Class TimedHashMap<K,V>
java.lang.Object
net.sourceforge.jnlp.util.TimedHashMap<K,V>
- Record Components:
K- The key typeV- The Object type
- All Implemented Interfaces:
Map<K,V>
Simple utility class that extends HashMap by adding an expiry to the entries.
This map stores entries, and returns them only if the entries were last accessed within a specified timeout period.
Otherwise, null is returned.
This map does not allow null keys but does allow null values.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HashMap<K, TimedHashMap.TimedEntry<V>> private static final longprivate static final Loggerprivate long -
Constructor Summary
ConstructorsConstructorDescriptionTimedHashMap(long timeout, TimeUnit unit) Create a new map with a non-default entry timeout period -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()Return cached item if it has not already expired.booleanisEmpty()keySet()Store the item in the map and associate a timestamp with it.voidvoidsetTimeout(long timeout, TimeUnit unit) Specify how long (in nanoseconds) entries are valid forintsize()values()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
LOG
-
DEFAULT_TIMEOUT
private static final long DEFAULT_TIMEOUT -
actualMap
-
timeout
private long timeout
-
-
Constructor Details
-
TimedHashMap
public TimedHashMap() -
TimedHashMap
Create a new map with a non-default entry timeout period- Parameters:
timeout- the length of the timeoutunit- the units of the timeout
-
-
Method Details
-
setTimeout
Specify how long (in nanoseconds) entries are valid for- Parameters:
timeout- the length of the timeoutunit- the units of the timeout
-
put
-
get
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
size
-
isEmpty
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
remove
-
putAll
-
clear
-
keySet
-
values
-
entrySet
-