|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.appworx.AppDbObjectCacheIndex<T,C>
T - the AppDbObject classC - the Comparable classpublic abstract class AppDbObjectCacheIndex<T extends AppDbObject,C extends Comparable<? super C>>
Cache index.
Holds the mapping of keys to objects.
| Constructor Summary | |
|---|---|
AppDbObjectCacheIndex(String name)
Create a new index. |
|
| Method Summary | |
|---|---|
protected boolean |
add(T object)
add an object to the index. |
protected void |
addUnique(T object)
add an unique object to the index. |
protected void |
clear()
clear contents of the cache index. |
protected void |
clearCacheStats()
Clears the cache statistics. |
abstract C |
extract(T object)
Extract the Comparable that uniquely identifies the object from that object. |
protected T |
get(ContextDb db,
C key)
get object from cache by key. |
protected List<T> |
getObjects()
get all objects from cache index |
protected List<T> |
getObjects(ContextDb db,
C fromKey,
C toKey)
get a subset of objects |
protected String |
printCacheStats()
Gets the cache index statistics as a printable string. |
protected boolean |
remove(T object)
remove object from cache. |
protected void |
removeExisting(T object)
remove object from cache. |
abstract T |
select(ContextDb db,
C key)
Select an AppDbObject by key from db. |
protected int |
size()
Gets the number of objects in this index. |
String |
toString()
Returns a string representation of the object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AppDbObjectCacheIndex(String name)
name - is the symbolic name of the index (for diagnostics only).| Method Detail |
|---|
public abstract T select(ContextDb db,
C key)
db - is the contextDb to select the object fromkey - is the Comparable used to uniquely identify the object (can be null)
public abstract C extract(T object)
object - is the object to extract the key from (never null)
public String toString()
java.lang.ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString in class Objectprotected void clear()
protected int size()
protected String printCacheStats()
protected void clearCacheStats()
protected T get(ContextDb db,
C key)
throws ApplicationException
db - is the contextdbkey - is the Comparable that uniquely identifies the object
ApplicationException - if the objects key has been changed by application
protected List<T> getObjects()
throws ApplicationException
ApplicationException - if a key of one of the objects has been changed by application
protected List<T> getObjects(ContextDb db,
C fromKey,
C toKey)
throws ApplicationException
db - is the contextDbfromKey - is the start of range (including)toKey - is the end of range (exluding)
ApplicationException - if a key of one of the objects has been changed by applicationprotected boolean add(T object)
object - is the object to append (never null)
protected void addUnique(T object)
throws ApplicationException
object - is the object to append (never null)
ApplicationException - if unique violationprotected boolean remove(T object)
object - the object to remove (never null)
protected void removeExisting(T object)
throws ApplicationException
object - the object to remove (never null)
ApplicationException - if not in cache
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||