org.edg.security.authorization.map
Class DefaultAttributeMap

java.lang.Object
  |
  +--org.edg.security.authorization.map.DefaultAttributeMap
All Implemented Interfaces:
AttributeMap, java.util.Map

public class DefaultAttributeMap
extends java.lang.Object
implements AttributeMap

Default implementation for the AttributeMap interface, that works against a normal Map implemenation.

Author:
mulmo

Field Summary
protected  java.util.Map map
          The Map instance to work against
 
Constructor Summary
DefaultAttributeMap(java.util.Map map)
           
 
Method Summary
 void addAttribute(java.lang.String key, java.lang.String value)
          Convenience method to add a single attribute to the existing set of attributes associated with a key.
 void addAttributes(java.lang.String key, java.util.List values)
          Convenience method to add a set of attributes.
 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)
           
 java.util.List getAttributes(java.lang.String key)
          Convenience method to get the right return type, and to get an empty list in case of no match.
 boolean hasMapping(java.lang.String key, java.lang.String value)
          This method has the same semantics as the call getAttributes(key).contains(value)
but may be optimized for the particular Map
 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)
           
 java.lang.String removeAttribute(java.lang.String key, java.lang.String value)
          Removal of a particular attribute in the list of attributes for the given subject.
 int size()
           
 void terminate()
          Terminate all Timer objects responsible for refreshing the content of the AttributeMap.
 java.util.Collection values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

map

protected java.util.Map map
The Map instance to work against

Constructor Detail

DefaultAttributeMap

public DefaultAttributeMap(java.util.Map map)
Parameters:
map - The map to work against
Method Detail

getAttributes

public java.util.List getAttributes(java.lang.String key)
Description copied from interface: AttributeMap
Convenience method to get the right return type, and to get an empty list in case of no match.

Specified by:
getAttributes in interface AttributeMap
Returns:
List of String, or an empty list if no match
See Also:
AttributeMap.getAttributes(String)

addAttributes

public void addAttributes(java.lang.String key,
                          java.util.List values)
Description copied from interface: AttributeMap
Convenience method to add a set of attributes.

This is typically implemented as an iteration of calls to addAttribute(String, String), one call for each value in the List.

This feature may be overriden by a particular Map implementation.

Specified by:
addAttributes in interface AttributeMap
Parameters:
key - the key
values - List of String with attributes
See Also:
AttributeMap.addAttributes(String, List)

addAttribute

public void addAttribute(java.lang.String key,
                         java.lang.String value)
Description copied from interface: AttributeMap
Convenience method to add a single attribute to the existing set of attributes associated with a key. This may be needed to be overriden by a particular Map.

Specified by:
addAttribute in interface AttributeMap
Parameters:
key - the key
value - The attribute to add
See Also:
Adds the attribute to the subject only if the association subject-attribute does not exist.

hasMapping

public boolean hasMapping(java.lang.String key,
                          java.lang.String value)
Description copied from interface: AttributeMap
This method has the same semantics as the call getAttributes(key).contains(value)
but may be optimized for the particular Map

Specified by:
hasMapping in interface AttributeMap
Parameters:
key - the key
value - the value to match against
Returns:
boolean if the mapping exists
See Also:
AttributeMap.hasMapping(String, String)

removeAttribute

public java.lang.String removeAttribute(java.lang.String key,
                                        java.lang.String value)
Description copied from interface: AttributeMap
Removal of a particular attribute in the list of attributes for the given subject.
This call may be optimized for the particular Map instance.

Specified by:
removeAttribute in interface AttributeMap
Parameters:
key - the key
value - a single value to remove from the list of values associated with the key
See Also:
AttributeMap.removeAttribute(String, String)

size

public int size()
Specified by:
size in interface java.util.Map
See Also:
Map.size()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map
See Also:
Map.isEmpty()

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map
See Also:
Map.containsKey(Object)

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map
See Also:
Map.containsValue(Object)

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map
See Also:
Map.get(Object)

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map
See Also:
Map.put(Object, Object)

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map
See Also:
Map.remove(Object)

putAll

public void putAll(java.util.Map t)
Specified by:
putAll in interface java.util.Map
See Also:
Map.putAll(Map)

clear

public void clear()
Specified by:
clear in interface java.util.Map
See Also:
Map.clear()

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map
See Also:
This method can be used to list all subjects

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map
See Also:
Map.values()

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map
See Also:
This method can be used to list all subjects with their associated attributes.

terminate

public void terminate()
Description copied from interface: AttributeMap
Terminate all Timer objects responsible for refreshing the content of the AttributeMap.

Specified by:
terminate in interface AttributeMap
See Also:
AttributeMap.terminate()