wt.epm.util
Class EPMCache.VersionCache

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

public static class EPMCache.VersionCache
extends Object

A Version Cache holds Iterated objects and indexes them using version keys. Given a version key it returns the object with the same branch identifier. If an object is not in its cache, the Version Cache will query it from the database and add it to its cache.


Field Summary
private  HashMap cache
           
 
Constructor Summary
EPMCache.VersionCache()
          Constructs a VersionCache.
EPMCache.VersionCache(Collection objects)
          Constructs a VersionCache adding the collection of Iterated objects to its cache.
 
Method Summary
 void add(Collection objects)
          Adds a collection of Iterated objects to the Version Cache.
 void add(Iterated object)
          Adds an Iterated object to the Version Cache.
 boolean contains(Iterated object)
          Returns true if the cache contains the given Iterated object.
 boolean contains(VersionForeignKey versionKey)
          Returns true if the cache contains the Iterated object with the given version key.
 List find(Collection versionKeys)
          Given a collection of version keys, returns the Iterated objects with the same branch identifiers.
private  List findObjects(Collection versionKeys)
          Given a collection of version keys, retrieves the Iterated objects with the same branch identifiers from the database.
 Iterated get(VersionForeignKey versionKey)
          Given an version key, returns the object with the same branch identifier provided the object is in the cache.
 boolean isEmpty()
          Returns true if this 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.VersionCache

public EPMCache.VersionCache()
Constructs a VersionCache.


EPMCache.VersionCache

public EPMCache.VersionCache(Collection objects)
                      throws WTException
Constructs a VersionCache adding the collection of Iterated objects to its cache.

Method Detail

get

public Iterated get(VersionForeignKey versionKey)
Given an version key, returns the object with the same branch identifier provided the object is in the cache. If it is not, this method returns null.


add

public void add(Iterated object)
         throws WTException
Adds an Iterated object to the Version Cache.

Throws:
WTException

add

public void add(Collection objects)
         throws WTException
Adds a collection of Iterated objects to the Version Cache.

Throws:
WTException

find

public List find(Collection versionKeys)
          throws WTException
Given a collection of version keys, returns the Iterated objects with the same branch identifiers. If an object is not in its cache, the Version 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 this cache contains no objects.


contains

public boolean contains(Iterated object)
                 throws WTException
Returns true if the cache contains the given Iterated object.

Throws:
WTException

contains

public boolean contains(VersionForeignKey versionKey)
Returns true if the cache contains the Iterated object with the given version key.


findObjects

private List findObjects(Collection versionKeys)
                  throws WTException
Given a collection of version keys, retrieves the Iterated objects with the same branch identifiers from the database.

Throws:
WTException