com.sap.security.api
Class AttributeList

java.lang.Object
  |
  +--com.sap.security.api.AttributeList
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class AttributeList
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Class AttributeList is used to define specific attributes which can be used to populate an IPrincipal object. If you know in advance which attributes you want to access use this class to define the used attributes. You will have better performance and less communication with the server if you specify the desired attributes. The object is NOT synchronized, which means that one has to expect runtime exceptions like ConcurrentModificationException or ArrayIndexOutOfBoundsException when the same instance of a AttributeList object is used in more than one thread in parallel. Note: Reuse of a AttributeList object which was already used to get a principal from a factory is not supported. The factory might change the content of the passed AttributeList object.

See Also:
Serialized Form

Field Summary
protected  java.util.ArrayList attributes
           
protected  java.util.HashSet fastAccess
           
protected  boolean mCheckSizeLimit
           
static int TYPE_BLOB
          TYPE_BLOB is returned by getAttributeType(String, String) if the type of the values of an attribute is of type byte[]
static int TYPE_STRING
          TYPE_STRING is returned by getAttributeType(String, String) if the type of the values of an attribute is of type String
static int TYPE_UNKNOWN
          TYPE_UNKNOWN is returned by getAttributeType(String, String) if the type of the values of an attribute cannot be determined
static java.lang.String VERSIONSTRING
           
 
Constructor Summary
AttributeList()
          Default constructor of AttributeList.
AttributeList(boolean checkSizeLimit)
          Constructor of AttributeList.
 
Method Summary
 void addAttribute(java.lang.String nameSpace, java.lang.String attributeName)
          Add an attribute to this instance of AttributeList with following properties Note: A AttributeList can only contain 25 attributes.
 void addAttribute(java.lang.String nameSpace, java.lang.String attributeName, int type)
          Add an attribute to this instance of AttributeList with following properties
 void addAttributeList(AttributeList populateAttributes)
          Add attributes to this instance of AttributeList
 java.lang.Object clone()
          Returns a new instance of AttributeList which contains the same data as this instance.
 boolean containsAttribute(java.lang.String nameSpace, java.lang.String attributeName)
           
 boolean containsAttribute(java.lang.String nameSpace, java.lang.String attributeName, int type)
          Returns whether an attribute is contained in this instance of AttributeList with following properties
 boolean equals(java.lang.Object obj)
          used to compare instances of AttributeList
 java.lang.String getAttributeNameOfAttributeAt(int index)
          Returns the name of an attribute at a given index in this attributeList
 int getAttributeType(java.lang.String nameSpace, java.lang.String attributeName)
          returns the type of the attribute of this instance of AttributeList.
 int getAttributeTypeOfAttributeAt(int index)
          returns the type of the attribute of this instance of AttributeList.
 java.lang.String getNameSpaceOfAttributeAt(int index)
          Returns the namespace of an attribute at a given index in this attributeList
 AttributeList getNotContainedAttributes(AttributeList populateAttributes)
          Returns a new instance of AttributeList which contains all attributes which are contained in the passed AttributeList, but not contained in this instance.
 int getSize()
          Returns the number of components in this attributeList
 int hashCode()
           
 boolean isSubsetOf(AttributeList populateAttributes)
          Returns a whether this AttributeList is a subset of the given AttributeList
 void removeAttribute(java.lang.String nameSpace, java.lang.String attributeName)
          Removes an attribute from this instance of AttributeList with following properties
 java.lang.String toString()
          Returns a string representation of this AttributeList.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSIONSTRING

public static final java.lang.String VERSIONSTRING

TYPE_UNKNOWN

public static final int TYPE_UNKNOWN
TYPE_UNKNOWN is returned by getAttributeType(String, String) if the type of the values of an attribute cannot be determined

TYPE_STRING

public static final int TYPE_STRING
TYPE_STRING is returned by getAttributeType(String, String) if the type of the values of an attribute is of type String

TYPE_BLOB

public static final int TYPE_BLOB
TYPE_BLOB is returned by getAttributeType(String, String) if the type of the values of an attribute is of type byte[]

attributes

protected java.util.ArrayList attributes

fastAccess

protected java.util.HashSet fastAccess

mCheckSizeLimit

protected boolean mCheckSizeLimit
Constructor Detail

AttributeList

public AttributeList()
Default constructor of AttributeList. An empty instance of AttributeList is ignored during population of an IPrincipal object. You have to use addAttribute(String, String) to add attributes

AttributeList

public AttributeList(boolean checkSizeLimit)
Constructor of AttributeList. An empty instance of AttributeList is ignored during population of an IPrincipal object. You have to use addAttribute(String, String)to add attributes
Parameters:
checkSizeLimit - specifies whether the size limit of 25 attributes should be checked
Method Detail

equals

public boolean equals(java.lang.Object obj)
used to compare instances of AttributeList
Overrides:
equals in class java.lang.Object
Parameters:
obj - object which should be compared with this instance
Returns:
true if objects are identical, false otherwise

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getAttributeTypeOfAttributeAt

public int getAttributeTypeOfAttributeAt(int index)
returns the type of the attribute of this instance of AttributeList.
Parameters:
index - index of attribute in AttributeList
Returns:
following constants: TYPE_UNKNOWN, TYPE_STRING, TYPE_BLOB

getAttributeType

public int getAttributeType(java.lang.String nameSpace,
                            java.lang.String attributeName)
returns the type of the attribute of this instance of AttributeList.
Parameters:
nameSpace - namespace of the attribute
attributeName - name of the attribute
Returns:
following constants: TYPE_UNKNOWN, TYPE_STRING, TYPE_BLOB

removeAttribute

public void removeAttribute(java.lang.String nameSpace,
                            java.lang.String attributeName)
Removes an attribute from this instance of AttributeList with following properties
Parameters:
nameSpace - namespace of the attribute
attributeName - name of the attribute

containsAttribute

public boolean containsAttribute(java.lang.String nameSpace,
                                 java.lang.String attributeName,
                                 int type)
Returns whether an attribute is contained in this instance of AttributeList with following properties
Parameters:
nameSpace - namespace of the attribute
attributeName - name of the attribute
type - the attribute type
Returns:
boolean: true if this instance contains this attribute, otherwise false

containsAttribute

public boolean containsAttribute(java.lang.String nameSpace,
                                 java.lang.String attributeName)

addAttribute

public void addAttribute(java.lang.String nameSpace,
                         java.lang.String attributeName)
Add an attribute to this instance of AttributeList with following properties Note: A AttributeList can only contain 25 attributes.
Parameters:
nameSpace - namespace of the attribute
attributeName - name of the attribute
Throws:
UMRuntimeException - if the AttributeList already contains 25 attributes.

addAttribute

public void addAttribute(java.lang.String nameSpace,
                         java.lang.String attributeName,
                         int type)
Add an attribute to this instance of AttributeList with following properties
Parameters:
nameSpace - namespace of the attribute
attributeName - name of the attribute
type - of the attribute. Following constants are allowed: TYPE_UNKNOWN, TYPE_STRING, TYPE_BLOB
Throws:
UMRuntimeException - if the AttributeList already contains 25 attributes.

addAttributeList

public void addAttributeList(AttributeList populateAttributes)
Add attributes to this instance of AttributeList
Parameters:
populateAttributes - instance of another AttributeList which is used to copy the attributes into this instance
Throws:
UMRuntimeException - if the AttributeList already contains 25 attributes.

isSubsetOf

public boolean isSubsetOf(AttributeList populateAttributes)
Returns a whether this AttributeList is a subset of the given AttributeList
Returns:
true if this AttributeList is a subset of the given AttributeList or false if this AttributeList is empty or the passed AttributeList is null

getNotContainedAttributes

public AttributeList getNotContainedAttributes(AttributeList populateAttributes)
Returns a new instance of AttributeList which contains all attributes which are contained in the passed AttributeList, but not contained in this instance.
Returns:
Object: the new AttributeList instance

clone

public java.lang.Object clone()
Returns a new instance of AttributeList which contains the same data as this instance.
Overrides:
clone in class java.lang.Object
Returns:
Object: the new AttributeList instance

getSize

public int getSize()
Returns the number of components in this attributeList

getNameSpaceOfAttributeAt

public java.lang.String getNameSpaceOfAttributeAt(int index)
Returns the namespace of an attribute at a given index in this attributeList
Returns:
String: name of attribute's namespace

getAttributeNameOfAttributeAt

public java.lang.String getAttributeNameOfAttributeAt(int index)
Returns the name of an attribute at a given index in this attributeList
Parameters:
index - given index in attributeList
Returns:
String: name of attribute at given index

toString

public java.lang.String toString()
Returns a string representation of this AttributeList. Containing the String representation of each element.
Overrides:
toString in class java.lang.Object