|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.util.Country.Store
public static class Country.Store
provides a convenient read-only store for all existing Country objects without having to hold them all in memory constantly
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.antelmann.db.DBClassStore |
|---|
DBClassStore.DBMethod |
| Constructor Summary | |
|---|---|
Country.Store(Database<?> db)
|
|
| Method Summary | |
|---|---|
boolean |
containsID(Object id)
determines whether the given ID is present in this store. |
int |
deleteEntries(Filter<? super Country> filter)
deletes all DBEntry objects that match the given filter; if the filter is null, all resources are deleted. |
boolean |
deleteEntry(Object id)
removes the entry with the given ID from this store in the database. |
DBEnumeration<Country> |
fetch(Filter<? super Country> filter)
allows to retrieve the entries of this storage via iteration. |
DBEnumeration<Stub<Country>> |
fetchStubs(Filter<? super Stub<?>> filter)
allows to access objects from this store w/o having to instantiate the entire original objects, but instead use Stubs to be able to display the list properly for selection. |
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. |
Database<?> |
getDatabase()
provides access to the database instance that also coordinates the transaction management. |
Country |
getEntry(Object id)
returns the DBEntry based on its ID. |
Class<Country> |
getEntryClass()
returns the runtime class type this store represents |
Stub<Country> |
getStub(Object id)
returns a Stub representing the resource for the given ID or null. |
void |
insert(Country entry)
it is suggested to create the entry with an ID obtained through generateNewID() before passing it into
this method. |
Object |
insertAsNew(Country entry)
inserts the given entry using an ID generated by generateNewID
while ignoring the ID of the given entry. |
int |
size(Filter<? super Country> filter)
returns the total number of T elements in this store based on the given filter (which may be null) |
void |
update(Country entry)
updates the given entry in the database. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Country.Store(Database<?> db)
| Method Detail |
|---|
public boolean containsID(Object id)
throws DatabaseException
DBClassStore
containsID in interface DBClassStore<Country>DatabaseException
public int deleteEntries(Filter<? super Country> filter)
throws DatabaseException
DBClassStoreDBClassStore.deleteEntry(Object)
is called for each entry passing the filter (although stores may choose to do so)!
Consequently, if a store's implementation does not call DBClassStore.deleteEntry(Object)
on each instance, calling this method may result in changes that are hard to monitor
for versioning purposes.
deleteEntries in interface DBClassStore<Country>DatabaseExceptionDBClassStore.deleteEntry(Object)
public boolean deleteEntry(Object id)
throws DatabaseException
DBClassStore
deleteEntry in interface DBClassStore<Country>DatabaseException
public DBEnumeration<Country> fetch(Filter<? super Country> 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.
fetch in interface DBClassStore<Country>filter - may be null, in which case all entries from are returned.
DatabaseExceptionAbstractIterator.list(java.util.Enumeration),
IterationException
public DBEnumeration<Stub<Country>> fetchStubs(Filter<? super Stub<?>> filter)
throws DatabaseException
DBClassStorefetch(Filter) .
fetchStubs in interface DBClassStore<Country>DatabaseException
public Object generateNewID()
throws DatabaseException,
UnsupportedOperationException
DBClassStore
generateNewID in interface DBClassStore<Country>DatabaseException
UnsupportedOperationExceptionSessionIdGenerator,
DBEntry.getID()public Database<?> getDatabase()
DBClassStore
getDatabase in interface DBClassStore<Country>
public Country getEntry(Object id)
throws DatabaseException
DBClassStore
getEntry in interface DBClassStore<Country>id - the ID that is retrieved from Resource.getID()
DatabaseExceptionDBEntry.getID()public Class<Country> getEntryClass()
DBClassStore
getEntryClass in interface DBClassStore<Country>
public Stub<Country> getStub(Object id)
throws DatabaseException
DBClassStore
getStub in interface DBClassStore<Country>DatabaseException
public void insert(Country entry)
throws DatabaseException
DBClassStoregenerateNewID() before passing it into
this method.
The ID of the entry must not already exist in the database.
insert in interface DBClassStore<Country>DatabaseExceptionDBClassStore.generateNewID()
public Object insertAsNew(Country 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.
insertAsNew in interface DBClassStore<Country>DatabaseException
UnsupportedOperationExceptionDBEntry.getID(),
DBClassStore.generateNewID()
public int size(Filter<? super Country> filter)
throws DatabaseException
DBClassStore
size in interface DBClassStore<Country>filter - if non-null, only those elements will be counted that are applicable to the filter
DatabaseException
public void update(Country entry)
throws DatabaseException
DBClassStore
update in interface DBClassStore<Country>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
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||