public class TemporaryMap<K,V> extends java.lang.Object implements java.util.Map<K,V>, TriggerClient, java.io.Serializable
Modifier | Constructor and Description |
---|---|
protected |
TemporaryMap() |
|
TemporaryMap(long expiresAfterMs,
long checkAfterMs)
Initialize the new instance with values that define the expiration
of any object in the map and the interval for checking if expired
objects are in the map.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canBeTriggeredBy(Trigger trigger)
FOR INTERNAL USE ONLY!
Will be called by a Trigger to check if object clean-up can be executed. |
void |
clear() |
boolean |
containsKey(java.lang.Object key)
This method returns true, if the given key can be found in this map.
|
boolean |
containsValue(java.lang.Object value)
This method returns true, if the given value is a value of any entry
in this map.
|
protected java.util.Map<K,Association<java.lang.Long,V>> |
createEmptyMap()
Provide a synchronized HashMap.
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
This method automatically touches every entry, so that its
expire period starts anew.
|
protected long |
expirationTime() |
protected void |
expirationTime(long newValue) |
protected java.util.Map.Entry<K,Association<java.lang.Long,V>> |
findByValue(java.lang.Object value) |
V |
get(java.lang.Object key)
Returns the object that was registered under the specified key.
|
protected java.util.Map<K,Association<java.lang.Long,V>> |
internalMap() |
protected void |
internalMap(java.util.Map<K,Association<java.lang.Long,V>> newValue) |
boolean |
isEmpty() |
protected boolean |
isExpired(Association<java.lang.Long,V> assoc) |
java.util.Set<K> |
keySet()
Returns all keys in this map.
|
protected java.lang.Long |
newTimestamp() |
V |
put(K key,
V value)
Puts the given value under the specified key into the map.
|
void |
putAll(java.util.Map<? extends K,? extends V> map)
Each entry of the given map will be added.
|
V |
remove(java.lang.Object key)
Remove the entry with the given key and return the associated object.
|
protected void |
removeExpiredEntries() |
int |
size() |
protected void |
touch(Association<java.lang.Long,V> assoc) |
protected void |
touchAll() |
boolean |
triggeredBy(Trigger trigger)
FOR INTERNAL USE ONLY!
Will be called by a Trigger to execute the clean-up of expired objects. |
java.util.Collection<V> |
values()
Returns all values of the map.
|
protected TemporaryMap()
public TemporaryMap(long expiresAfterMs, long checkAfterMs)
expiresAfterMs
- Defines after what time (milliseconds) an unused
object must be removed (must be >= 100)checkAfterMs
- Defines the interval for lookup and remove expired
objects (must be >= 10)public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
public V get(java.lang.Object key)
public java.util.Set<K> keySet()
public V put(K key, V value)
public void putAll(java.util.Map<? extends K,? extends V> map)
public java.util.Collection<V> values()
public V remove(java.lang.Object key)
public boolean canBeTriggeredBy(Trigger trigger)
canBeTriggeredBy
in interface TriggerClient
trigger
- The trigger that calls this methodTriggerClient.canBeTriggeredBy(Trigger)
public boolean triggeredBy(Trigger trigger)
triggeredBy
in interface TriggerClient
trigger
- The trigger that calls this methodTriggerClient.triggeredBy(Trigger)
protected void touch(Association<java.lang.Long,V> assoc)
protected void touchAll()
protected java.lang.Long newTimestamp()
protected void removeExpiredEntries()
protected boolean isExpired(Association<java.lang.Long,V> assoc)
protected java.util.Map.Entry<K,Association<java.lang.Long,V>> findByValue(java.lang.Object value)
protected java.util.Map<K,Association<java.lang.Long,V>> createEmptyMap()
protected java.util.Map<K,Association<java.lang.Long,V>> internalMap()
protected void internalMap(java.util.Map<K,Association<java.lang.Long,V>> newValue)
protected long expirationTime()
protected void expirationTime(long newValue)