Class CacheLRUWrapper

java.lang.Object
net.sourceforge.jnlp.cache.CacheLRUWrapper

public class CacheLRUWrapper extends Object
This class helps maintain the ordering of most recently use items across multiple jvm instances.
  • Constructor Details

    • CacheLRUWrapper

      public CacheLRUWrapper()
  • Method Details

    • getInstance

      public static CacheLRUWrapper getInstance()
      Returns an instance of the policy.
      Returns:
      an instance of the policy
    • getCacheDir

      public InfrastructureFileDescriptor getCacheDir()
      Returns:
      the cacheDir
    • getWindowsShortcutList

      public File getWindowsShortcutList()
    • getRecentlyUsedFile

      public InfrastructureFileDescriptor getRecentlyUsedFile()
      Returns:
      the recentlyUsedFile
    • load

      public void load()
      Update map for keeping track of recently used items.
    • store

      public boolean store()
      Write file to disk.
      Returns:
      true if properties were successfully stored, false otherwise
    • addEntry

      public boolean addEntry(String key, String path)
      This adds a new entry to file.
      Parameters:
      key - key we want path to be associated with.
      path - path to cache item.
      Returns:
      true if we successfully added to map, false otherwise.
    • removeEntry

      public boolean removeEntry(String key)
      This removed an entry from our map.
      Parameters:
      key - key we want to remove.
      Returns:
      true if we successfully removed key from map, false otherwise.
    • updateEntry

      public boolean updateEntry(String oldKey)
      This updates the given key to reflect it was recently accessed.
      Parameters:
      oldKey - Key we wish to update.
      Returns:
      true if we successfully updated value, false otherwise.
    • getLRUSortedEntries

      public List<Map.Entry<String,String>> getLRUSortedEntries()
      Return a copy of the keys available.
      Returns:
      List of Strings sorted by ascending order.
    • lock

      public void lock()
      Lock the file to have exclusive access.
    • unlock

      public void unlock()
      Unlock the file.
    • getValue

      public String getValue(String key)
      Return the value of given key.
      Parameters:
      key - key of property
      Returns:
      value of given key, null otherwise.
    • containsKey

      public boolean containsKey(String key)
    • containsValue

      public boolean containsValue(String value)
    • generateKey

      public String generateKey(String path)
      Generate a key given the path to file. May or may not generate the same key given same path.
      Parameters:
      path - Path to generate a key with.
      Returns:
      String representing the a key.