uk.ac.ic.doc.automed.util.cache
Class ObjectCache

java.lang.Object
  extended by uk.ac.ic.doc.automed.util.cache.ObjectCache

public class ObjectCache
extends java.lang.Object

Author:
dmle

Field Summary
protected static java.util.Map cacheMap
           
private static int counter
           
private static boolean debug
           
private static boolean debugDetailed
           
protected static ObjectCache instance
           
static java.lang.Integer MODE_DATA
           
private static java.lang.Integer MODE_DEFAULT
           
static java.lang.Integer MODE_MAPPING
           
static java.lang.Integer MODE_OBJECT
           
static java.lang.Integer MODE_RANGE
           
static java.lang.Integer STATE_CACHE
           
static java.lang.Integer STATE_CACHENEW
           
private static java.lang.Integer STATE_DEFAULT
           
static java.lang.Integer STATE_NOCACHE
           
static java.lang.Integer STATE_READ
           
static java.lang.Integer STATE_WRITE
           
static java.lang.Integer STATE_WRITENEW
           
private  java.util.Map stateM
           
private  java.util.Map storeM
           
private static long TTL
           
 
Constructor Summary
private ObjectCache()
           
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
          Check for default mode
private  StorageHandler getDefaultHandler()
           
static ObjectCache getInstance()
          Return the default cache instance
static ObjectCache getInstance(java.lang.String name)
          Return a new cache instance identified by name
private  StorageHandler getModeHandler(java.lang.Integer mode)
           
static java.lang.Integer getModeRandom()
           
 boolean isCacheMapping()
           
 boolean isCacheOn(java.lang.Integer mode)
          Returns true if some sort of caching is on, otherwise returns false
 boolean isReadOn(java.lang.Integer mode)
           
 boolean isWriteOn(java.lang.Integer mode)
           
 java.lang.Object read(java.lang.Integer mode, java.lang.Object key, java.lang.Object args)
           
 java.lang.Object read(java.lang.Object key, java.lang.Object args)
           
 java.util.Collection readKeys(java.lang.Integer mode)
          Retrieve all cache keys of a specific mode
 java.lang.Object remove(java.lang.Integer mode, java.lang.Object key)
           
 java.lang.Object remove(java.lang.Object key)
           
 void removeAll(java.lang.Integer mode, java.lang.Object key)
           
 java.lang.Integer setCache(java.lang.Integer state)
          Set cache for default mode
 void setMode(java.lang.Integer mode, java.lang.Integer state)
          Change the caching state of a mode
 void setMode(java.lang.Integer mode, java.lang.Integer state, java.lang.Object handler)
          Turn on caching of a mode
 void write(java.lang.Integer mode, java.lang.Object key, java.lang.Object value)
           
 void write(java.lang.Object key, java.lang.Object value)
          Cache object for the default mode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_MAPPING

public static final java.lang.Integer MODE_MAPPING

MODE_RANGE

public static final java.lang.Integer MODE_RANGE

MODE_OBJECT

public static final java.lang.Integer MODE_OBJECT

MODE_DATA

public static final java.lang.Integer MODE_DATA

counter

private static int counter

MODE_DEFAULT

private static final java.lang.Integer MODE_DEFAULT

storeM

private java.util.Map storeM

stateM

private java.util.Map stateM

STATE_NOCACHE

public static final java.lang.Integer STATE_NOCACHE

STATE_WRITE

public static final java.lang.Integer STATE_WRITE

STATE_WRITENEW

public static final java.lang.Integer STATE_WRITENEW

STATE_READ

public static final java.lang.Integer STATE_READ

STATE_CACHE

public static final java.lang.Integer STATE_CACHE

STATE_CACHENEW

public static final java.lang.Integer STATE_CACHENEW

STATE_DEFAULT

private static final java.lang.Integer STATE_DEFAULT

TTL

private static final long TTL
See Also:
Constant Field Values

debug

private static final boolean debug

debugDetailed

private static final boolean debugDetailed

instance

protected static ObjectCache instance

cacheMap

protected static java.util.Map cacheMap
Constructor Detail

ObjectCache

private ObjectCache()
Method Detail

getModeRandom

public static java.lang.Integer getModeRandom()

getInstance

public static ObjectCache getInstance()
Return the default cache instance

Returns:

getInstance

public static ObjectCache getInstance(java.lang.String name)
Return a new cache instance identified by name

Parameters:
name -
Returns:

setMode

public void setMode(java.lang.Integer mode,
                    java.lang.Integer state,
                    java.lang.Object handler)
Turn on caching of a mode


setMode

public void setMode(java.lang.Integer mode,
                    java.lang.Integer state)
Change the caching state of a mode

Parameters:
mode -
state -

getModeHandler

private StorageHandler getModeHandler(java.lang.Integer mode)

containsKey

public boolean containsKey(java.lang.Object key)
Check for default mode

Parameters:
key -
Returns:

setCache

public java.lang.Integer setCache(java.lang.Integer state)
Set cache for default mode

Parameters:
cacheOn -
Returns:

write

public void write(java.lang.Object key,
                  java.lang.Object value)
Cache object for the default mode

Parameters:
key -
value -

write

public void write(java.lang.Integer mode,
                  java.lang.Object key,
                  java.lang.Object value)

read

public java.lang.Object read(java.lang.Object key,
                             java.lang.Object args)

read

public java.lang.Object read(java.lang.Integer mode,
                             java.lang.Object key,
                             java.lang.Object args)

readKeys

public java.util.Collection readKeys(java.lang.Integer mode)
Retrieve all cache keys of a specific mode

Returns:

removeAll

public void removeAll(java.lang.Integer mode,
                      java.lang.Object key)

remove

public java.lang.Object remove(java.lang.Integer mode,
                               java.lang.Object key)

remove

public java.lang.Object remove(java.lang.Object key)

isCacheOn

public boolean isCacheOn(java.lang.Integer mode)
Returns true if some sort of caching is on, otherwise returns false

Returns:

isCacheMapping

public boolean isCacheMapping()

isWriteOn

public boolean isWriteOn(java.lang.Integer mode)

isReadOn

public boolean isReadOn(java.lang.Integer mode)

clear

public void clear()

getDefaultHandler

private StorageHandler getDefaultHandler()