Package jadex.commons
Class ObjectCache
- java.lang.Object
-
- jadex.commons.ObjectCache
-
- All Implemented Interfaces:
java.io.Serializable
public class ObjectCache extends java.lang.Object implements java.io.SerializableA cache for CachedObjects that reflect files. A cached object is loaded per filename (not the filename of the held object in the cache).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.MapcacheThe expression caches for filename.protected java.lang.StringfilenameThe filename of the cache.protected booleanpersist_alwaysThe persist strategy (always or only on demand by manually calling persist).protected booleanpersist_singleThe flag indicating if cached objects are stored on disk themselves.
-
Constructor Summary
Constructors Constructor Description ObjectCache(java.lang.String filename)Create a new cache.ObjectCache(java.lang.String filename, boolean persist_always, boolean persist_single)Create a new cache.ObjectCache(java.lang.String filename, boolean persist_always, boolean persist_single, int max)Create a new cache.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(CachedObject co)Add a cached object.voidclear()Clear the cache.CachedObjectloadCachedObject(java.lang.String filename, long lastmodified)Load the cached file.static ObjectCacheloadObjectCache(java.lang.String filename)Load the model cache.voidpersist()Presist the cached object.voidremove(java.lang.String filename)Add a cached object.
-
-
-
Field Detail
-
persist_always
protected boolean persist_always
The persist strategy (always or only on demand by manually calling persist).
-
persist_single
protected boolean persist_single
The flag indicating if cached objects are stored on disk themselves.
-
filename
protected java.lang.String filename
The filename of the cache.
-
cache
protected java.util.Map cache
The expression caches for filename.
-
-
Constructor Detail
-
ObjectCache
public ObjectCache(java.lang.String filename)
Create a new cache.
-
ObjectCache
public ObjectCache(java.lang.String filename, boolean persist_always, boolean persist_single)Create a new cache.
-
ObjectCache
public ObjectCache(java.lang.String filename, boolean persist_always, boolean persist_single, int max)Create a new cache.
-
-
Method Detail
-
loadCachedObject
public CachedObject loadCachedObject(java.lang.String filename, long lastmodified)
Load the cached file.- Parameters:
filename- The filename of the cached object.lastmodified- The last modified date important for the up-to-date check. -1 for do not check.
-
add
public void add(CachedObject co)
Add a cached object.- Parameters:
co- The new object.
-
remove
public void remove(java.lang.String filename)
Add a cached object.- Parameters:
filename- The filename.
-
persist
public void persist() throws java.io.IOExceptionPresist the cached object.- Throws:
java.io.IOException
-
clear
public void clear()
Clear the cache.
-
loadObjectCache
public static ObjectCache loadObjectCache(java.lang.String filename)
Load the model cache.- Parameters:
filename- The filename.- Returns:
- The object cache.
-
-