ewe.database
Class LookupData

java.lang.Object
  extended byewe.data.DataObject
      extended byewe.database.LookupData
All Implemented Interfaces:
Comparable, Copyable, DataUnit

public class LookupData
extends DataObject


Field Summary
protected  EntriesView view
          This is the view into the Database created by getLookup().
 
Constructor Summary
LookupData()
           
 
Method Summary
 void closeLookup()
          Close the lookup database.
 LookupData getLookup(Database openDatabase, String sortName)
          Get a LookupData which can be used to lookup values based on the specified sort.
 LookupData getLookup(File databaseFile, String sortName)
          Get a LookupData which can be used to lookup values based on the specified sort.
 EntriesView getLookupView()
          Return the view used to lookup data in the database.
 Vector lookup(Handle h, Object[] searches, boolean hasWildcards)
          This looks up for all records which match the search criteria.
 Vector lookup(Handle h, ObjectFinder filter)
          This looks up for all records which match the search criteria.
 Vector lookup(Object[] searches, boolean hasWildcards)
          This looks up for all records which match the search criteria.
 Vector lookup(Object search, boolean hasWildcards)
          This looks up for all records which match the search criteria.
 Vector lookup(ObjectFinder filter)
          This looks up for all records which match the search criteria.
 LookupData lookupOne(Object[] search, boolean hasWildcards)
          This looks up for one record which matches the search criteria.
 LookupData lookupOne(Object search, boolean hasWildcards)
          This looks up for one record which matches the search criteria.
 LookupData lookupOne(ObjectFinder filter)
          This looks up for all records which match the search criteria and returns the first match.
 Database openDatabase(File databaseFile, String mode)
          This is used to open the specified database.
 
Methods inherited from class ewe.data.DataObject
_getSetField, appendAllFields, compareTo, copied, copyFrom, equals, getCopy, getDeclaredField, getDeclaredFieldValue, getDeclaredFieldValue, getFieldList, getFieldList, getMyFieldList, getNew
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, toString
 

Field Detail

view

protected EntriesView view
This is the view into the Database created by getLookup().

Constructor Detail

LookupData

public LookupData()
Method Detail

getLookupView

public EntriesView getLookupView()
Return the view used to lookup data in the database. This should only be called on an object returned by one of the getLookup() values. If you are using this to do any lookups yourself, you should call openLookup() on the view before looking up data and then call closeLookup() afterwards.

Returns:
the view used to lookup data in the database.

openDatabase

public Database openDatabase(File databaseFile,
                             String mode)
                      throws IOException
This is used to open the specified database. By default it uses a default DatabaseManager as returned by DatabaseManager.getDefaultDatabaseMaker(), but you can override this to open the Database in another way. This method is called by the getLookup() method - which opens the database in read-only mode.

Parameters:
databaseFile - the File to open.
mode - the mode - either "r" or "rw".
Returns:
an open database.
Throws:
IOException - if an error occurs.

getLookup

public LookupData getLookup(File databaseFile,
                            String sortName)
                     throws IOException
Get a LookupData which can be used to lookup values based on the specified sort.

Parameters:
databaseFile - the databaseFile to open (in read-only mode).
sortName - an optional sort name. If null then the first stored sort is used.
Returns:
a LookupData object that can be used to lookup values based on the specified sort.
Throws:
IOException - if an error occurs.

getLookup

public LookupData getLookup(Database openDatabase,
                            String sortName)
                     throws IOException
Get a LookupData which can be used to lookup values based on the specified sort.

Parameters:
openDatabase - the open database to lookup in.
sortName - an optional sort name. If null then the first stored sort is used.
Returns:
a LookupData object that can be used to lookup values based on the specified sort.
Throws:
IOException - if an error occurs.

lookup

public Vector lookup(Handle h,
                     Object[] searches,
                     boolean hasWildcards)
              throws IOException
This looks up for all records which match the search criteria. Only call this on an object returned by getLookup().

Parameters:
h - an optional Handle that can be used to monitor or stop the search.
searches - the fields to search for.
hasWildcards - true if the fields contain wildcard characters.
Returns:
a Vector of LookupData objects which contain the data from the matching records or null if the search was aborted through the Handle h.
Throws:
IOException - if an error occurs.

lookup

public Vector lookup(Handle h,
                     ObjectFinder filter)
              throws IOException
This looks up for all records which match the search criteria. Only call this on an object returned by getLookup().

Parameters:
h - an optional Handle that can be used to monitor or stop the search.
filter - an ObjectFinder that will filter each database record.
Returns:
a Vector of LookupData objects which contain the data from the matching records or null if the search was aborted through the Handle h.
Throws:
IOException - if an error occurs.

lookup

public Vector lookup(Object[] searches,
                     boolean hasWildcards)
              throws IOException
This looks up for all records which match the search criteria. Only call this on an object returned by getLookup().

Parameters:
searches - the fields to search for.
hasWildcards - true if the fields contain wildcard characters.
Returns:
a Vector of LookupData objects which contain the data from the matching records.
Throws:
IOException - if an error occurs.

lookup

public Vector lookup(Object search,
                     boolean hasWildcards)
              throws IOException
This looks up for all records which match the search criteria. Only call this on an object returned by getLookup().

Parameters:
search - one field to search for.
hasWildcards - true if the field contain wildcard characters.
Returns:
a Vector of LookupData objects which contain the data from the matching records.
Throws:
IOException - if an error occurs.

lookupOne

public LookupData lookupOne(Object[] search,
                            boolean hasWildcards)
                     throws IOException
This looks up for one record which matches the search criteria. Only call this on an object returned by getLookup().

Parameters:
hasWildcards - true if the fields contain wildcard characters.
Returns:
one LookupData object which contain the first matching data from the matching records or null if none match.
Throws:
IOException - if an error occurs.

lookupOne

public LookupData lookupOne(Object search,
                            boolean hasWildcards)
                     throws IOException
This looks up for one record which matches the search criteria. Only call this on an object returned by getLookup().

Parameters:
search - one field to search for.
hasWildcards - true if the field contain wildcard characters.
Returns:
one LookupData object which contain the first matching data from the matching records or null if none match.
Throws:
IOException - if an error occurs.

lookup

public Vector lookup(ObjectFinder filter)
              throws IOException
This looks up for all records which match the search criteria. Only call this on an object returned by getLookup().

Parameters:
filter - an ObjectFinder that will filter each database record.
Returns:
a Vector of LookupData objects which contain the data from the matching records.
Throws:
IOException - if an error occurs.

lookupOne

public LookupData lookupOne(ObjectFinder filter)
                     throws IOException
This looks up for all records which match the search criteria and returns the first match. Only call this on an object returned by getLookup().

Parameters:
filter - an ObjectFinder that will filter each database record.
Returns:
one LookupData object which contain the first matching data from the matching records or null if none match.
Throws:
IOException - if an error occurs.

closeLookup

public void closeLookup()
                 throws IOException
Close the lookup database.

Throws:
IOException - on IO error.