org.formaria.cache
Class Cache

java.lang.Object
  extended by org.formaria.cache.Cache

public class Cache
extends java.lang.Object

A cache of objects For licensing information see license.txt


Constructor Summary
Cache()
           
 
Method Summary
 java.lang.Object get(java.lang.Class cls, java.lang.Object id)
          Get a cache object.
 java.lang.Object getByName(java.lang.String name, java.lang.Object id)
          Lookup by the class's simple name (case insensitive)
 ObjectAccessService getRemoteService()
           
protected  boolean isValid(CachedObject co)
           
 void put(java.lang.Object o)
           
 void putList(java.util.List<?> l)
           
 void putList(java.lang.Object[] l)
           
 void putTree(CachedObject<?> parent, java.util.List<?> treeItems)
           
protected  CachedObject read(java.lang.Class cls, java.lang.Object id)
           
 void remove(java.lang.Class cls, java.lang.Object id)
           
 void remove(java.lang.Object obj)
           
 void setRemoteService(ObjectAccessService roas)
           
protected  void write(CachedObject co)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cache

public Cache()
Method Detail

put

public void put(java.lang.Object o)

putList

public void putList(java.util.List<?> l)

putList

public void putList(java.lang.Object[] l)

putTree

public void putTree(CachedObject<?> parent,
                    java.util.List<?> treeItems)

getByName

public java.lang.Object getByName(java.lang.String name,
                                  java.lang.Object id)
Lookup by the class's simple name (case insensitive)

Parameters:
name - the simple name
id - the object id if any
Returns:
the raw object(s)

get

public java.lang.Object get(java.lang.Class cls,
                            java.lang.Object id)
Get a cache object. For lists a shared index list is used so that while a new list is returned for each invocation the index remains the same. In this way the contents of the cache can be updated and augmented without disturbing the client.

Parameters:
cls - the cached object class
id - the object id
Returns:

remove

public void remove(java.lang.Class cls,
                   java.lang.Object id)

remove

public void remove(java.lang.Object obj)

isValid

protected boolean isValid(CachedObject co)

read

protected CachedObject read(java.lang.Class cls,
                            java.lang.Object id)

write

protected void write(CachedObject co)

getRemoteService

public ObjectAccessService getRemoteService()

setRemoteService

public void setRemoteService(ObjectAccessService roas)