Class AttributeList
- java.lang.Object
-
- com.ibm.oauth.core.api.attributes.AttributeList
-
public class AttributeList extends java.lang.Object
An ordered list of attributes used throughout the component to communicate full state and information in OAuth request and response. An attribute will be uniquely identified in the list by its name and type. Therefore an attribute list cannot have two attributes with the same name and type.
-
-
Constructor Summary
Constructors Constructor Description AttributeList()
One and only constructor which builds a new empty list of attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Attribute>
getAllAttributes()
Gets all attributes in the attribute list.Attribute
getAttributeByNameAndType(java.lang.String name, java.lang.String type)
Returns a reference to an attribute within the attribute list identified by its name and type.Attribute[]
getAttributesByType(java.lang.String type)
Returns an array of attributes from the list that match a given type.java.lang.String
getAttributeValueByName(java.lang.String name)
Returns the first string value of an attribute from the attribute list identified by its name only.java.lang.String
getAttributeValueByNameAndType(java.lang.String name, java.lang.String type)
Returns the first string value of an attribute from the attribute list identified by its name and type.java.lang.String[]
getAttributeValuesByName(java.lang.String name)
Returns the list of string values (as a string array) of an attribute from the attribute list identified by its name only.java.lang.String[]
getAttributeValuesByNameAndType(java.lang.String name, java.lang.String type)
Returns the list of string values (as a string array) of an attribute from the attribute list identified by its name and type.void
setAttribute(java.lang.String name, java.lang.String type, java.lang.String[] values)
Set the values of an attribute in the attribute list identified by name and type.java.lang.String
toString()
String representation of the attribute list useful for debug tracing.
-
-
-
Method Detail
-
getAttributeValueByNameAndType
public java.lang.String getAttributeValueByNameAndType(java.lang.String name, java.lang.String type)
Returns the first string value of an attribute from the attribute list identified by its name and type. Name and type checking are done as string comparisons. If the type of an attribute is not defined (null) then it will ONLY match if the requested type is also null. Similarly if the requested type is null, only attributes with a null (undefined) type will be matched.- Parameters:
name
- name of attributetype
- type of attribute- Returns:
- first string value of a matching attribute from the attribute list or null if no matching attribute
-
getAttributeValueByName
public java.lang.String getAttributeValueByName(java.lang.String name)
Returns the first string value of an attribute from the attribute list identified by its name only. If more than one attribute in the attribute list has the same name (and different types), the first value of the first matching attribute will be returned.- Parameters:
name
- name of attribute- Returns:
- first string value of a matching attribute from the attribute list or null if no matching attribute
-
getAttributeValuesByNameAndType
public java.lang.String[] getAttributeValuesByNameAndType(java.lang.String name, java.lang.String type)
Returns the list of string values (as a string array) of an attribute from the attribute list identified by its name and type. Name and type checking are done as string comparisons. If the type of an attribute is not defined (null) then it will ONLY match if the requested type is also null. Similarly if the requested type is null, only attributes with a null (undefined) type will be matched.- Parameters:
name
- name of attributetype
- type of attribute- Returns:
- string array of values of a matching attribute from the attribute list or null if no matching attribute
-
getAttributeValuesByName
public java.lang.String[] getAttributeValuesByName(java.lang.String name)
Returns the list of string values (as a string array) of an attribute from the attribute list identified by its name only. If more than one attribute in the attribute list has the same name (and different types), the values of the first matching attribute will be returned.- Parameters:
name
- name of attribute- Returns:
- string array of values of a matching attribute from the attribute list or null if no matching attribute
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.String type, java.lang.String[] values)
Set the values of an attribute in the attribute list identified by name and type. If an existing attribute with that name and type already appears in the attribute list its values will be replaced otherwise a new attribute will be appended to the list.- Parameters:
name
- - name of attribute to update/addtype
- - type of attribute to update/addvalues
- - array of string values of attribute to update/add
-
getAttributeByNameAndType
public Attribute getAttributeByNameAndType(java.lang.String name, java.lang.String type)
Returns a reference to an attribute within the attribute list identified by its name and type. If the attribute is modified, it will be modified in the list. If no attribute with that name and type exists in the list, returns null.- Parameters:
name
- - name of attributetype
- - type of attribute- Returns:
- reference to the attribute in the list, or null if an attribute with that name and type cannot be located.
-
getAttributesByType
public Attribute[] getAttributesByType(java.lang.String type)
Returns an array of attributes from the list that match a given type. Each attribute is a reference so any modifications to attributes returned in the array will be reflected in the attribute list.- Parameters:
type
- type of attribute to match- Returns:
- an array of attributes that match the given type, or null if there are no attributes with that type in the list.
-
getAllAttributes
public java.util.List<Attribute> getAllAttributes()
Gets all attributes in the attribute list.- Returns:
- a list of attributes
-
toString
public java.lang.String toString()
String representation of the attribute list useful for debug tracing.- Overrides:
toString
in classjava.lang.Object
-
-