Dashboard Builder Commons 6.0.0.Beta1

org.jboss.dashboard.database.cache.custom.map
Class SynchronizedLRUMap

java.lang.Object
  extended by java.util.AbstractMap
      extended by org.jboss.dashboard.database.cache.custom.map.AbstractHashedMap
          extended by org.jboss.dashboard.database.cache.custom.map.AbstractLinkedMap
              extended by org.jboss.dashboard.database.cache.custom.map.LRUMap
                  extended by org.jboss.dashboard.database.cache.custom.map.SynchronizedLRUMap
All Implemented Interfaces:
Serializable, Cloneable, Map, org.apache.commons.collections.IterableMap, org.apache.commons.collections.OrderedMap, BoundedMap
Direct Known Subclasses:
LRUCache.ListeningLRUMap

public class SynchronizedLRUMap
extends LRUMap

Synchronizes ALL public methods, not only those defined by Map interface

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jboss.dashboard.database.cache.custom.map.AbstractLinkedMap
AbstractLinkedMap.EntrySetIterator, AbstractLinkedMap.KeySetIterator, AbstractLinkedMap.LinkEntry, AbstractLinkedMap.LinkIterator, AbstractLinkedMap.LinkMapIterator, AbstractLinkedMap.ValuesIterator
 
Nested classes/interfaces inherited from class org.jboss.dashboard.database.cache.custom.map.AbstractHashedMap
AbstractHashedMap.EntrySet, AbstractHashedMap.HashEntry, AbstractHashedMap.HashIterator, AbstractHashedMap.HashMapIterator, AbstractHashedMap.KeySet, AbstractHashedMap.Values
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.jboss.dashboard.database.cache.custom.map.LRUMap
DEFAULT_MAX_SIZE
 
Fields inherited from class org.jboss.dashboard.database.cache.custom.map.AbstractLinkedMap
header
 
Fields inherited from class org.jboss.dashboard.database.cache.custom.map.AbstractHashedMap
data, DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_THRESHOLD, entrySet, GETKEY_INVALID, GETVALUE_INVALID, keySet, loadFactor, MAXIMUM_CAPACITY, modCount, NO_NEXT_ENTRY, NO_PREVIOUS_ENTRY, NULL, REMOVE_INVALID, SETVALUE_INVALID, size, threshold, values
 
Constructor Summary
SynchronizedLRUMap(int size)
           
 
Method Summary
 void clear()
          Clears the map, resetting the size to zero and nullifying references to avoid garbage collection issues.
 Object clone()
          Clones the map without cloning the keys or values.
 boolean containsKey(Object key)
          Checks whether the map contains the specified key.
 boolean containsValue(Object value)
          Checks whether the map contains the specified value.
 Set entrySet()
          Gets the entrySet view of the map.
 boolean equals(Object obj)
          Compares this map with another.
 Object firstKey()
          Gets the first key in the map, which is the most recently inserted.
 Object get(Object key)
          Gets the value mapped to the key specified.
 int hashCode()
          Gets the standard Map hashCode.
 boolean isEmpty()
          Checks whether the map is currently empty.
 boolean isFull()
          Returns true if this map is full and no new mappings can be added.
 boolean isScanUntilRemovable()
          Whether this LRUMap will scan until a removable entry is found when the map is full.
 Set keySet()
          Gets the keySet view of the map.
 Object lastKey()
          Gets the last key in the map, which is the first inserted.
 org.apache.commons.collections.MapIterator mapIterator()
          Gets an iterator over the map.
 int maxSize()
          Gets the maximum size of the map (the bound).
 Object nextKey(Object key)
          Gets the next key in sequence.
 org.apache.commons.collections.OrderedMapIterator orderedMapIterator()
          Gets a bidirectional iterator over the map.
 Object previousKey(Object key)
          Gets the previous key in sequence.
 Object put(Object key, Object value)
          Puts a key-value mapping into this map.
 void putAll(Map map)
          Puts all the values from the specified map into this map.
 Object remove(Object key)
          Removes the specified mapping from this map.
 int size()
          Gets the size of the map.
 String toString()
          Gets the map as a String.
 Collection values()
          Gets the values view of the map.
 
Methods inherited from class org.jboss.dashboard.database.cache.custom.map.LRUMap
addMapping, doReadObject, doWriteObject, moveToMRU, removeLRU, reuseMapping, updateEntry
 
Methods inherited from class org.jboss.dashboard.database.cache.custom.map.AbstractLinkedMap
addEntry, createEntry, createEntrySetIterator, createKeySetIterator, createValuesIterator, entryAfter, entryBefore, getEntry, init, removeEntry
 
Methods inherited from class org.jboss.dashboard.database.cache.custom.map.AbstractHashedMap
calculateNewCapacity, calculateThreshold, checkCapacity, convertKey, destroyEntry, ensureCapacity, entryHashCode, entryKey, entryNext, entryValue, getEntry, hash, hashIndex, isEqualKey, isEqualValue, removeMapping, reuseEntry
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SynchronizedLRUMap

public SynchronizedLRUMap(int size)
Method Detail

get

public Object get(Object key)
Description copied from class: LRUMap
Gets the value mapped to the key specified.

This operation changes the position of the key in the map to the most recently used position (first).

Specified by:
get in interface Map
Overrides:
get in class LRUMap
Parameters:
key - the key
Returns:
the mapped value, null if no match

isFull

public boolean isFull()
Description copied from class: LRUMap
Returns true if this map is full and no new mappings can be added.

Specified by:
isFull in interface BoundedMap
Overrides:
isFull in class LRUMap
Returns:
true if the map is full

maxSize

public int maxSize()
Description copied from class: LRUMap
Gets the maximum size of the map (the bound).

Specified by:
maxSize in interface BoundedMap
Overrides:
maxSize in class LRUMap
Returns:
the maximum number of elements the map can hold

isScanUntilRemovable

public boolean isScanUntilRemovable()
Description copied from class: LRUMap
Whether this LRUMap will scan until a removable entry is found when the map is full.

Overrides:
isScanUntilRemovable in class LRUMap
Returns:
true if this map scans

clone

public Object clone()
Description copied from class: LRUMap
Clones the map without cloning the keys or values.

Overrides:
clone in class LRUMap
Returns:
a shallow clone

toString

public String toString()
Description copied from class: AbstractHashedMap
Gets the map as a String.

Overrides:
toString in class AbstractHashedMap
Returns:
a string version of the map

hashCode

public int hashCode()
Description copied from class: AbstractHashedMap
Gets the standard Map hashCode.

Specified by:
hashCode in interface Map
Overrides:
hashCode in class AbstractHashedMap
Returns:
the hash code defined in the Map interface

equals

public boolean equals(Object obj)
Description copied from class: AbstractHashedMap
Compares this map with another.

Specified by:
equals in interface Map
Overrides:
equals in class AbstractHashedMap
Parameters:
obj - the object to compare to
Returns:
true if equal

values

public Collection values()
Description copied from class: AbstractHashedMap
Gets the values view of the map. Changes made to the view affect this map. To simply iterate through the values, use AbstractHashedMap.mapIterator().

Specified by:
values in interface Map
Overrides:
values in class AbstractHashedMap
Returns:
the values view

keySet

public Set keySet()
Description copied from class: AbstractHashedMap
Gets the keySet view of the map. Changes made to the view affect this map. To simply iterate through the keys, use AbstractHashedMap.mapIterator().

Specified by:
keySet in interface Map
Overrides:
keySet in class AbstractHashedMap
Returns:
the keySet view

entrySet

public Set entrySet()
Description copied from class: AbstractHashedMap
Gets the entrySet view of the map. Changes made to the view affect this map. To simply iterate through the entries, use AbstractHashedMap.mapIterator().

Specified by:
entrySet in interface Map
Overrides:
entrySet in class AbstractHashedMap
Returns:
the entrySet view

remove

public Object remove(Object key)
Description copied from class: AbstractHashedMap
Removes the specified mapping from this map.

Specified by:
remove in interface Map
Overrides:
remove in class AbstractHashedMap
Parameters:
key - the mapping to remove
Returns:
the value mapped to the removed key, null if key not in map

putAll

public void putAll(Map map)
Description copied from class: AbstractHashedMap
Puts all the values from the specified map into this map.

This implementation iterates around the specified map and uses AbstractHashedMap.put(Object, Object).

Specified by:
putAll in interface Map
Overrides:
putAll in class AbstractHashedMap
Parameters:
map - the map to add

put

public Object put(Object key,
                  Object value)
Description copied from class: AbstractHashedMap
Puts a key-value mapping into this map.

Specified by:
put in interface Map
Overrides:
put in class AbstractHashedMap
Parameters:
key - the key to add
value - the value to add
Returns:
the value previously mapped to this key, null if none

containsKey

public boolean containsKey(Object key)
Description copied from class: AbstractHashedMap
Checks whether the map contains the specified key.

Specified by:
containsKey in interface Map
Overrides:
containsKey in class AbstractHashedMap
Parameters:
key - the key to search for
Returns:
true if the map contains the key

isEmpty

public boolean isEmpty()
Description copied from class: AbstractHashedMap
Checks whether the map is currently empty.

Specified by:
isEmpty in interface Map
Overrides:
isEmpty in class AbstractHashedMap
Returns:
true if the map is currently size zero

size

public int size()
Description copied from class: AbstractHashedMap
Gets the size of the map.

Specified by:
size in interface Map
Overrides:
size in class AbstractHashedMap
Returns:
the size

orderedMapIterator

public org.apache.commons.collections.OrderedMapIterator orderedMapIterator()
Description copied from class: AbstractLinkedMap
Gets a bidirectional iterator over the map. Changes made to the iterator affect this map.

A MapIterator returns the keys in the map. It also provides convenient methods to get the key and value, and set the value. It avoids the need to create an entrySet/keySet/values object.

Specified by:
orderedMapIterator in interface org.apache.commons.collections.OrderedMap
Overrides:
orderedMapIterator in class AbstractLinkedMap
Returns:
the map iterator

mapIterator

public org.apache.commons.collections.MapIterator mapIterator()
Description copied from class: AbstractLinkedMap
Gets an iterator over the map. Changes made to the iterator affect this map.

A MapIterator returns the keys in the map. It also provides convenient methods to get the key and value, and set the value. It avoids the need to create an entrySet/keySet/values object.

Specified by:
mapIterator in interface org.apache.commons.collections.IterableMap
Overrides:
mapIterator in class AbstractLinkedMap
Returns:
the map iterator

previousKey

public Object previousKey(Object key)
Description copied from class: AbstractLinkedMap
Gets the previous key in sequence.

Specified by:
previousKey in interface org.apache.commons.collections.OrderedMap
Overrides:
previousKey in class AbstractLinkedMap
Parameters:
key - the key to get before
Returns:
the previous key

nextKey

public Object nextKey(Object key)
Description copied from class: AbstractLinkedMap
Gets the next key in sequence.

Specified by:
nextKey in interface org.apache.commons.collections.OrderedMap
Overrides:
nextKey in class AbstractLinkedMap
Parameters:
key - the key to get after
Returns:
the next key

lastKey

public Object lastKey()
Description copied from class: AbstractLinkedMap
Gets the last key in the map, which is the first inserted.

Specified by:
lastKey in interface org.apache.commons.collections.OrderedMap
Overrides:
lastKey in class AbstractLinkedMap
Returns:
the eldest key

firstKey

public Object firstKey()
Description copied from class: AbstractLinkedMap
Gets the first key in the map, which is the most recently inserted.

Specified by:
firstKey in interface org.apache.commons.collections.OrderedMap
Overrides:
firstKey in class AbstractLinkedMap
Returns:
the most recently inserted key

clear

public void clear()
Description copied from class: AbstractLinkedMap
Clears the map, resetting the size to zero and nullifying references to avoid garbage collection issues.

Specified by:
clear in interface Map
Overrides:
clear in class AbstractLinkedMap

containsValue

public boolean containsValue(Object value)
Description copied from class: AbstractLinkedMap
Checks whether the map contains the specified value.

Specified by:
containsValue in interface Map
Overrides:
containsValue in class AbstractLinkedMap
Parameters:
value - the value to search for
Returns:
true if the map contains the value

Dashboard Builder Commons 6.0.0.Beta1

Copyright © 2012-2013 JBoss by Red Hat. All Rights Reserved.