org.opensaml.xml.util
Class ValueTypeIndexedMap<KeyType,ValueType>

java.lang.Object
  extended by org.opensaml.xml.util.ValueTypeIndexedMap<KeyType,ValueType>
Type Parameters:
KeyType - the type of object used as keys
ValueType - the type of object stored as values
All Implemented Interfaces:
Map<KeyType,ValueType>

public class ValueTypeIndexedMap<KeyType,ValueType>
extends Object
implements Map<KeyType,ValueType>

Map implementation which allows subsets of entries to be retrieved based on the type of the entry value.


Nested Class Summary
private static class ValueTypeIndexedMap.NullValue
          Class to represent null values.
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
private  Map<Class<?>,Map<KeyType,ValueType>> index
          Storage for index of class -> members.
private  Map<KeyType,ValueType> map
          Storage for map members.
private  Set<Class> types
          Set of valid types for this map.
 
Constructor Summary
ValueTypeIndexedMap()
          Constructor.
ValueTypeIndexedMap(Collection<Class> newTypes)
          Constructor.
ValueTypeIndexedMap(Map<KeyType,ValueType> newMap, Collection<Class> newTypes)
          Constructor.
 
Method Summary
 void clear()
          
 boolean containsKey(Object key)
          
 boolean containsValue(Object value)
          
 Set<Map.Entry<KeyType,ValueType>> entrySet()
          
 ValueType get(Object key)
          
 Set<Class> getTypes()
          Get the value types that are indexed.
 boolean isEmpty()
          
 Set<KeyType> keySet()
          
private  Boolean matchType(Class<?> type, Object object)
          Check if the object is of the specified type, taking null into account as well.
 ValueType put(KeyType key, ValueType value)
          
 void putAll(Map<? extends KeyType,? extends ValueType> t)
          
 void rebuildIndex()
          Rebuild internal index.
 ValueType remove(Object key)
          
 void setTypes(Collection<Class> newTypes)
          Set which value types are indexed.
 int size()
          
<SubType extends ValueType>
Map<KeyType,SubType>
subMap(Class<SubType> type)
          Returns an unmodifiable map of the entries whose value is of the specified type.
 String toString()
          
 Collection<ValueType> 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

index

private Map<Class<?>,Map<KeyType,ValueType>> index
Storage for index of class -> members.


map

private Map<KeyType,ValueType> map
Storage for map members.


types

private Set<Class> types
Set of valid types for this map.

Constructor Detail

ValueTypeIndexedMap

public ValueTypeIndexedMap()
Constructor.


ValueTypeIndexedMap

public ValueTypeIndexedMap(Map<KeyType,ValueType> newMap,
                           Collection<Class> newTypes)
Constructor.

Parameters:
newMap - existing map to build from.
newTypes - collection of value types to index

ValueTypeIndexedMap

public ValueTypeIndexedMap(Collection<Class> newTypes)
Constructor.

Parameters:
newTypes - collection of value types to index
Method Detail

clear

public void clear()

Specified by:
clear in interface Map<KeyType,ValueType>

containsKey

public boolean containsKey(Object key)

Specified by:
containsKey in interface Map<KeyType,ValueType>

containsValue

public boolean containsValue(Object value)

Specified by:
containsValue in interface Map<KeyType,ValueType>

entrySet

public Set<Map.Entry<KeyType,ValueType>> entrySet()

Specified by:
entrySet in interface Map<KeyType,ValueType>

get

public ValueType get(Object key)

Specified by:
get in interface Map<KeyType,ValueType>

getTypes

public Set<Class> getTypes()
Get the value types that are indexed.

Returns:
which value types are indexed

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Map<KeyType,ValueType>

keySet

public Set<KeyType> keySet()

Specified by:
keySet in interface Map<KeyType,ValueType>

matchType

private Boolean matchType(Class<?> type,
                          Object object)
Check if the object is of the specified type, taking null into account as well.

Parameters:
type - type to check for
object - object to check
Returns:
true if the object is of the specified type

put

public ValueType put(KeyType key,
                     ValueType value)

Specified by:
put in interface Map<KeyType,ValueType>

putAll

public void putAll(Map<? extends KeyType,? extends ValueType> t)

Specified by:
putAll in interface Map<KeyType,ValueType>

rebuildIndex

public void rebuildIndex()
Rebuild internal index.


remove

public ValueType remove(Object key)

Specified by:
remove in interface Map<KeyType,ValueType>

setTypes

public void setTypes(Collection<Class> newTypes)
Set which value types are indexed.

Parameters:
newTypes - which value types are indexed

size

public int size()

Specified by:
size in interface Map<KeyType,ValueType>

subMap

public <SubType extends ValueType> Map<KeyType,SubType> subMap(Class<SubType> type)
Returns an unmodifiable map of the entries whose value is of the specified type.

Type Parameters:
SubType - type of values to include in the returned map
Parameters:
type - type of values to return
Returns:
sub map of entries whose value is of type SubType or null if the specified type is not a valid type for this map.

toString

public String toString()

Overrides:
toString in class Object

values

public Collection<ValueType> values()

Specified by:
values in interface Map<KeyType,ValueType>


Copyright © 1999-2013. All Rights Reserved.