|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.edg.security.authorization.map.CachedMap
Class CachedMap A map with constraints on time and/or size. Various map instances may be slow in their lookups. This class can be wrapped around another map. It caches the results from the lookups in a hash table, only accessing the underlying map when needed. The caching policy can be altered in two ways:
put()
, remove()
, clear()
of
the cached map is immediately propagated to the underlying map.
Insert 'the right' copyright
Nested Class Summary | |
class |
CachedMap.Result
|
Field Summary | |
protected java.util.LinkedHashMap |
myCache
|
protected java.util.Map |
myMap
|
protected long |
myMaxSize
|
protected long |
myMaxTime
|
protected long |
mySize
|
static long |
theDefaultMaxSize
theDefaultMaxSize The maximum number of lookup results stored in the cache. |
static long |
theDefaultMaxTime
theDefaultMaxTime The maximum time period a result is cached, in seconds. |
Constructor Summary | |
CachedMap(java.util.Map mapToCache)
Constructor CachedMap. |
|
CachedMap(java.util.Map mapToCache,
long maxSize,
long maxTime)
Constructor CachedMap. |
Method Summary | |
void |
clear()
|
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
|
java.util.Set |
entrySet()
|
java.lang.Object |
get(java.lang.Object key)
|
boolean |
isEmpty()
|
java.util.Set |
keySet()
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
|
void |
putAll(java.util.Map t)
|
java.lang.Object |
remove(java.lang.Object key)
|
int |
size()
Deprecated. Hmm... what to return here? The current size of the cache or the size of the underlying Map? Unsupported for now... |
java.lang.String |
toString()
|
java.util.Collection |
values()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Field Detail |
public static long theDefaultMaxSize
public static long theDefaultMaxTime
protected java.util.Map myMap
protected long myMaxSize
protected long myMaxTime
protected long mySize
protected java.util.LinkedHashMap myCache
Constructor Detail |
public CachedMap(java.util.Map mapToCache)
theDefaultMaxSize
,
CachedMap(Map, long, long)
public CachedMap(java.util.Map mapToCache, long maxSize, long maxTime)
mapToCache
- - the map to cache result of lookups frommaxSize
- - the max size of the cachemaxTime
- - the max time to cache a result, in secondstheDefaultMaxSize
,
theDefaultMaxTime
Method Detail |
public int size()
size
in interface java.util.Map
public boolean isEmpty()
isEmpty
in interface java.util.Map
Map.isEmpty()
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map
Map.containsKey(Object)
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
Map.containsValue(Object)
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
Map.get(Object)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
Map.put(Object, Object)
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
Map.remove(Object)
public void putAll(java.util.Map t)
putAll
in interface java.util.Map
Map.putAll(Map)
public void clear()
clear
in interface java.util.Map
Map.clear()
public java.util.Set keySet()
keySet
in interface java.util.Map
Map.keySet()
public java.util.Collection values()
values
in interface java.util.Map
Map.values()
public java.util.Set entrySet()
entrySet
in interface java.util.Map
Map.entrySet()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |