public interface FoundEntries extends DatabaseTypes
You get a FoundEntries object by calling one of the getFoundEntries() methods on the Database or you can call getEmptyEntries() to get an empty FoundEntries which you can then add records to.
You use FoundEntries to retrieve, add, delete and modify records and the FoundEntries will maintain its sort state during these operations.
You can get an EntriesView object for a FoundEntries using getEmptyEntries() or getFullView() and then use that EntriesView object to search the data using any criteria. You can then create a new FoundEntries from the results of the search using getSubSet() and then create a new FoundEntries object sorted by some other criteria using one of the sort() methods.
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 |
add(DatabaseEntry toAdd)
This saves a new entry to the database AND adds it to this FoundEntries
object.
|
int |
addData(Object data)
Add a new entry using the data object.
|
void |
change()
Mark the FoundEntries as having been changed in some way.
|
void |
delete(int index)
This deletes the data AND removes it from this FoundEntries list.
|
void |
erase(int index)
This erases the data without marking it as deleted AND removes it from this FoundEntries list.
|
void |
exclude(DatabaseEntry entry)
Exclude the entry from this FoundEntries if it is in it.
|
void |
exclude(int index)
Exclude the entry from this FoundEntries.
|
boolean |
excludeAll(Handle h,
EntriesView viewFromOtherFoundEntries)
Exclude all the entries as specified from the view of another FoundEntries
from this FoundEntries.
|
IntArray |
filterAll(Handle h,
ObjectFinder finder,
IntArray dest)
Find, using an entry by entry sequential search, all entries in the FoundEntries that match the
criteria as specified by the selector.
|
long |
findAll(Handle h,
EntrySelector selector)
Find, using a binary chop search, all entries in the FoundEntries that match the
criteria as specified by the selector.
|
IntArray |
findAll(Handle h,
EntrySelector selector,
IntArray dest)
Find, using a binary chop search, all entries in the FoundEntries that match the
criteria as specified by the selector.
|
long |
findAll(Handle h,
Object search,
boolean hasWildCards)
Find, using a binary chop search, all entries in the FoundEntries that match the
criteria as specified by the selector.
|
long |
findAll(Handle h,
Object searchData,
Comparer comparer)
This finds the last index of the entry which (according to the provided
Comparer) matches a search criteria.
|
int |
findFirst(Handle h,
Object searchData,
boolean hasWildCards)
Find the index of the first entry that matches a search criteria.
|
int |
findFirst(Handle h,
Object searchData,
Comparer comparer)
This finds the first index of the entry which (according to the provided
Comparer) matches a search criteria.
|
int |
findInsertIndex(DatabaseEntry toAdd)
Find the index where the specified entry would be added in the FoundEntries.
|
int |
findLast(Handle h,
Object searchData,
boolean hasWildCards)
Find the index of the last entry that matches a search criteria.
|
int |
findLast(Handle h,
Object searchData,
Comparer comparer)
This finds the last index of the entry which (according to the provided
Comparer) matches a search criteria.
|
Range |
findRange(Handle h,
EntrySelector selector,
Range dest)
Find the range of indexes which match the search criteria as specified in the EntrySelector
parameter.
|
DatabaseEntry |
get(int index)
Get the data at the specified index, creating a new DatabaseEntry to get it from.
|
DatabaseEntry |
get(int index,
DatabaseEntry data)
Get the data at the specified index.
|
void |
get(int index,
int[] fieldIDs,
Object[] destinationObjects)
A convenience method for retrieving only a limited set of field values for
a particular entry.
|
FoundEntries |
getCopy()
Get a full copy of this FoundEntries, including the entries themselves.
|
long |
getCurrentState()
Get the current changed state of the FoundEntries.
|
Object |
getData(int index)
Get the data object from the specified index.
|
Object |
getData(int index,
Object destination)
Get the data object from the specified index.
|
Database |
getDatabase()
Get the database associated with the FoundEntries.
|
EntriesView |
getEmptyView()
Get a new EntriesView for this FoundEntries that is initially empty.
|
EntrySelector |
getEntrySelector(Object searchData,
boolean hasWildCards)
Get an EntrySelector for the data given the search data.
|
EventDispatcher |
getEventDispatcher()
Get the EventDispatcher for this FoundEntries.
|
EntriesView |
getFullView(EntriesView destination)
Get an EntriesView that contains all the entries in this FoundEntries.
|
DatabaseEntry |
getNew()
Create a new DatabaseEntry for this FoundEntries.
|
Comparer |
getSortComparer()
Return the current sort Comparer.
|
int[] |
getSortCriteria()
Return the current sort criteria if one was used.
|
int |
getSortEntry()
Return the ID of the sort used to sort the database by if one was used.
|
FoundEntries |
getSubSet(EntriesView view)
Get a SubSet of this FoundEntries using the indexes included in the view.
|
boolean |
hasChangedSince(long previousState)
Return if the FoundEntries has changed since the previous state.
|
int |
include(DatabaseEntry entry)
Add an entry to the FoundEntries if it was not added before.
|
boolean |
includeAll(Handle h,
EntriesView viewFromOtherFoundEntries)
Include all the entries as specified from the view of another FoundEntries
in this FoundEntries.
|
int |
indexOf(DatabaseEntry entry)
Return the index of the entry in the FoundEntries object.
|
boolean |
isAllInclusive()
If a FoundEntries is all inclusive then adding entries to the database will automatically
add the new entries to the FoundEntries.
|
boolean |
isSorted()
Return if the entries are sorted.
|
boolean |
searchIsCompatibleWithSortState(int[] criteria)
Check if the proposed search criteria is compatible with the FoundEntries current sort.
|
int |
set(int index,
DatabaseEntry changed)
This saves changes to the data entry and will rearrange current entries
to maintain its sort order.
|
void |
setAddNewEntriesFirst(boolean addFirst)
If you add a new entry to a sorted FoundEntries, then that new entry may match
exactly other entries already in the FoundEntries.
|
void |
setAllInclusive(boolean allInclusive)
If a FoundEntries is all inclusive then adding entries to the database will automatically
add the new entries to the FoundEntries.
|
int |
setData(int index,
Object data)
Set the data at the specified index using the data object.
|
int |
size()
Return the number of entries in the FoundEntries.
|
Handle |
sort(Comparer comparer)
Sort the found entries in a separate thread.
|
FoundEntries |
sort(Handle h,
Comparer comparer)
This sorts the FoundEntries in the current thread using the specified Comparer.
|
FoundEntries |
sort(Handle h,
int sortID)
This sorts the FoundEntries in the current thread using the specified sortID.
|
FoundEntries |
sort(Handle h,
int[] criteria)
This sorts the FoundEntries in the current thread using the specified sortID.
|
Handle |
sort(int sortID)
Sort the found entries in a separate thread.
|
Handle |
sort(int[] criteria)
Sort the found entries in a separate thread.
|
int |
store(int index,
DatabaseEntry changed)
This saves changes to the entry but does not modify its special synchronization fields.
|
Database getDatabase()
int size()
DatabaseEntry getNew()
int add(DatabaseEntry toAdd) throws IOException
IOException
void delete(int index) throws IOException
IOException
void erase(int index) throws IOException
IOException
DatabaseEntry get(int index, DatabaseEntry data) throws IOException
index
- The index to read from.data
- a destination DatabaseEntry, which can be null.IOException
- on error.DatabaseEntry get(int index) throws IOException
index
- The index to read from.IOException
- on error.int indexOf(DatabaseEntry entry)
entry
- the entry to look for.FoundEntries sort(Handle h, int[] criteria) throws IOException
h
- the Handle for monitoring the sort. This can be null but if it is the possibility
exists that the sort may run natively thereby not giving other threads a chance to run.criteria
- the sort criteria.IOException
- if there was an error reading data for sorting.Handle sort(int[] criteria) throws IOException
database
- The database to sort the entries.criteria
- The criteria for sorting.IOException
FoundEntries sort(Handle h, int sortID) throws IllegalArgumentException, IOException
h
- the Handle for monitoring the sort. This can be null but if it is the possibility
exists that the sort may run natively thereby not giving other threads a chance to run.sortID
- The sortID in the database to sort by.IllegalArgumentException
- if the sortID is not valid.IOException
- if there was an error reading data for sorting.Handle sort(int sortID) throws IllegalArgumentException
sortID
- The sortID in the database to sort by.IllegalArgumentException
FoundEntries sort(Handle h, Comparer comparer) throws IOException
h
- the Handle for monitoring the sort. This can be null but if it is the possibility
exists that the sort may run natively thereby not giving other threads a chance to run.comparer
- a Comparer used to compare each entry.IOException
- if there was an error reading data for sorting.Handle sort(Comparer comparer) throws IOException
comparer
- a Comparer used to compare each entry.IOException
FoundEntries getCopy()
boolean isSorted()
int getSortEntry()
int[] getSortCriteria()
Comparer getSortComparer()
long getCurrentState()
boolean hasChangedSince(long previousState)
void change()
Object getData(int index, Object destination) throws IllegalStateException, IllegalArgumentException, IOException
index
- the index in the FoundEntries object.destination
- a destination object. If this is null a new one will be created if
possible.IllegalArgumentException
- if the destination object is not the right type.IllegalStateException
- if a new object was requested but could not be created.IOException
- if there is an error reading the data.Object getData(int index) throws IllegalStateException, IOException
index
- the index in the FoundEntries object.IllegalStateException
- if a new object could not be created.IOException
- if there is an error reading the data.int setData(int index, Object data) throws IllegalArgumentException, IOException
index
- the index in the FoundEntries object.data
- the data object.IllegalArgumentException
- if the destination object is not the right type.IOException
- if there is an error writing the data.int set(int index, DatabaseEntry changed) throws IOException
index
- The index of the entry.changed
- the changed entry.IOException
- on error.int store(int index, DatabaseEntry changed) throws IOException
index
- The index of the entry.changed
- the changed entry.IOException
- on error.void get(int index, int[] fieldIDs, Object[] destinationObjects) throws IOException
index
- the index of the entry.fieldIDs
- the field IDs.destinationObjectsAndWrappers
- the destination Object and/or Wrappers
to hold the data. See DatabaseEntry.getFieldValue() to see the destination types to use.IOException
int addData(Object data) throws IllegalArgumentException, IOException
data
- the data object.IllegalArgumentException
- if the destination object is not the right type.IOException
- if there is an error writing the data.int include(DatabaseEntry entry) throws IllegalArgumentException, IOException
entry
- the entry to include.IllegalArgumentException
- if the entry is not a valid saved entry.IOException
- on error.void exclude(DatabaseEntry entry) throws IllegalArgumentException, IOException, IllegalStateException
entry
- the entry to exclude.IllegalArgumentException
- if the entry is not a valid saved entry.IOException
- on error.IllegalStateException
- if the FoundEntries is all-inclusive or is a DatabaseIndex.void exclude(int index) throws IOException, IllegalStateException
index
- the index of the entry.IOException
- on error.IllegalStateException
- if the FoundEntries is all-inclusive or is a DatabaseIndex.void setAllInclusive(boolean allInclusive) throws IllegalArgumentException
allInclusive
- true to set the FoundEntries to all inclusive, false to set to be not
all inclusive.IllegalArgumentException
- if you try to set a FoundEntries associated with a
DatabaseIndex to non all inclusive.boolean isAllInclusive()
void setAddNewEntriesFirst(boolean addFirst)
addFirst
- if this is true then the new entry is added before the matching entries.boolean searchIsCompatibleWithSortState(int[] criteria)
criteria
- the proposed sort criteria.EntrySelector getEntrySelector(Object searchData, boolean hasWildCards) throws IllegalStateException
searchData
- the data to search for.hasWildCards
- this should be true if the data contains wild cards.IllegalStateException
EntriesView getEmptyView()
EntriesView getFullView(EntriesView destination)
destination
- an optional EntriesView object to hold the data.FoundEntries getSubSet(EntriesView view)
boolean includeAll(Handle h, EntriesView viewFromOtherFoundEntries) throws IOException
h
- an optional handle used to monitor and possibly abort the process.viewFromOtherFoundEntries
- a view into another FoundEntries object.IOException
boolean excludeAll(Handle h, EntriesView viewFromOtherFoundEntries) throws IOException
h
- an optional handle used to monitor and possibly abort the process.viewFromOtherFoundEntries
- a view into another FoundEntries object.IOException
int findFirst(Handle h, Object searchData, Comparer comparer) throws IOException, IllegalStateException, HandleStoppedException
During the search the comparer will have its compare() method called with the searchData parameter object as the first parameter and a DatabaseEntry object as the second parameter. The comparer should return
<0 if the DatabaseEntry is considered greater than the search data. 0 if the DatabaseEntry is considered to match the search data. >0 if the DatabaseEntry is considered less than the search data.The Comparer should NOT take into account if the SORT_DESCENDING option is set - that will be taken care of by the search routine.
h
- an optional handle used to monitor and possibly abort the process.searchData
- search data possibly used by the comparer - this can be null.comparer
- a comparer to compare the search data with the data in records of the FoundEntries.IOException
IllegalStateException
- if this FoundEntries is not sorted.HandleStoppedException
- if the operation was aborted.int findLast(Handle h, Object searchData, Comparer comparer) throws IOException, IllegalStateException, HandleStoppedException
During the search the comparer will have its compare() method called with the searchData parameter object as the first parameter and a DatabaseEntry object as the second parameter. The comparer should return
<0 if the DatabaseEntry is considered greater than the search data. 0 if the DatabaseEntry is considered to match the search data. >0 if the DatabaseEntry is considered less than the search data.The Comparer should NOT take into account if the SORT_DESCENDING option is set - that will be taken care of by the search routine.
h
- an optional handle used to monitor and possibly abort the process.searchData
- search data possibly used by the comparer.comparer
- a comparer to compare the search data with the data in records of the FoundEntries.IOException
IllegalStateException
- if this FoundEntries is not sorted.HandleStoppedException
- if the operation was aborted.int findFirst(Handle h, Object searchData, boolean hasWildCards) throws IOException, IllegalStateException, HandleStoppedException
h
- an optional handle used to monitor and possibly abort the process.searchData
- search data possibly used by the comparer.hasWildCards
- set this true if the search data has wildcard data (e.g. '*' characters).IOException
IllegalStateException
- if this FoundEntries is not sorted.HandleStoppedException
- if the operation was aborted.int findLast(Handle h, Object searchData, boolean hasWildCards) throws IOException, IllegalStateException, HandleStoppedException
h
- an optional handle used to monitor and possibly abort the process.searchData
- search data possibly used by the comparer.hasWildCards
- set this true if the search data has wildcard data (e.g. '*' characters).IOException
IllegalStateException
- if this FoundEntries is not sorted.HandleStoppedException
- if the operation was aborted.int findInsertIndex(DatabaseEntry toAdd) throws IOException
IOException
Range findRange(Handle h, EntrySelector selector, Range dest) throws IOException, IllegalArgumentException
h
- An optional handle that can be used to monitor the progress of the operation.selector
- An EntrySelector used to determine which entries to include in the range.dest
- An optional destination Range object.IOException
- On error reading the database.IllegalArgumentException
- If the EntrySelector specifies a search that is not
compatible with the sort criteria used by the FoundEntries.IntArray findAll(Handle h, EntrySelector selector, IntArray dest) throws IOException
h
- an optional handle used to monitor and possibly abort the search.selector
- an EntrySelector created using getEntrySelector().dest
- an optional destination IntArray.IOException
IntArray filterAll(Handle h, ObjectFinder finder, IntArray dest) throws IOException
h
- an optional handle used to monitor and possibly abort the search.finder
- an ObjectFinder used to select the entries.dest
- an optional destination IntArray.IOException
EventDispatcher getEventDispatcher()
long findAll(Handle h, Object search, boolean hasWildCards) throws IOException, StoppedException
h
- an optional handle used to monitor and possibly abort the search.searchData
- search data possibly used by the comparer.hasWildCards
- set this true if the search data has wildcard data (e.g. '*' characters).StoppedException
- if the provided handle is not null and stop() was called on the handle.IOException
long findAll(Handle h, EntrySelector selector) throws IOException, StoppedException
h
- an optional handle used to monitor and possibly abort the search.selector
- an EntrySelector created using getEntrySelector().IOException
- on an I/O Error.StoppedException
- if the provided handle is not null and stop() was called on the handle.long findAll(Handle h, Object searchData, Comparer comparer) throws IOException, StoppedException
During the search the comparer will have its compare() method called with the searchData parameter object as the first parameter and a DatabaseEntry object as the second parameter. The comparer should return
<0 if the DatabaseEntry is considered greater than the search data. 0 if the DatabaseEntry is considered to match the search data. >0 if the DatabaseEntry is considered less than the search data.The Comparer should NOT take into account if the SORT_DESCENDING option is set - that will be taken care of by the search routine.
h
- an optional handle used to monitor and possibly abort the process.searchData
- search data possibly used by the comparer.comparer
- a comparer to compare the search data with the data in records of the FoundEntries.IOException
- on an I/O Error.StoppedException
- if the provided handle is not null and stop() was called on the handle.