public interface Database extends DatabaseTypes, HasProperties
The interface specifies the functions a Database provides, not how it is implemented. However the Ewe library provides a Database implementation that can be implemented on any object that provides RandomAccessStream functionality (such as a RandomAccessFile). This allows a Database to be setup in memory as easily as on disk.
Databases can be fully secure using Ewe encryption or any other type of encryption.
Modifier and Type | Field and Description |
---|---|
static String |
CreatedSortName |
static int |
FIELD_MODIFIER_INTEGER_AUTO_INCREMENT
Used by modifyField() - this modifies an INTEGER field to be auto-incremental.
|
static String |
ModifiedBySortName |
static String |
ModifiedSortName |
static String |
OidSortName |
static int |
SYNC_SLOW
This is a sync option that
suggests that the database use a sync model that uses less memory but may be slower.
|
static int |
SYNC_STORE_CREATION_DATE
This is a sync option that
tells the database to store the creation date along with every record.
|
static int |
SYNC_STORE_MODIFICATION_DATE
This is a sync option that
tells the database to store the modification date along with every record.
|
static int |
SYNC_STORE_MODIFIED_BY
This is a sync option that tells the database to save the MODIFIED_BY data with
each record.
|
static String |
SyncSortName |
BOOLEAN, BYTE_ARRAY, CREATED_FIELD, DATE, DATE_TIME, DECIMAL, DOUBLE, FIRST_SPECIAL_FIELD, FLAG_SYNCHRONIZED, FLAGS_FIELD, INTEGER, JAVA_OBJECT, LONG, MAX_ID, MODIFIED_BY_FIELD, MODIFIED_FIELD, NAME_FIELD, OBJECT_BYTES_FIELD, OBJECT_TEXT_FIELD, OID_FIELD, OPTION_ERROR_ON_NEED_REINDEX, PLAIN_DATE, PLAIN_TIME, reservedFieldHeaders, reservedFieldIDs, reservedFieldNames, reservedFieldTypes, SORT_DATE_ONLY, SORT_IGNORE_CASE, SORT_TIME_ONLY, SORT_UNKNOWN_IS_GREATER_THAN_KNOWN, SORT_UNKNOWN_IS_LESS_THAN_KNOWN, STRING, TIME, TIMESTAMP
Modifier and Type | Method and Description |
---|---|
int |
addField(String fieldName,
int fieldType)
Add a new field.
|
int |
addSort(String sortName,
int options,
int field)
Create a new sort criteria that sorts using one field only.
|
int |
addSort(String sortName,
int options,
int field1,
int field2,
int field3,
int field4)
Create a new sort criteria allowing you to specify up to four fields.
|
int |
addSort(String sortName,
int options,
String fieldList)
Create a new sort criteria allowing you to specify up to four fields.
|
void |
addSpecialField(int fieldCode)
Use this to add one of the reserved fields (the XXXX_FIELD) values.
|
void |
append(DatabaseEntry de)
Use this method in "Append" mode to add a data item to the Databse.
|
void |
change()
Mark the Database as having been changed in some way.
|
void |
close()
Close the database.
|
void |
closeLookup()
This is used with enableLookupMode() - it tells the database that data reading is complete
and the underlying file may be closed.
|
int |
countDeletedEntries()
Returns the number of entries marked as deleted.
|
Handle |
countEntries()
If getEntriesCount() returns -1, indicating that the number of entries is unknown,
then this method will count the entries by counting each one if necessary.
|
void |
delete()
Delete the database.
|
boolean |
deleteMetaData(String name) |
boolean |
deleteStream(String name)
Delete a Stream from the Database.
|
boolean |
enableLookupMode()
This method tells the database that it will be used for read-only lookups and that it can
close its underlying file if it wishes - and later re-open it when lookups are done without
re-reading the database info.
|
boolean |
enableSynchronization(Handle h,
int syncOptions)
This tells the database to include the OID_FIELD, FLAGS_FIELD, CREATED_FIELD and MODIFIED_FIELD
information with each record so that it can be synchronized with a other databases.
|
void |
enableSynchronization(int syncOptions)
This tells the database to include the OID_FIELD, FLAGS_FIELD, CREATED_FIELD and MODIFIED_FIELD
information with each record so that it can be synchronized with a other databases.
|
int[] |
ensureFields(Object objectOrClass,
String fields,
String headers)
Similar to setFields() except that no error is thrown if any fields
of the same name and type already exist.
|
int[] |
ensureSorts(Object objectOrClass,
String sorts)
This works the same as setSorts() except that no error is thrown if
any of the sorts already exists and has the same criteria of the already declared sort.
|
Iterator |
entries()
This returns an Iterator that you can use to go through the entries in
the database.
|
Iterator |
entries(Object searchData,
Comparer comparer)
This returns an Iterator that you can use to go through the entries in
the database.
|
Iterator |
entries(ObjectFinder entry)
This returns an Iterator that you can use to go through the entries in
the database.
|
void |
eraseDeletedEntries()
Erase all the entries marked as deleted.
|
boolean |
eraseDeletedEntry(long OID)
Erase the deleted entry for the specified OID.
|
long |
estimateEntriesCount()
If getEntriesCount() returns -1, indicating that the number of entries is unknown,
then this method will attempt to estimate the entries count via a quick non-blocking method
without resorting to counting each entry.
|
int |
findField(String fieldName)
Find the FieldID of a named field.
|
int[] |
findFields(String fieldNames)
Get an array of fieldIds for a comma separated list of field names.
|
int[] |
findFields(String[] fieldNames)
Get an array of fieldIds for an array of field names.
|
int |
findSort(String sortName)
Get the ID of a named sort criteria.
|
long |
getCurrentState()
Get the current changed state of the Database.
|
long[] |
getDeletedEntries()
Get an array of object IDs representing all the deleted entries.
|
DatabaseEntry |
getDeletedEntry(long OID,
DatabaseEntry dest)
Get the DatabaseEntry of the deleted OID.
|
long[] |
getDeletedSince(Time t)
Get all OIDs of all entries deleted since the Time t.
|
FoundEntries |
getEmptyEntries()
This returns an empty FoundEntries object for this Database
|
FoundEntries |
getEntries()
Deprecated.
use getFoundEntries(Handle h,int sortID) with a zero sortID instead.
|
FoundEntries |
getEntries(int sortID)
Deprecated.
use getFoundEntries(Handle h,int sortID) instead.
|
long |
getEntriesCount()
This will return the number of entries in the database if known.
|
EventDispatcher |
getEventDispatcher()
Get an EventDispatcher which you can use to attach EventListeners to, for
listening to the events being generated by the Database.
|
String |
getFieldHeader(int fieldID)
Get the header for a specified field ID.
|
String |
getFieldName(int fieldID)
Get the name for a specified field ID.
|
int[] |
getFields()
Get the IDs of all the fields.
|
int |
getFieldType(int fieldID)
Get the type of a field.
|
Handle |
getFoundEntries(Comparer comparer)
Get all the entries in the Database sorted by the specified Comparer in a new thread.
|
FoundEntries |
getFoundEntries(Handle h,
Comparer comparer)
Get all the entries in the Database sorted by the specific comparer.
|
FoundEntries |
getFoundEntries(Handle h,
int sortID)
Get all the entries in the Database sorted by the specified sort ID.
|
FoundEntries |
getFoundEntries(Handle h,
int sortID,
EntrySelector selector)
Get a subset of the entries in the Database sorted by the specific sort ID and
which the EntrySelector considers to be equal to the searchData.
|
FoundEntries |
getFoundEntries(Handle h,
int sortID,
Object primarySearchFields)
Get a subset of the entries in the Database sorted by the specific sort ID and
which match the primarySearchFields data.
|
FoundEntries |
getFoundEntries(Handle h,
int sortID,
ObjectFinder finder)
Get a subset of the entries in the Database sorted by the specific sort ID and
which the ObjectFinder considers to be what is being looked for.
|
FoundEntries |
getFoundEntries(Handle h,
String indexName)
Get all the entries in the database sorted according to the specified index.
|
Handle |
getFoundEntries(int sortID)
Get all the entries in the Database sorted by the specified sort ID in a new thread.
|
Handle |
getFoundEntries(int sortID,
EntrySelector selector)
Get a subset the entries in the Database sorted by the specified sort ID in a new thread.
|
Handle |
getFoundEntries(int sortID,
Object primarySearchFields)
Get a subset of the entries in the Database sorted by the specific sort ID and
which match the primarySearchFields data in a new thread.
|
Handle |
getFoundEntries(int sortID,
ObjectFinder finder)
Get a subset of the entries in the Database sorted by the specific sort ID and
which the ObjectFinder considers to be what is being looked for in a new thread.
|
Handle |
getFoundEntries(String indexName)
Get all the entries in the Database sorted by the specified index in a new thread.
|
int |
getIdentifier()
Get a unique identifier for this database - used for synchronizing.
|
IndexEntry[] |
getIndexes()
This returns all the indexes used by the Database.
|
Locale |
getLocale()
Set the locale being used with the Database.
|
Object |
getMetaData(String name,
int length,
boolean mustExist) |
Time |
getModifiedTime()
Get the time of the last modification made to the database.
|
DatabaseEntry |
getNewData()
Return an empty DatabaseEntry to be used with this database.
|
Object |
getNewDataObject()
Create and return a new instance of the object class assigned to the
database.
|
Class |
getObjectClass()
If setObjectClass() was used on the database to specify a Java class to
be used as a data interface, then this will return a Reflect object
representing that class.
|
int[] |
getSortFields(int sortID)
Get the fields by which the Sort will sort.
|
String |
getSortName(int sortID)
Get the name of a Sort.
|
int |
getSortOptions(int sortID)
Get the options associated with the sortID.
|
int[] |
getSorts()
Get the IDs of all the sorts.
|
long |
getStreamLength(String name)
Returns the length of a meta-data Stream stored in the Database, or -1 if the named Stream
does not exist.
|
StringCollator |
getStringCollator()
Return the Collator used by the database to sort and search for Strings.
|
Time |
getSynchronizedTime(int remoteDatabaseID) |
Time |
getTimeOfDeletion(long OID,
Time destination)
Return the time of deletion of the specified OID.
|
boolean |
hasChangedSince(long previousState)
Return if the Database has changed since the previous state.
|
boolean |
indexBy(Handle h,
Class databaseEntryComparer,
String name)
This tells the Database to keep an index using a particular Comparer class and
distinct name.
|
boolean |
indexBy(Handle h,
int sortID,
String name)
This tells the Database to keep an index for a particular sort ID and optional
distinct name.
|
void |
indexBy(int sortID)
This is a convenience method for the other indexBy method.
|
boolean |
isIndexedBy(int sortID)
This returns if the Database has at least one index that uses the specified sort ID.
|
boolean |
isInstanceOfDataObject(Object data)
Return if the specified object is an instance of the data transfer object
assigned in setObjectClass();
|
boolean |
isOpenForReadWrite()
This should return true if the Database is open in read/write mode, or false
if it is open in read-only mode.
|
int |
metaDataLength(String name)
Returns the length of the named MetaData (in bytes) in the DB.
|
void |
modifyField(int fieldID,
int modifier,
Object modifierData)
Modify a field in some way.
|
void |
openLookup()
This is used with enableLookupMode() - it tells the database that data is about to be read in
and if the underlying file is closed - then it should be re-opened and kept open until closeLookup()
is called.
|
InputStream |
openStreamForReading(String name)
Open a Stream into the database to read some sort of meta-data.
|
OutputStream |
openStreamForReplacing(String name)
Open a Stream into the database to save some sort of meta-data.
|
OutputStream |
openStreamForWriting(String name,
boolean append)
Open a Stream into the database to save some sort of meta-data.
|
int[] |
overrideFields(Object objectOrClass,
String fields,
String headers)
Similar to setFields() except that no error is thrown if any fields
of the same name and type already exist.
|
int[] |
overrideSorts(Object objectOrClass,
String sorts)
This works the same as setSorts() except that no error is thrown if
any of the sorts already exists and has the same criteria of the already declared sort,
and also any old sorts of the same name will be replaced by the new sort.
|
void |
readMetaData(Object metaLocation,
int metaOffset,
byte[] data,
int offset,
int length) |
int |
readMetaDataInt(Object metaLocation,
int offset) |
boolean |
reIndex(Handle h)
In "Append" mode, after all the data has been added, call this method to re-index the
database.
|
void |
removeField(int fieldID)
Remove a field.
|
void |
removeSort(int sortID)
Remove a Sort.
|
void |
rename(String newName)
Rename the database.
|
void |
save()
Save the Database specs to permanent storage.
|
void |
setDataValidator(DataValidator validator)
Set a DataValidator to validate data before it is saved in the Database.
|
void |
setEncryption(DataProcessor decryptor,
DataProcessor encryptor)
Use this when the Database is initialized to set the decryptor and encryptor
for the data.
|
boolean |
setFieldHeader(int fieldID,
String newHeader)
Set the header for a specified field ID.
|
int[] |
setFields(Object objectOrClass)
Set the fields for the Database, which must match fields in the objectOrClass
transfer object.
|
int[] |
setFields(Object objectOrClass,
String fields)
Set the fields for the Database, which must match fields in the objectOrClass
transfer object.
|
int[] |
setFields(Object objectOrClass,
String fields,
String headers)
Set the fields for the Database, which must match fields in the objectOrClassOrReflect
transfer object.
|
void |
setLocale(Locale locale)
Set the locale to be used with the Database.
|
boolean |
setModifiedTime(Time t)
Set the time of the last modification made to the database.
|
void |
setObjectClass(Object objectOrClass)
This is used to set the class of the object used for data transfer to
and from the table.
|
int |
setOptions(int optionsToSet,
int optionsToClear)
Set/Clear/Retrieve Database options.
|
void |
setPassword(String password)
Use this when the Database is initialized to set the encryption key for the database.
|
int[] |
setSorts(Object objectOrClass)
Set the sorts of the Database as specified by the object provided.
|
int[] |
setSorts(Object objectOrClass,
String sorts)
Set the sorts of the Database as specified by the object provided.
|
void |
setStringCollator(StringCollator collator)
Set the Collator used by the database to sort and search for Strings.
|
void |
setSynchronizedTime(int remoteDatabaseID,
Time syncTime) |
int[] |
toCriteria(int sortID)
Convert the sortID to a Criteria array, used by a number of
Database functions.
|
boolean |
useEncryption(DataProcessor decryptor,
DataProcessor encryptor)
Use this when opening the database and accessing the data.
|
boolean |
usePassword(Object key)
Use this when opening the database and accessing the data.
|
void |
writeMetaData(Object metaLocation,
int metaOffset,
byte[] data,
int offset,
int length) |
void |
writeMetaDataInt(Object metaLocation,
int offset,
int value) |
getProperties
static final int FIELD_MODIFIER_INTEGER_AUTO_INCREMENT
static final int SYNC_SLOW
static final int SYNC_STORE_CREATION_DATE
static final int SYNC_STORE_MODIFICATION_DATE
static final int SYNC_STORE_MODIFIED_BY
static final String OidSortName
static final String SyncSortName
static final String ModifiedSortName
static final String ModifiedBySortName
static final String CreatedSortName
int setOptions(int optionsToSet, int optionsToClear)
optionsToSet
- any of the DatabaseTypes.OPTION_XXXX values OR'ed together.optionsToClear
- any of the DatabaseTypes.OPTION_XXXX values OR'ed together.void setEncryption(DataProcessor decryptor, DataProcessor encryptor) throws IOException
IOException
void setPassword(String password) throws IllegalArgumentException, IOException
password
- a string to be used as the password. Choose a mix of numeric and letters
for better security.IllegalArgumentException
IOException
boolean useEncryption(DataProcessor decryptor, DataProcessor encryptor) throws IOException
decryptor
- The decryptor. Necessary for reading and writing if the Database is encrypted.encryptor
- The encryptor. Necessary for writing only if the Database is encrypted.IOException
boolean usePassword(Object key) throws IOException
IOException
Locale getLocale()
void setLocale(Locale locale)
int countDeletedEntries() throws IOException
IOException
- on error.long[] getDeletedEntries() throws IOException
IOException
void eraseDeletedEntries() throws IOException
IOException
DatabaseEntry getDeletedEntry(long OID, DatabaseEntry dest) throws IOException
OID
- The OID to look for.IOException
Time getTimeOfDeletion(long OID, Time destination) throws IOException
OID
- The OID of the deleted entry.destination
- an optional destination time. If this is null the a new Time will
be created.IOException
boolean eraseDeletedEntry(long OID) throws IOException
OID
- the OID of the deleted entry.IOException
long[] getDeletedSince(Time t) throws IOException
IOException
void setObjectClass(Object objectOrClass) throws IllegalArgumentException
objectOrClass
- IllegalArgumentException
Class getObjectClass()
Object getNewDataObject() throws IllegalStateException
IllegalStateException
- if no object class is specified or the
object could not be instantiated.boolean isInstanceOfDataObject(Object data)
data
- the object to check.boolean isOpenForReadWrite()
int[] setSorts(Object objectOrClass) throws IllegalArgumentException
objectOrClass
- the Class of the object or an instance of the object.IllegalArgumentException
- if a sort conflicts with an already saved sort.int[] setSorts(Object objectOrClass, String sorts) throws IllegalArgumentException
objectOrClass
- the Class of the object or an instance of the object.sorts
- a String specifying the sort criteria to use.IllegalArgumentException
- if a sort conflicts with an already saved sort.int[] ensureSorts(Object objectOrClass, String sorts) throws IllegalArgumentException
objectOrClass
- the Class of the object or an instance of the object.sorts
- a String specifying the sort criteria to use.IllegalArgumentException
int[] overrideSorts(Object objectOrClass, String sorts) throws IllegalArgumentException
objectOrClass
- the Class of the object or an instance of the object.sorts
- a String specifying the sort criteria to use.IllegalArgumentException
int[] ensureFields(Object objectOrClass, String fields, String headers) throws IllegalArgumentException
objectOrClass
- The object or class of the object to be used for data transfer.fields
- A comma separated list of fields.headers
- An optional comma separated list of headers.IllegalArgumentException
int[] overrideFields(Object objectOrClass, String fields, String headers) throws IllegalArgumentException
objectOrClass
- The object or class of the object to be used for data transfer.fields
- A comma separated list of fields.headers
- An optional comma separated list of headers.IllegalArgumentException
int[] setFields(Object objectOrClass) throws IllegalArgumentException
objectOrClass
- The object or class of the object to be used for data transfer.IllegalArgumentException
int[] setFields(Object objectOrClass, String fields) throws IllegalArgumentException
objectOrClass
- The object or class of the object to be used for data transfer.fields
- A comma separated list of fields.IllegalArgumentException
int[] setFields(Object objectOrClass, String fields, String headers) throws IllegalArgumentException
objectOrClass
- The object or class of the object to be used for data transfer.fields
- A comma separated list of fields.headers
- An optional comma separated list of headers.IllegalArgumentException
int findField(String fieldName)
fieldName
- The name of the field.int[] findFields(String[] fieldNames)
int[] findFields(String fieldNames)
String getFieldName(int fieldID)
String getFieldHeader(int fieldID)
boolean setFieldHeader(int fieldID, String newHeader)
String getSortName(int sortID)
int[] getSortFields(int sortID)
int getSortOptions(int sortID)
int[] toCriteria(int sortID) throws IllegalArgumentException
IllegalArgumentException
int getFieldType(int fieldID)
int[] getFields()
int[] getSorts()
int addField(String fieldName, int fieldType) throws IllegalArgumentException
fieldName
- The name of the new field.fieldType
- The type of the new field.IllegalArgumentException
void modifyField(int fieldID, int modifier, Object modifierData) throws IllegalArgumentException, IOException
fieldID
- The id of the field to modify.modifier
- one of the FIELD_MODIFIER_XXX values appropriate for the field type.modifierData
- Some data dependent on the field modifier used.IllegalArgumentException
- if the modifier is not appropriate for the field or
if the data is not the correct type for the modifier.IOException
int findSort(String sortName)
sortName
- The name of the sort criteria.int addSort(String sortName, int options, int field) throws IllegalArgumentException
IllegalArgumentException
int addSort(String sortName, int options, int field1, int field2, int field3, int field4) throws IllegalArgumentException
sortName
- The name of the sort.options
- Sorting options.field1
- the id of the field for the first (primary) sort criteria.field2
- the id of the field for the second sort criteria - set to 0 for no more fields.field3
- the id of the field for the third sort criteria - set to 0 for no more fields.field4
- the id of the field for the fourth sort criteria - set to 0 for no more fields.IllegalArgumentException
int addSort(String sortName, int options, String fieldList) throws IllegalArgumentException
sortName
- The name of the sort.options
- Sorting options.fieldList
- A comma separated field list.IllegalArgumentException
- if any of the fields could not be found, or if too many
fields are specified.void removeField(int fieldID)
fieldID
- the ID of the field to remove.void removeSort(int sortID)
sortID
- the ID of the sort to remove.DatabaseEntry getNewData()
void append(DatabaseEntry de) throws IOException
IOException
boolean reIndex(Handle h) throws IOException
If you close the database without doing reIndex, it will be reIndexed automatically the next time it is opened.
h
- a Handle that can be used to monitor or abort the operation.IOException
- if there was an error writing to the database.FoundEntries getEmptyEntries()
FoundEntries getEntries() throws IOException, DataTooBigException
DataTooBigException
- if the number of entries cannot fit in a FoundEntries
object. In this case the method should be called again with a finder that is more restrictive
of the included entries.IOException
FoundEntries getEntries(int sortID) throws IOException, DataTooBigException
sortID
- The sortID to use. If this is 0 the entries are not sorted.IOException
DataTooBigException
- if the number of entries cannot fit in a FoundEntries
object. In this case the method should be called again with a finder that is more restrictive
of the included entries.FoundEntries getFoundEntries(Handle h, int sortID) throws IOException, DataTooBigException
h
- a handle that other threads can use to monitor the operation progress.sortID
- The sortID to use. If this is 0 the entries are not sorted.IOException
DataTooBigException
- if the number of entries cannot fit in a FoundEntries
object. In this case the method should be called again with a finder that is more restrictive
of the included entries.FoundEntries getFoundEntries(Handle h, int sortID, EntrySelector selector) throws IOException, DataTooBigException
h
- an optional Handle used to monitor and possibly abort the process.sortID
- The sortID to use. If this is 0 the entries are not sorted.selector
- An object used to select the data according to certain criteria.IOException
DataTooBigException
- if the number of entries cannot fit in a FoundEntries
object. In this case the method should be called again with a finder that is more restrictive
of the included entries.FoundEntries getFoundEntries(Handle h, int sortID, ObjectFinder finder) throws IOException, DataTooBigException
h
- an optional Handle used to monitor and possibly abort the process.sortID
- The sortID to use. If this is 0 the entries are not sorted.finder
- This object will have its lookingFor(Object obj) method called for each
entry in the database. If the finder returns true, then that entry will be placed in the FoundEntries
returned.IOException
DataTooBigException
- if the number of entries cannot fit in a FoundEntries
object. In this case the method should be called again with a finder that is more restrictive
of the included entries.FoundEntries getFoundEntries(Handle h, int sortID, Object primarySearchFields) throws IOException, DataTooBigException
h
- an optional Handle used to monitor and possibly abort the process.sortID
- The sortID to use. If this is 0 the entries are not sorted.primarySearchFields
- data that will be used to select entries in the Database.IOException
DataTooBigException
- if the number of entries cannot fit in a FoundEntries
object. In this case the method should be called again with a finder that is more restrictive
of the included entries.FoundEntries getFoundEntries(Handle h, Comparer comparer) throws IOException, DataTooBigException
h
- an optional Handle used to monitor and possibly abort the process.comparer
- This is used to sort the entries.IOException
DataTooBigException
- if the number of entries cannot fit in a FoundEntries
object. In this case the method should be called again with a finder that is more restrictive
of the included entries.FoundEntries getFoundEntries(Handle h, String indexName) throws IllegalArgumentException, IOException, DataTooBigException
h
- an optional Handle used to monitor and possibly abort the process.indexName
- a valid index name.IllegalArgumentException
IOException
DataTooBigException
- if the number of entries cannot fit in a FoundEntries
object. In this case the method should be called again with a finder that is more restrictive
of the included entries.Handle getFoundEntries(int sortID)
sortID
- The sortID to use. If this is 0 the entries are not sorted.Handle getFoundEntries(int sortID, EntrySelector selector)
sortID
- The sortID to use. If this is 0 the entries are not sorted.selector
- An object used to select the data according to certain criteria.Handle getFoundEntries(int sortID, ObjectFinder finder)
sortID
- The sortID to use. If this is 0 the entries are not sorted.finder
- This object will have its lookingFor(Object obj) method called for each
entry in the database. If the finder returns true, then that entry will be placed in the FoundEntries
returned.Handle getFoundEntries(int sortID, Object primarySearchFields)
sortID
- The sortID to use. If this is 0 the entries are not sorted.primarySearchFields
- data that will be used to select entries in the Database.Handle getFoundEntries(Comparer comparer)
comparer
- This is used to sort the entries.Handle getFoundEntries(String indexName)
indexName
- a valid index name.void save() throws IOException
IOException
- if an error occurs.void close() throws IOException
IOException
- on error.void delete() throws IOException
IOException
- if the database could not be deleted.void rename(String newName) throws IOException
newName
- the new name for the database.IOException
- if the database could not be renamed.Time getModifiedTime() throws IOException
IOException
- on error.boolean setModifiedTime(Time t) throws IOException
t
- the modified time.IOException
- on error.void addSpecialField(int fieldCode) throws IllegalArgumentException
IllegalArgumentException
void enableSynchronization(int syncOptions) throws IOException
syncOptions
- any of the SYNC_XXX values ORed together.IOException
boolean enableSynchronization(Handle h, int syncOptions) throws IOException
a
- Handle that can be used by another thread to monitor and abort
the progress of the operation.syncOptions
- any of the SYNC_XXX values ORed together.IOException
int getIdentifier() throws IOException
IOException
void setSynchronizedTime(int remoteDatabaseID, Time syncTime) throws IOException
IOException
Time getSynchronizedTime(int remoteDatabaseID) throws IOException
IOException
long getEntriesCount() throws IOException
IOException
- on error.long estimateEntriesCount() throws IOException
IOException
- on error.Handle countEntries()
Iterator entries() throws IOException
The getNext() method of the returned iterator may throw a DatabaseIOException if there is an IO error when retrieving the next entry.
IOException
Iterator entries(ObjectFinder entry) throws IOException
The getNext() method of the returned iterator may throw a DatabaseIOException if there is an IO error when retrieving the next entry.
IOException
Iterator entries(Object searchData, Comparer comparer) throws IOException
The getNext() method of the returned iterator may throw a DatabaseIOException if there is an IO error when retrieving the next entry.
IOException
boolean indexBy(Handle h, int sortID, String name) throws IOException, IllegalArgumentException
Creating a new index will usually involve sorting all the entries of the database so this may take some time to complete and you can monitor and abort the operation using the Handle parameter.
h
- An optional handle that you can use to monitor and control any index creation
operation.sortID
- A valid sort ID for the database.name
- A distinct name for the index. If it is null then the same name as the sort ID
will be used.IOException
- If an IO error occured using the database.IllegalArgumentException
- if the sort ID is invalid.boolean indexBy(Handle h, Class databaseEntryComparer, String name) throws IOException, IllegalArgumentException
Creating a new index will usually involve sorting all the entries of the database so this may take some time to complete and you can monitor and abort the operation using the Handle parameter.
h
- An optional handle that you can use to monitor and control any index creation
operation.databaseEntryComparer
- A valid object that implements DatabaseEntryComparername
- A distinct name for the index, which must not be null.IOException
- If an IO error occured using the database.IllegalArgumentException
- if the comparer or name is invalid.void indexBy(int sortID) throws IOException, IllegalArgumentException
sortID
- A valid sort ID for the database.IOException
- If an IO error occured using the database.IllegalArgumentException
- if the sort ID is invalid.boolean isIndexedBy(int sortID)
IndexEntry[] getIndexes()
long getCurrentState()
boolean hasChangedSince(long previousState)
void change()
EventDispatcher getEventDispatcher()
OutputStream openStreamForWriting(String name, boolean append) throws IOException
name
- The name of the meta-data Stream.append
- Set this true if you want to add to the data already stored in the stream.IOException
- if an error occurs.OutputStream openStreamForReplacing(String name) throws IOException
name
- The name of the meta-data Stream.IOException
- if an error occurs.InputStream openStreamForReading(String name) throws IOException
name
- The name of the meta-data Stream.IOException
- if an error occurs or if the Stream does not exist.boolean deleteStream(String name) throws IOException
name
- The name of the meta-data Stream.IOException
- if an error occurs.IOException
- if an error occurs.long getStreamLength(String name) throws IOException
name
- the name of the Stream.IOException
- if an error occurs.void setDataValidator(DataValidator validator)
validator
- A validator or null to clear the validator.IOException
- if there was an error saving the validator.void readMetaData(Object metaLocation, int metaOffset, byte[] data, int offset, int length) throws IOException
IOException
void writeMetaData(Object metaLocation, int metaOffset, byte[] data, int offset, int length) throws IOException
IOException
Object getMetaData(String name, int length, boolean mustExist) throws IOException, IllegalArgumentException
IOException
IllegalArgumentException
boolean deleteMetaData(String name) throws IOException
IOException
int readMetaDataInt(Object metaLocation, int offset) throws IOException
IOException
void writeMetaDataInt(Object metaLocation, int offset, int value) throws IOException
IOException
int metaDataLength(String name) throws IOException
name
- the name of the MetaData.IOException
boolean enableLookupMode() throws IOException
Not all Databases may support this and if it does not, it will return false - although normal database operations will not be affected. In other words - if this method returns false, the application can continue as if it returned true - but its operations will not be optimized in this way.
IOException
- if an IO error occurs.void openLookup() throws IOException
IOException
- if an IO error occurs.void closeLookup() throws IOException
IOException
- if an IO error occurs.StringCollator getStringCollator()
void setStringCollator(StringCollator collator)