wt.epm.util
Class EPMCache.ObjectCache

java.lang.Object
  extended bywt.epm.util.EPMCache.ObjectCache
Enclosing class:
EPMCache

public static class EPMCache.ObjectCache
extends Object

An Object Cache holds Persistable objects and indexes them by their object identifiers. Given an object identifier, it returns the object with that identifier. If an object is not in its cache, the Object Cache will query it from the database and add it to its cache.


Field Summary
private  HashMap cache
           
 
Constructor Summary
EPMCache.ObjectCache()
          Constructs an ObjectCache.
EPMCache.ObjectCache(Collection objects)
          Constructs an ObjectCache adding the collection of Persistable objects to its cache.
 
Method Summary
 void add(Collection objects)
          Adds a collection of Persistable objects to the Object Cache.
 void add(Persistable object)
          Adds a Persistable object to the Object Cache.
 boolean contains(ObjectIdentifier objectId)
          Returns true if the cache contains the Persistable object with the given object identifier.
 boolean contains(Persistable object)
          Returns true if the cache contains the given Persistable object.
 List find(Collection objectIds)
          Given a collection of object identifiers, returns the Persistable objects with these identifiers.
 Persistable get(ObjectIdentifier objectId)
          Given an object identifier, returns the object with that identifier provided it is in the cache.
 boolean isEmpty()
          Returns true if the cache contains no objects.
 Collection objects()
          Returns an unmodifiable collection view of the objects in this cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

private HashMap cache
Constructor Detail

EPMCache.ObjectCache

public EPMCache.ObjectCache()
Constructs an ObjectCache.


EPMCache.ObjectCache

public EPMCache.ObjectCache(Collection objects)
Constructs an ObjectCache adding the collection of Persistable objects to its cache.

Method Detail

get

public Persistable get(ObjectIdentifier objectId)
Given an object identifier, returns the object with that identifier provided it is in the cache. If it is not, this method returns null.


add

public void add(Persistable object)
Adds a Persistable object to the Object Cache.


add

public void add(Collection objects)
Adds a collection of Persistable objects to the Object Cache.


find

public List find(Collection objectIds)
          throws WTException
Given a collection of object identifiers, returns the Persistable objects with these identifiers. If an object is not in its cache, the Object Cache will query it from the database and add it to its cache.

Throws:
WTException

objects

public Collection objects()
Returns an unmodifiable collection view of the objects in this cache.


isEmpty

public boolean isEmpty()
Returns true if the cache contains no objects.


contains

public boolean contains(Persistable object)
Returns true if the cache contains the given Persistable object.


contains

public boolean contains(ObjectIdentifier objectId)
Returns true if the cache contains the Persistable object with the given object identifier.