net.geant.edugain.attributes
Class AttributeSet

java.lang.Object
  extended by net.geant.edugain.attributes.AttributeSet
All Implemented Interfaces:
java.lang.Cloneable

public class AttributeSet
extends java.lang.Object
implements java.lang.Cloneable

This class implements a container for AttributeValues. AttributeSet also manages the attribute name mappings with the help of AttributeNameMapper implementations.

Author:
Kristof Bajnok, Adam Lantos

Field Summary
private  AttributeNameMapper attributeNameMapper
          AttributeNameMapper which is used to manage attribute name mappings.
private  java.util.Map<java.lang.String,AttributeValues> attributes
          Map for storing Attributes.
private static java.lang.String DEFAULT_ATTRIBUTENAMESPACE
          Default attributeNameSpace.
private  org.apache.log4j.Logger log
           
private static long serialVersionUID
           
 
Constructor Summary
AttributeSet()
          Creates an empty set.
AttributeSet(AttributeNameMapper mapper)
          Creates an empty set with the specified AttributeNameMapper.
AttributeSet(java.util.List<AttributeValues> attributeList)
          Creates a set from a list of AttributeValues.
AttributeSet(java.util.List<AttributeValues> attributeList, AttributeNameMapper mapper)
          Creates a set from a list of AttributeValues.
 
Method Summary
 boolean add(AttributeValues newAttribute)
          Add a new attribute to the set.
protected  java.lang.Object clone()
           
 boolean contains(java.lang.String id)
          Determines if the set contains an AttriubuteValue with a given ID.
 void debugOutput()
           
 void filterOut(java.lang.String id, java.util.List<java.lang.String> values)
          Filters out Attribute Values from this set.
 AttributeValues get(java.lang.String id)
          Return an attribute from the set.
 AttributeNameMapper getAttributeNameMapper()
           
 java.util.Set<java.lang.String> getAttributeNames()
          Get all attribute IDs.
 java.util.List<AttributeValues> getAttributeValues()
          Get all AttributeValues.
 AttributeValues remove(java.lang.String id)
          Remove an attribute from the set.
 void setAttributeNameMapper(AttributeNameMapper attributeNameMapper)
           
 int size()
          Returns the size of the set.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ATTRIBUTENAMESPACE

private static java.lang.String DEFAULT_ATTRIBUTENAMESPACE
Default attributeNameSpace. This default namespace is set in the AttributeValues when no explicit namespace is set.


attributes

private java.util.Map<java.lang.String,AttributeValues> attributes
Map for storing Attributes.


attributeNameMapper

private AttributeNameMapper attributeNameMapper
AttributeNameMapper which is used to manage attribute name mappings.


serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

log

private org.apache.log4j.Logger log
Constructor Detail

AttributeSet

public AttributeSet()
Creates an empty set. This constructor sets the name mapper to the NoopAttributeNameMapper implementation.


AttributeSet

public AttributeSet(AttributeNameMapper mapper)
Creates an empty set with the specified AttributeNameMapper.

Parameters:
mapper -

AttributeSet

public AttributeSet(java.util.List<AttributeValues> attributeList)
Creates a set from a list of AttributeValues. This constructor sets the name mapper to the NoopAttributeNameMapper implementation.

Parameters:
attributeList -

AttributeSet

public AttributeSet(java.util.List<AttributeValues> attributeList,
                    AttributeNameMapper mapper)
Creates a set from a list of AttributeValues. This constructor also takes care of attribute mappings.

Parameters:
attributeList - list of AttributeValues
mapper - specific AttributeNameMapper implementation to use
Method Detail

add

public boolean add(AttributeValues newAttribute)
Add a new attribute to the set. New attribute values are merged with old ones.

Parameters:
newAttribute - attributeValue to add.
Returns:
true if internal attributes were modified by this call.

remove

public AttributeValues remove(java.lang.String id)
Remove an attribute from the set.

Parameters:
id - ID of the attribute to be removed
Returns:
AttributeValue value

get

public AttributeValues get(java.lang.String id)
Return an attribute from the set.

Parameters:
id - ID of the attribute
Returns:
AttributeValue value

contains

public boolean contains(java.lang.String id)
Determines if the set contains an AttriubuteValue with a given ID.

Parameters:
id - Attribute ID
Returns:
true if such an attribute is found

size

public int size()
Returns the size of the set.

Returns:

getAttributeNames

public java.util.Set<java.lang.String> getAttributeNames()
Get all attribute IDs.

Returns:
Set of attribute IDs in the set

getAttributeValues

public java.util.List<AttributeValues> getAttributeValues()
Get all AttributeValues.

Returns:
List of the AttributeValues

filterOut

public void filterOut(java.lang.String id,
                      java.util.List<java.lang.String> values)
Filters out Attribute Values from this set. This filtering is done by removing single values. If all values are removed, the AttributeValue itself is removed from the set.

Parameters:
id - String identifier of the attribute
values - List Removable values of the attribute

getAttributeNameMapper

public AttributeNameMapper getAttributeNameMapper()

setAttributeNameMapper

public void setAttributeNameMapper(AttributeNameMapper attributeNameMapper)

clone

protected java.lang.Object clone()
Overrides:
clone in class java.lang.Object

debugOutput

public void debugOutput()