LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.data.cache
Class LySimpleCache

java.lang.Object
  extended by leon.data.LyCache
      extended by leon.data.cache.LySimpleCache
Direct Known Subclasses:
LyLruCache

public class LySimpleCache
extends LyCache

This class implements a simple cache in which objects are stored and unloaded on the fly, depending to dataSource needs.

Each object kept in the cache has a number of locks (uses) associated to it, when this number of locks become 0, the object is removed from the cache.


Nested Class Summary
 
Nested classes/interfaces inherited from class leon.data.LyCache
LyCache.Result
 
Field Summary
static java.lang.String __VERSION
          File version.
 
Fields inherited from class leon.data.LyCache
NB_UNKNOWN_OBJECTS
 
Constructor Summary
LySimpleCache(LyClass cacheClass, LyInfoCache policy)
          Constructor of a simple cache of objects related to a given class description.
 
Method Summary
 void allowLoaded(boolean allowLoaded)
          Indicate if the cache can be marked as Loaded.
 LyObject getObjectFromPeer(java.lang.Object peer)
          Gets an object from its physical representation (peer).
 int getSize(LyFilter filter)
          Return the number of objects within this cache that match the given filter (all objects of the cache if filter is null).
 boolean isEmpty()
          Tests if this cache is empty or not (contains no object).
 
Methods inherited from class leon.data.LyCache
clearUnknownIdsCache, contains, contains, getCacheClass, getCount, getEnvironment, getObject, getObjectList, getObjects, getObjects, getPolicy, isLoaded, rehash, setLoaded
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
File version.

See Also:
Constant Field Values
Constructor Detail

LySimpleCache

public LySimpleCache(LyClass cacheClass,
                     LyInfoCache policy)
Constructor of a simple cache of objects related to a given class description.

Parameters:
cacheClass - Class description of objects stored in the cache.
policy - Description of th epolicy of thsi cache.
Method Detail

getObjectFromPeer

public LyObject getObjectFromPeer(java.lang.Object peer)
Gets an object from its physical representation (peer). This method is only valid if stored objects are logical objects (instances of LyObject).

Specified by:
getObjectFromPeer in class LyCache
Parameters:
peer - Physical representation of the searched object.
Returns:
Object with the specified physical representation if it exists, otherwise null.
Throws:
java.lang.IllegalStateException - If this cache is not a cache that keep logical objects.

getSize

public int getSize(LyFilter filter)
Return the number of objects within this cache that match the given filter (all objects of the cache if filter is null). This method gives objects that are in the cache, no other objects are loaded.

Specified by:
getSize in class LyCache
Parameters:
filter - Filter used for selecting objects. If filter is null, the total is returned.
Returns:
Number of objects in the cache that match the filter.

isEmpty

public boolean isEmpty()
Tests if this cache is empty or not (contains no object).

Specified by:
isEmpty in class LyCache
Returns:
True if the cache is empty, false otherwise.

allowLoaded

public void allowLoaded(boolean allowLoaded)
Indicate if the cache can be marked as Loaded. For the simple cache, this implementation does nothing as marking this cache as loaded is a nonsense

Specified by:
allowLoaded in class LyCache
Parameters:
allowLoaded - the value of the allowLoaded attribute

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com