ewe.database
Class EntrySelector

java.lang.Object
  extended byewe.database.EntrySelector

public class EntrySelector
extends Object


Field Summary
 int[] criteria
           
 Database db
           
 DatabaseEntry de
           
 boolean forceAFilterSearch
           
 boolean hasWildCards
           
 
Constructor Summary
EntrySelector(Database db, Object searchData, int[] criteria, boolean hasWildCards)
           
EntrySelector(Database db, Object primarySearchFields, int sortID, boolean hasWildCards)
           
EntrySelector(Database db, Object searchData, int sortID, int numberOfCriteria, boolean hasWildCards)
           
EntrySelector(FoundEntries fe, Object primarySearchFields, boolean hasWildCards)
           
EntrySelector(FoundEntries fe, Object searchData, int numberOfCriteria, boolean hasWildCards)
           
 
Method Summary
 boolean canSearch(FoundEntries fe)
          Return if the specified FoundEntries is sorted by a search criteria that is compatible with this EntrySelector, such that a binary-chop search is possible using this EntrySelector on the specified FoundEntries.
 boolean canSearch(int sortID)
          Return if the specified sort ID for the EntrySelector's Database is compatible with this EntrySelector, such that a binary-chop search is possible using this EntrySelector on the database.
 boolean canSearch(int[] sortCriteria)
          Return if the specified sort criteria is compatible with this EntrySelector, such that a binary-chop search is possible using this EntrySelector on the database.
 int compare(Object dataOrEntry)
           
 int decode(Database db, byte[] source, int offset, DataProcessor decryptor)
          Decode the EntrySelector for use with the specified Database.
protected  int doCompare(DatabaseEntry myData, DatabaseEntry other)
           
 ByteArray encode(ByteArray destination, DataProcessor encryptor)
          Encode and append the EntrySelector to a ByteArray.
 int[] getCriteria()
           
 Comparer toComparer()
           
 ObjectFinder toObjectFinder()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

de

public DatabaseEntry de

db

public Database db

criteria

public int[] criteria

hasWildCards

public boolean hasWildCards

forceAFilterSearch

public boolean forceAFilterSearch
Constructor Detail

EntrySelector

public EntrySelector(Database db,
                     Object primarySearchFields,
                     int sortID,
                     boolean hasWildCards)

EntrySelector

public EntrySelector(FoundEntries fe,
                     Object primarySearchFields,
                     boolean hasWildCards)

EntrySelector

public EntrySelector(FoundEntries fe,
                     Object searchData,
                     int numberOfCriteria,
                     boolean hasWildCards)

EntrySelector

public EntrySelector(Database db,
                     Object searchData,
                     int[] criteria,
                     boolean hasWildCards)

EntrySelector

public EntrySelector(Database db,
                     Object searchData,
                     int sortID,
                     int numberOfCriteria,
                     boolean hasWildCards)
              throws IllegalArgumentException
Method Detail

getCriteria

public int[] getCriteria()

encode

public ByteArray encode(ByteArray destination,
                        DataProcessor encryptor)
                 throws IOException
Encode and append the EntrySelector to a ByteArray. Override this if you are inheriting from EntrySelector.

Parameters:
destination - the destination ByteArray. If this is null a new one will be created.
encryptor - an optional encryptor for the field search data.
Returns:
the destination ByteArray or a new ByteArray.
Throws:
IOException - if there was an error encrypting the data.

decode

public int decode(Database db,
                  byte[] source,
                  int offset,
                  DataProcessor decryptor)
           throws IOException
Decode the EntrySelector for use with the specified Database. Override this if you are inheriting from EntrySelector.

Parameters:
db - The Database this comparer will be used with.
source - The encoded bytes.
offset - The offset in the array of the bytes.
decryptor - An optional decryptor to decrypt the data.
Returns:
the number of bytes read.
Throws:
IOException - if there is an error decyrpting the data.

canSearch

public boolean canSearch(FoundEntries fe)
Return if the specified FoundEntries is sorted by a search criteria that is compatible with this EntrySelector, such that a binary-chop search is possible using this EntrySelector on the specified FoundEntries. If forceAFilterSearch is true, this will always return false.


canSearch

public boolean canSearch(int[] sortCriteria)
Return if the specified sort criteria is compatible with this EntrySelector, such that a binary-chop search is possible using this EntrySelector on the database. If forceAFilterSearch is true, this will always return false.


canSearch

public boolean canSearch(int sortID)
                  throws IllegalArgumentException
Return if the specified sort ID for the EntrySelector's Database is compatible with this EntrySelector, such that a binary-chop search is possible using this EntrySelector on the database. If forceAFilterSearch is true, this will always return false.

Throws:
IllegalArgumentException

doCompare

protected int doCompare(DatabaseEntry myData,
                        DatabaseEntry other)

compare

public int compare(Object dataOrEntry)
            throws IllegalArgumentException
Throws:
IllegalArgumentException

toObjectFinder

public ObjectFinder toObjectFinder()

toComparer

public Comparer toComparer()