Project Aristotle - ArisID Attribute Services

org.openliberty.arisid
Class AttributeValue

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<java.lang.String>
              extended by org.openliberty.arisid.AttributeValue
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.lang.String>, java.util.Collection<java.lang.String>, java.util.List<java.lang.String>, java.util.RandomAccess, IAttributeValue
Direct Known Subclasses:
AttributeFilterValue

public class AttributeValue
extends java.util.ArrayList<java.lang.String>
implements IAttributeValue

AttributeValue is used to hold values returned from an attribute authority. An AttributeValue usually represents one returned attribute in a DigitalSubject. All String values are UTF-8 encoded. The AttributeValue will also hold IGF meta response data for an attribute. TODO Add IGF meta data response information TODO How to encode and handle multi-byte data.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.openliberty.arisid.IAttributeValue
VALUE_TYPE_EMPTY, VALUE_TYPE_MULTI, VALUE_TYPE_SINGLE, VALUE_TYPE_UNDEFINED
 
Constructor Summary
AttributeValue(AttributeDef attr, java.lang.Exception error)
          This constructor is used when an exception has occurred and typically no values are present.
AttributeValue(AttributeDef attr, java.util.List<java.lang.String> vals)
          This constructor is typically used to set the values for a DigitalSubject or an AttributeFilter
AttributeValue(AttributeDef attr, java.lang.String value)
          This constructor is typically used to set the values for a DigitalSubject or an AttributeFilter
AttributeValue(java.lang.String attrRefId)
          Creates an instance of an IAttributeValue using an Attribute Reference Identifier (the name of a declared attribute).
AttributeValue(java.lang.String name, java.lang.Exception error)
          This constructor is used when an exception has occurred and typically no values are present.
AttributeValue(java.lang.String attrId, java.util.List<java.lang.String> vals)
          This constructor is typically used to set the values for a DigitalSubject or an AttributeFilter
AttributeValue(java.lang.String attrId, java.lang.String value)
          This constructor is typically used to set the values for a DigitalSubject
 
Method Summary
 void add(int index, java.lang.String element)
           
 boolean add(java.lang.String o)
          Add a String value to the list of values.
 boolean addAll(java.util.Collection<? extends java.lang.String> c)
           
 boolean addAll(int index, java.util.Collection<? extends java.lang.String> c)
           
 boolean addBinary(byte[] value)
          Adds a binary value to the list of Attribute Values.
static byte[] base64Decode(java.lang.String value)
          Returns the Base64 decoded value (binary value) for a Base64 encoded string
static java.lang.String base64Encode(byte[] value)
          Returns the Base64 encoded string for a given binary value
 boolean compare(java.lang.String val)
           
 boolean compareAttributeValueExact(AttributeValue val)
          Deprecated. Use compareValueExact(IAttributeValue) instead
 boolean compareAttributeValueIgnoreCaseExact(AttributeValue val)
          Deprecated. Use compareValueIgnoreCaseExact(IAttributeValue) instead
 boolean compareIgnoreCase(java.lang.String val)
           
 boolean compareValueExact(IAttributeValue val)
          All values in the current object must match values in the supplied array.
 boolean compareValueIgnoreCaseExact(IAttributeValue val)
           
 boolean contains(java.lang.String value)
          Tests whether the specified value is contained.
 boolean containsBinary(byte[] value)
          Tests whether the specified binary value is contained.
 boolean equals(java.lang.Object obj)
           
 byte[] getBinary(int i)
          Returns a value in binary form.
 java.lang.Object[] getBinaryValues()
           
 java.lang.Exception getError()
          Returns the error associated with the value if present
 java.lang.String getNameIdRef()
          Returns the Attribute associated with the value as declared in CARML
 IPolicy getPolicy()
          Returns dynamic WS-Policy constraints that are to be applied to the value.
 int getValueType()
          Returns whether the value is either undefined, empty, contains single or multiple values.
 int hashCode()
           
 boolean isError()
          Returns whether the current entity has an error condition.
 boolean isUndefined()
          Returns whether the current value is undefined.
 byte[] removeBinary(int i)
          Removes the i th element and returns the binary value removed.
 void setPolicy(IPolicy policy)
          Allows dynamic privacy policy constraints to be applied in the form of a WS-Policy.
 java.lang.String toString()
           
 
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openliberty.arisid.IAttributeValue
get, iterator, remove, size
 
Methods inherited from interface java.util.List
containsAll, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

AttributeValue

public AttributeValue(java.lang.String attrRefId)
Creates an instance of an IAttributeValue using an Attribute Reference Identifier (the name of a declared attribute). When this constructor is used, the AttributeValue will initially have the state of "undefined" until one of the add(String) or addAll(Collection) methods is called. To create an empty AttributeValue use the constructor AttributeValue(String, List) with an empty list parameter.

Parameters:
attrRefId - The attribute definition that this AttributeValue is based on.

AttributeValue

public AttributeValue(AttributeDef attr,
                      java.util.List<java.lang.String> vals)
This constructor is typically used to set the values for a DigitalSubject or an AttributeFilter

Parameters:
attr - The attribute definition (AttributeDef)
vals - String value(s) of the attribute. Passing a null shall mean that the AttributeValue is "undefined" (see isUndefined()).

AttributeValue

public AttributeValue(AttributeDef attr,
                      java.lang.String value)
This constructor is typically used to set the values for a DigitalSubject or an AttributeFilter

Parameters:
attr - The Attribute definition of the attribute being returned
value - A single value for the attribute. Passing a null shall mean that the AttributeValue is "undefined" (see isUndefined()).

AttributeValue

public AttributeValue(java.lang.String attrId,
                      java.util.List<java.lang.String> vals)
This constructor is typically used to set the values for a DigitalSubject or an AttributeFilter

Parameters:
attrId - The attribute definition name id.
vals - String value(s) of the attribute. Passing a null shall mean that the AttributeValue is "undefined" (see isUndefined()).

AttributeValue

public AttributeValue(java.lang.String attrId,
                      java.lang.String value)
This constructor is typically used to set the values for a DigitalSubject

Parameters:
attrId - The attribute definition name id.
value - A single value for the attribute. Passing a null shall mean that the AttributeValue is "undefined" (see isUndefined()).

AttributeValue

public AttributeValue(java.lang.String name,
                      java.lang.Exception error)
This constructor is used when an exception has occurred and typically no values are present.

Parameters:
name - The name of the attribute being returned.
error - The exception (typically IGFException) that occurred preventing returning the attribute result

AttributeValue

public AttributeValue(AttributeDef attr,
                      java.lang.Exception error)
This constructor is used when an exception has occurred and typically no values are present.

Parameters:
attr - The definition of the attribute being returned.
error - The exception (typically IGFException) that occurred preventing returning the attribute result
Method Detail

isError

public boolean isError()
Description copied from interface: IAttributeValue
Returns whether the current entity has an error condition. Note: the presence of an error does not mean there are not values present.

Specified by:
isError in interface IAttributeValue
Returns:
The error condition that occured during construction of the value.

isUndefined

public boolean isUndefined()
Description copied from interface: IAttributeValue
Returns whether the current value is undefined. For example, see constructors for AttributeValue.

Specified by:
isUndefined in interface IAttributeValue
Returns:
true if no value has been defined (as opposed to just an empty set).

getError

public java.lang.Exception getError()
Description copied from interface: IAttributeValue
Returns the error associated with the value if present

Specified by:
getError in interface IAttributeValue
Returns:
the exception or null if no error present.

getNameIdRef

public java.lang.String getNameIdRef()
Description copied from interface: IAttributeValue
Returns the Attribute associated with the value as declared in CARML

Specified by:
getNameIdRef in interface IAttributeValue
Returns:
A String containing the Attribute name identifier.

getBinaryValues

public java.lang.Object[] getBinaryValues()

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection<java.lang.String>
Specified by:
hashCode in interface java.util.List<java.lang.String>
Overrides:
hashCode in class java.util.AbstractList<java.lang.String>

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Collection<java.lang.String>
Specified by:
equals in interface java.util.List<java.lang.String>
Specified by:
equals in interface IAttributeValue
Overrides:
equals in class java.util.AbstractList<java.lang.String>

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractCollection<java.lang.String>

compareAttributeValueExact

public boolean compareAttributeValueExact(AttributeValue val)
Deprecated. Use compareValueExact(IAttributeValue) instead

All values in the current object must match values in the supplied array. Order of values is not exact

Parameters:
val - An AttributeValue object to be compared containing one or more values
Returns:
true if the filter value matches at least one of the attribute values;

compareValueExact

public boolean compareValueExact(IAttributeValue val)
All values in the current object must match values in the supplied array. Order of values is not exact

Specified by:
compareValueExact in interface IAttributeValue
Parameters:
val - An AttributeValue object to be compared containing one or more values
Returns:
true if the filter value matches at least one of the attribute values;

compareAttributeValueIgnoreCaseExact

public boolean compareAttributeValueIgnoreCaseExact(AttributeValue val)
Deprecated. Use compareValueIgnoreCaseExact(IAttributeValue) instead

Parameters:
val - An AttributeValue object to be compared containing one or more values
Returns:
true if the filter value matches at least one of the attribute values;

compareValueIgnoreCaseExact

public boolean compareValueIgnoreCaseExact(IAttributeValue val)
Specified by:
compareValueIgnoreCaseExact in interface IAttributeValue
Parameters:
val - An AttributeValue object to be compared containing one or more values
Returns:
true if the filter value matches at least one of the attribute values;

compare

public boolean compare(java.lang.String val)
Specified by:
compare in interface IAttributeValue
Parameters:
val - to be compared
Returns:
true if the String representation of the values are a match. This is the String version of IAttributeValue.compareValueExact(IAttributeValue).

compareIgnoreCase

public boolean compareIgnoreCase(java.lang.String val)

getValueType

public int getValueType()
Description copied from interface: IAttributeValue
Returns whether the value is either undefined, empty, contains single or multiple values.

Specified by:
getValueType in interface IAttributeValue
Returns:
an integer as defined by the constants IAttributeValue.VALUE_TYPE_UNDEFINED, IAttributeValue.VALUE_TYPE_EMPTY, IAttributeValue.VALUE_TYPE_SINGLE, or IAttributeValue.VALUE_TYPE_MULTI.

add

public void add(int index,
                java.lang.String element)
Specified by:
add in interface java.util.List<java.lang.String>
Overrides:
add in class java.util.ArrayList<java.lang.String>

add

public boolean add(java.lang.String o)
Description copied from interface: IAttributeValue
Add a String value to the list of values.

Specified by:
add in interface java.util.Collection<java.lang.String>
Specified by:
add in interface java.util.List<java.lang.String>
Specified by:
add in interface IAttributeValue
Overrides:
add in class java.util.ArrayList<java.lang.String>
Returns:
true if added successfully.

addAll

public boolean addAll(java.util.Collection<? extends java.lang.String> c)
Specified by:
addAll in interface java.util.Collection<java.lang.String>
Specified by:
addAll in interface java.util.List<java.lang.String>
Overrides:
addAll in class java.util.ArrayList<java.lang.String>

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends java.lang.String> c)
Specified by:
addAll in interface java.util.List<java.lang.String>
Overrides:
addAll in class java.util.ArrayList<java.lang.String>

setPolicy

public void setPolicy(IPolicy policy)
Description copied from interface: IAttributeValue
Allows dynamic privacy policy constraints to be applied in the form of a WS-Policy.

Specified by:
setPolicy in interface IAttributeValue
Parameters:
policy - Privacy constraints in a WS-Policy (IPolicy) container. To parse/set dynamic constraints, use the PolicyHandler class.

getPolicy

public IPolicy getPolicy()
Description copied from interface: IAttributeValue
Returns dynamic WS-Policy constraints that are to be applied to the value. On an outbound request it applies to constraints being sent to an attribute authority. In a response, such a from DigitalSubject.getAttributeValue(String), it contains transactional constraints specified by the attribute authority.

Specified by:
getPolicy in interface IAttributeValue
Returns:
Privacy constraints in a WS-Policy (IPolicy) container. To parse/set transactional constraints, use the PolicyHandler class.

contains

public boolean contains(java.lang.String value)
Description copied from interface: IAttributeValue
Tests whether the specified value is contained.

Specified by:
contains in interface IAttributeValue
Returns:
true if a match is located based on the String value.

base64Encode

public static java.lang.String base64Encode(byte[] value)
Returns the Base64 encoded string for a given binary value

Parameters:
value - Binary Value to be encoded in byte array
Returns:
Base64 encoded String

base64Decode

public static byte[] base64Decode(java.lang.String value)
Returns the Base64 decoded value (binary value) for a Base64 encoded string

Parameters:
value - Base64 encoded string
Returns:
binary value in byte array

addBinary

public boolean addBinary(byte[] value)
Description copied from interface: IAttributeValue
Adds a binary value to the list of Attribute Values. The byte[] array will be stored as a base64 encoded string.

Specified by:
addBinary in interface IAttributeValue
Returns:
true if the value was Added.

containsBinary

public boolean containsBinary(byte[] value)
Description copied from interface: IAttributeValue
Tests whether the specified binary value is contained.

Specified by:
containsBinary in interface IAttributeValue
Returns:
true if a match is located based on a base64 encoding of the byte[] value.

getBinary

public byte[] getBinary(int i)
Description copied from interface: IAttributeValue
Returns a value in binary form. The method does a base64 deocde of the stored string value.

Specified by:
getBinary in interface IAttributeValue
Parameters:
i - The element to return (where 0 is the first element)
Returns:
A byte[] array containing the original binary value.

removeBinary

public byte[] removeBinary(int i)
Description copied from interface: IAttributeValue
Removes the i th element and returns the binary value removed.

Specified by:
removeBinary in interface IAttributeValue
Parameters:
i - The element to remove (where 0 is the first)
Returns:
The binary value of the element removed

OpenLiberty.org - Licensed under Apache APL 2.0