Package net.sourceforge.jnlp.cache
Class CacheLRUWrapper
- java.lang.Object
-
- net.sourceforge.jnlp.cache.CacheLRUWrapper
-
public class CacheLRUWrapper extends java.lang.ObjectThis class helps maintain the ordering of most recently use items across multiple jvm instances.
-
-
Constructor Summary
Constructors Constructor Description CacheLRUWrapper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEntry(java.lang.String key, java.lang.String path)This adds a new entry to file.booleancontainsKey(java.lang.String key)booleancontainsValue(java.lang.String value)java.lang.StringgenerateKey(java.lang.String path)Generate a key given the path to file.InfrastructureFileDescriptorgetCacheDir()static CacheLRUWrappergetInstance()Returns an instance of the policy.java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>>getLRUSortedEntries()Return a copy of the keys available.InfrastructureFileDescriptorgetRecentlyUsedFile()java.lang.StringgetValue(java.lang.String key)Return the value of given key.java.io.FilegetWindowsShortcutList()voidload()Update map for keeping track of recently used items.voidlock()Lock the file to have exclusive access.booleanremoveEntry(java.lang.String key)This removed an entry from our map.booleanstore()Write file to disk.voidunlock()Unlock the file.booleanupdateEntry(java.lang.String oldKey)This updates the given key to reflect it was recently accessed.
-
-
-
Method Detail
-
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 java.io.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(java.lang.String key, java.lang.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(java.lang.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(java.lang.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 java.util.List<java.util.Map.Entry<java.lang.String,java.lang.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 java.lang.String getValue(java.lang.String key)
Return the value of given key.- Parameters:
key- key of property- Returns:
- value of given key, null otherwise.
-
containsKey
public boolean containsKey(java.lang.String key)
-
containsValue
public boolean containsValue(java.lang.String value)
-
generateKey
public java.lang.String generateKey(java.lang.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.
-
-