|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.db.AbstractDBClassStore<T>
com.antelmann.db.EnumDBStore<T>
public class EnumDBStore<T extends Enum<?> & DBEntry>
allows any Enum that also implements DBEntry to be made available via DBClassStore.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.antelmann.db.DBClassStore |
|---|
DBClassStore.DBMethod |
| Constructor Summary | |
|---|---|
EnumDBStore(Database<?> db,
Class<T> type)
|
|
| Method Summary | |
|---|---|
boolean |
deleteEntry(Object id)
removes the entry with the given ID from this store in the database. |
DBEnumeration<T> |
fetch(Filter<? super T> filter)
allows to retrieve the entries of this storage via iteration. |
Object |
generateNewID()
this method is to generate unique new IDs for the DBEntry at hand - if the application has no other specific way of providing new IDs for this implementation. |
void |
insert(T entry)
it is suggested to create the entry with an ID obtained through generateNewID() before passing it into
this method. |
Object |
insertAsNew(T entry)
inserts the given entry using an ID generated by generateNewID
while ignoring the ID of the given entry. |
void |
update(T entry)
updates the given entry in the database. |
| Methods inherited from class com.antelmann.db.AbstractDBClassStore |
|---|
containsID, deleteEntries, fetchStubs, getDatabase, getEntry, getEntryClass, getStub, size |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EnumDBStore(Database<?> db,
Class<T> type)
| Method Detail |
|---|
public boolean deleteEntry(Object id)
throws DatabaseException
DBClassStore
DatabaseException
public void insert(T entry)
throws DatabaseException
DBClassStoregenerateNewID() before passing it into
this method.
The ID of the entry must not already exist in the database.
DatabaseExceptionDBClassStore.generateNewID()
public Object generateNewID()
throws DatabaseException,
UnsupportedOperationException
DBClassStore
DatabaseException
UnsupportedOperationExceptionSessionIdGenerator,
DBEntry.getID()
public Object insertAsNew(T entry)
throws DatabaseException,
UnsupportedOperationException
DBClassStoregenerateNewID
while ignoring the ID of the given entry.
With this method, the same Object (with the same ID) can be inserted
multiple times, stored with a new ID on each call; the ID creation is handled
automatically.
This is an optional feature that might not be implemented in all cases.
DatabaseException
UnsupportedOperationExceptionDBEntry.getID(),
DBClassStore.generateNewID()
public void update(T entry)
throws DatabaseException
DBClassStore
DatabaseException - if the database was not able to perform the update
or it the entry didn't exist in the database before calling this method
public DBEnumeration<T> fetch(Filter<? super T> filter)
throws DatabaseException
DBClassStoreAs all relevant entries may not completely fit into memory, an Enumeration is returned instead of a list. To directly get all entries as a list (and thus avoid concurrency problems), consider using methods from AbstractIterator to quickly retrieve all resources before processing them.
Be aware that the result of the enumeration may become undefined if data is inserted/deleted/updated while the elements are accessed. To guarantee consistency, all access to the returned Enumeration must be externally synchronized by holding the monitor of the database transaction throughout maintaining the Enumeration.
Note that you may have IterationExceptions being thrown on calling methods on the returned Enumeration, which are caused by either DatabaseExceptions or InstantiationExceptions on trying to fetch the next element, as not all possible errors may be caught on calling this method (as it possibly cannot instantiate all entries in advance).
All access to the returned Enumeration must be made within an active transaction.
As the returned Enumeration may hold resources to the database while iterating, the caller must ensure that these resources can be properly release. This is usually achieved by simply completely iterating through the return value, in which case the DBEnumeration is expected to properly clean up automatically. But in cases where the caller doesn't intend to go all the way through the Enumeration, the caller has to clean up explicitly, which can be done by calling the close() method on the returned DBEnumeration.
filter - may be null, in which case all entries from are returned.
DatabaseExceptionAbstractIterator.list(java.util.Enumeration),
IterationException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||