Package com.twelvemonkeys.util
Class AbstractDecoratedMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- com.twelvemonkeys.util.AbstractDecoratedMap<K,V>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<K,V>
- Direct Known Subclasses:
IgnoreCaseMap
,LinkedMap
,TimeoutMap
abstract class AbstractDecoratedMap<K,V> extends java.util.AbstractMap<K,V> implements java.util.Map<K,V>, java.io.Serializable, java.lang.Cloneable
AbstractDecoratedMap- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/util/AbstractDecoratedMap.java#2 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
AbstractDecoratedMap.BasicEntry<K,V>
A simple Map.Entry implementation.protected class
AbstractDecoratedMap.EntrySet
protected class
AbstractDecoratedMap.KeySet
protected class
AbstractDecoratedMap.Values
-
Constructor Summary
Constructors Constructor Description AbstractDecoratedMap()
Creates aMap
backed by aHashMap
.AbstractDecoratedMap(java.util.Map<? extends K,? extends V> pContents)
Creates aMap
backed by aHashMap
, containing all key/value mappings from the givenMap
.AbstractDecoratedMap(java.util.Map<K,java.util.Map.Entry<K,V>> pBacking, java.util.Map<? extends K,? extends V> pContents)
Creates aMap
backed by the given backing-Map
, containing all key/value mappings from the given contents-Map
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
clear()
protected java.lang.Object
clone()
Returns a shallow copy of thisAbstractMap
instance: the keys and values themselves are not cloned.boolean
containsKey(java.lang.Object pKey)
boolean
containsValue(java.lang.Object pValue)
Returnstrue
if this map maps one or more keys to the specified pValue.(package private) java.util.Map.Entry<K,V>
createEntry(K pKey, V pValue)
java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
abstract V
get(java.lang.Object pKey)
(package private) java.util.Map.Entry<K,V>
getEntry(K pKey)
protected void
init()
Default implementation, does nothing.boolean
isEmpty()
java.util.Set<K>
keySet()
protected abstract java.util.Iterator<java.util.Map.Entry<K,V>>
newEntryIterator()
protected abstract java.util.Iterator<K>
newKeyIterator()
protected abstract java.util.Iterator<V>
newValueIterator()
abstract V
put(K pKey, V pValue)
abstract V
remove(java.lang.Object pKey)
protected java.util.Map.Entry<K,V>
removeEntry(java.util.Map.Entry<K,V> pEntry)
Removes the given entry from the Map.int
size()
java.util.Collection<V>
values()
-
-
-
Constructor Detail
-
AbstractDecoratedMap
public AbstractDecoratedMap()
Creates aMap
backed by aHashMap
.
-
AbstractDecoratedMap
public AbstractDecoratedMap(java.util.Map<? extends K,? extends V> pContents)
Creates aMap
backed by aHashMap
, containing all key/value mappings from the givenMap
.This is constructor is here to comply with the reccomendations for "standard" constructors in the
Map
interface.- Parameters:
pContents
- the map whose mappings are to be placed in this map. May benull
.- See Also:
AbstractDecoratedMap(java.util.Map, java.util.Map)
-
AbstractDecoratedMap
public AbstractDecoratedMap(java.util.Map<K,java.util.Map.Entry<K,V>> pBacking, java.util.Map<? extends K,? extends V> pContents)
Creates aMap
backed by the given backing-Map
, containing all key/value mappings from the given contents-Map
.NOTE: The backing map is structuraly cahnged, and it should NOT be accessed directly, after the wrapped map is created.
- Parameters:
pBacking
- the backing map of this map. Must be either empty, or the same map aspContents
.pContents
- the map whose mappings are to be placed in this map. May benull
.- Throws:
java.lang.IllegalArgumentException
- ifpBacking
isnull
or ifpBacking
differs frompContent
and is not empty.
-
-
Method Detail
-
init
protected void init()
Default implementation, does nothing.
-
size
public int size()
-
clear
public void clear()
-
isEmpty
public boolean isEmpty()
-
containsKey
public boolean containsKey(java.lang.Object pKey)
-
containsValue
public boolean containsValue(java.lang.Object pValue)
Returnstrue
if this map maps one or more keys to the specified pValue. More formally, returnstrue
if and only if this map contains at least one mapping to a pValuev
such that(pValue==null ? v==null : pValue.equals(v))
.This implementation requires time linear in the map size for this operation.
-
values
public java.util.Collection<V> values()
-
keySet
public java.util.Set<K> keySet()
-
clone
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a shallow copy of thisAbstractMap
instance: the keys and values themselves are not cloned.
-
newKeyIterator
protected abstract java.util.Iterator<K> newKeyIterator()
-
newValueIterator
protected abstract java.util.Iterator<V> newValueIterator()
-
newEntryIterator
protected abstract java.util.Iterator<java.util.Map.Entry<K,V>> newEntryIterator()
-
get
public abstract V get(java.lang.Object pKey)
-
remove
public abstract V remove(java.lang.Object pKey)
-
-