Holger's
Java API

com.antelmann.db
Class AbstractDBClassStore<T extends DBEntry>

java.lang.Object
  extended by com.antelmann.db.AbstractDBClassStore<T>
All Implemented Interfaces:
DBClassStore<T>, TransactionRequired
Direct Known Subclasses:
EnumDBStore

public abstract class AbstractDBClassStore<T extends DBEntry>
extends Object
implements DBClassStore<T>

provides basic implementation of methods that can be implemented based on other methods of the interface - though these implementations may be very inefficient

Since:
12.12.2013, 22:30:06
Author:
holger

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.antelmann.db.DBClassStore
DBClassStore.DBMethod
 
Constructor Summary
AbstractDBClassStore(Database<?> db, Class<T> type)
           
 
Method Summary
 boolean containsID(Object id)
          determines whether the given ID is present in this store.
 int deleteEntries(Filter<? super T> filter)
          deletes all DBEntry objects that match the given filter; if the filter is null, all resources are deleted.
 DBEnumeration<Stub<T>> 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.
 Database<?> getDatabase()
          provides access to the database instance that also coordinates the transaction management.
 T getEntry(Object id)
          returns the DBEntry based on its ID.
 Class<T> getEntryClass()
          returns the runtime class type this store represents
 Stub<T> getStub(Object id)
          returns a Stub representing the resource for the given ID or null.
 int size(Filter<? super T> filter)
          returns the total number of T elements in this store based on the given filter (which may be null)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.antelmann.db.DBClassStore
deleteEntry, fetch, generateNewID, insert, insertAsNew, update
 

Constructor Detail

AbstractDBClassStore

public AbstractDBClassStore(Database<?> db,
                            Class<T> type)
Method Detail

getDatabase

public Database<?> getDatabase()
Description copied from interface: DBClassStore
provides access to the database instance that also coordinates the transaction management.

Specified by:
getDatabase in interface DBClassStore<T extends DBEntry>

getEntryClass

public Class<T> getEntryClass()
Description copied from interface: DBClassStore
returns the runtime class type this store represents

Specified by:
getEntryClass in interface DBClassStore<T extends DBEntry>

containsID

public boolean containsID(Object id)
                   throws DatabaseException
Description copied from interface: DBClassStore
determines whether the given ID is present in this store.

Specified by:
containsID in interface DBClassStore<T extends DBEntry>
Throws:
DatabaseException

deleteEntries

public int deleteEntries(Filter<? super T> filter)
                  throws DatabaseException
Description copied from interface: DBClassStore
deletes all DBEntry objects that match the given filter; if the filter is null, all resources are deleted. Calling this method does not necessarily entail that DBClassStore.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.

Specified by:
deleteEntries in interface DBClassStore<T extends DBEntry>
Returns:
the number of objects that were deleted
Throws:
DatabaseException
See Also:
DBClassStore.deleteEntry(Object)

getEntry

public T getEntry(Object id)
                           throws DatabaseException
Description copied from interface: DBClassStore
returns the DBEntry based on its ID.

Specified by:
getEntry in interface DBClassStore<T extends DBEntry>
Parameters:
id - the ID that is retrieved from Resource.getID()
Returns:
the associated DBEntry or null if the id is unknown
Throws:
DatabaseException
See Also:
DBEntry.getID()

fetchStubs

public DBEnumeration<Stub<T>> fetchStubs(Filter<? super Stub<?>> filter)
                                                  throws DatabaseException
Description copied from interface: DBClassStore
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. The given filter may be null. Other than that, the same transactional implications apply as for fetch(Filter).

Specified by:
fetchStubs in interface DBClassStore<T extends DBEntry>
Throws:
DatabaseException

getStub

public Stub<T> getStub(Object id)
                                throws DatabaseException
Description copied from interface: DBClassStore
returns a Stub representing the resource for the given ID or null. This method allows to display the object w/o having to retrieve the full DBEntry.

Specified by:
getStub in interface DBClassStore<T extends DBEntry>
Throws:
DatabaseException

size

public int size(Filter<? super T> filter)
         throws DatabaseException
Description copied from interface: DBClassStore
returns the total number of T elements in this store based on the given filter (which may be null)

Specified by:
size in interface DBClassStore<T extends DBEntry>
Parameters:
filter - if non-null, only those elements will be counted that are applicable to the filter
Throws:
DatabaseException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads