|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.martiansoftware.trivialpersist.Table
A collection of records that share a schema. Analogous to a table in a relational database.
Method Summary | |
Iterator |
comparatorNames()
Returns an Iterator over all comparator names available |
Record |
create()
Creates a new, writeable Record in this Table. |
Record |
createCopy(Record record)
Creates a new, writeable Record in this Table with all fields (except its Key) copied from the specified Record. |
void |
declareField(String fieldName,
String fieldType)
Declares a field (name and type) for this Table |
Iterator |
filterNames()
Returns an Iterator over all filter names available |
Record |
getByKey(martianutils.io.MaildirID key)
Returns the record associated with the specified Key, or null if no such record exists. |
Comparator |
getComparator(String comparatorName)
Returns the requested comparator. |
RecordFilter |
getFilter(String filterName)
Returns the requested RecordFilter, or null if no such filter is defined. |
String |
getName()
Returns the name of this Table |
void |
init(File schemaFile)
Initializes the table with the schema contained within the specified file |
SortedSet |
select(RecordFilter recordFilter,
Comparator comparator)
Returns a SortedSet of Records that pass the specified RecordFilter, sorted by the specified Comparator. |
SortedSet |
select(String filterName,
String comparatorName)
|
SortedSet |
selectAll()
Returns a set of all records, sorted by key. |
void |
setRecordInitializer(RecordInitializer recordInitializer)
Sets the RecordInitializer for this Table. |
int |
size()
Returns the number of Records in this Table |
void |
storeComparator(String comparatorName,
Comparator comparator)
Stores a comparator by name |
void |
storeFilter(String filterName,
RecordFilter filter)
Stores a filter by name |
String |
toString()
Returns a String representatino of this Table. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public String getName()
public void init(File schemaFile) throws TrivialPersistException
schemaFile
- the file containing the schema
TrivialPersistException
public void declareField(String fieldName, String fieldType) throws TrivialPersistException
fieldName
- the name of the field to declarefieldType
- the data type of the field
TrivialPersistException
- if the declaration fails for
any reason (e.g., duplicate fieldname, invalid type, etc.)public int size()
public SortedSet selectAll()
public SortedSet select(String filterName, String comparatorName)
public SortedSet select(RecordFilter recordFilter, Comparator comparator)
recordFilter
- the filter to use in selecting Records. If null,
all Records will be included in the result.comparator
- the Comparator to use in sorting Records. If null,
Records will be sorted according to their keys.
public Record create() throws TrivialPersistException
TrivialPersistException
- if the Record could not be createdpublic Record createCopy(Record record) throws TrivialPersistException
save()
d before it will be
returned by any queries against this Table.
If this Table has a RecordInitializer set, it will not be run on the new copy.
record
- the Record to copy
TrivialPersistException
- if the record could not be copiedpublic Record getByKey(martianutils.io.MaildirID key)
key
- the Key to use for the lookup.
public String toString()
public void setRecordInitializer(RecordInitializer recordInitializer)
recordInitializer
- the RecordInitializer to use. If null, no
RecordInitializer will be used.public void storeFilter(String filterName, RecordFilter filter)
filterName
- the name to give the filterfilter
- the filter to storepublic Iterator filterNames()
public RecordFilter getFilter(String filterName)
filterName
- the name of the filter to retrieve
public void storeComparator(String comparatorName, Comparator comparator)
comparatorName
- the name to give the comparatorcomparator
- the comparator to storepublic Iterator comparatorNames()
public Comparator getComparator(String comparatorName)
comparatorName
- the name of the comparator to retrieve
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |