Package jadex.commons

Class ObjectCache

  • All Implemented Interfaces:
    java.io.Serializable

    public class ObjectCache
    extends java.lang.Object
    implements java.io.Serializable
    A 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.Map cache
      The expression caches for filename.
      protected java.lang.String filename
      The filename of the cache.
      protected boolean persist_always
      The persist strategy (always or only on demand by manually calling persist).
      protected boolean persist_single
      The 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.
    • 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.IOException
        Presist 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.