com.tivoli.mts
Class PDAttrs

java.lang.Object
  |
  +--com.tivoli.mts.PDAttrs
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

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

This class represents what would be known in the C APIs of Policy Director as an Attrlist, or attribute list. The individual attributes have String names. Values for an attribute may either be Strings or byte arrays. PDAttrs allows an attribute to have more than one value, so attempting to add a value to a name that already has been added to a PDAttrs will result in a multi-valued attribute.

Since:
PD 3.8
Author:
Bruce A Rich
See Also:
Serialized Form

Constructor Summary
PDAttrs()
          Constructs a new, empty map with default capacity and load factor, which is 0.75.
PDAttrs(int initialCapacity)
          Constructs a new, empty map with the specified initial capacity and default load factor, which is 0.75.
PDAttrs(int initialCapacity, float loadFactor)
          Constructs a new, empty map with the specified initial capacity and the specified load factor.
PDAttrs(PDAttrs that)
          Constructs a new PDAttrs containing the elements in the specified PDAttrs.
 
Method Summary
 java.util.Collection add(java.lang.String name, byte[] value)
          Associates the specified value with the specified name in this PDAttrs.
 java.util.Collection add(java.lang.String name, PDAttrValues vals)
          Associates the specified values with the specified name in this PDAttrs.
 java.util.Collection add(java.lang.String name, java.lang.String value)
          Associates the specified value with the specified name in this PDAttrs.
 void addAll(PDAttrs attrs)
          Adds all of the elements in the specified PDAttrs to this PDAttrs.
 void clear()
          Clear the current PDAttrs.
 java.lang.Object clone()
          Clone the current PDAttrs.
 boolean delete(java.lang.String key)
          Remove the named attribute from the PDAttrs.
 byte[] encode()
           
 java.util.Set entrySet()
          Return a Set view of the entries in the PDAttrs.
 boolean equals(java.lang.Object obj)
          Indicates whether some other Object is equal to this one.
 PDAttrValues get(java.lang.String key)
          Returns the value(s) to which this PDAttrs maps the specified key.
 int getQoP()
          Returns the current value of QoP
 int hashCode()
          Returns a hashcode for the current object.
 java.util.Set keySet()
          Returns a set view of the keys contained in this PDAttrs.
 void setQoP(int qop)
          Sets the current value of QoP
 int size()
          Returns the number of key-values mappings in the current PDAttrs.
 java.lang.String toString()
          Return a string version of this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PDAttrs

public PDAttrs()
Constructs a new, empty map with default capacity and load factor, which is 0.75.

PDAttrs

public PDAttrs(int initialCapacity)
Constructs a new, empty map with the specified initial capacity and default load factor, which is 0.75.

PDAttrs

public PDAttrs(int initialCapacity,
               float loadFactor)
Constructs a new, empty map with the specified initial capacity and the specified load factor.

PDAttrs

public PDAttrs(PDAttrs that)
        throws java.lang.NullPointerException,
               java.lang.ClassCastException
Constructs a new PDAttrs containing the elements in the specified PDAttrs.
Parameters:
that - the PDAttrs whose elements are to be placed into this PDAttrs
Throws:
java.lang.NullPointerException - if no PDAttrs is passed in
java.lang.ClassCastException - if one or more of the elements in the PDAttrs to be added are not PDAttr objects
Method Detail

add

public java.util.Collection add(java.lang.String name,
                                PDAttrValues vals)
Associates the specified values with the specified name in this PDAttrs. If this PDAttrs previously contained values for this name, then the input values are added to the values already known for that name.
Parameters:
name - the name of the attribute
vals - the new values to be associated with that name
Returns:
the previous values associated with the name, or null if no values were previously known for that attribute.
Throws:
java.lang.NullPointerException - on parameter errors.

add

public java.util.Collection add(java.lang.String name,
                                java.lang.String value)
Associates the specified value with the specified name in this PDAttrs. If this PDAttrs previously contained values for this name, then the input value is added to the values already known for that name.
Parameters:
name - the name of the attribute
value - the new value to be associated with that name
Returns:
the previous values associated with the name, or null if no values were previously known for that attribute.
Throws:
java.lang.NullPointerException - on parameter errors.

add

public java.util.Collection add(java.lang.String name,
                                byte[] value)
Associates the specified value with the specified name in this PDAttrs. If this PDAttrs previously contained values for this name, then the input value is added to the values already known for that name. Note that if the value is mutable, it is cloned before being entered in the PDAttrs.
Parameters:
name - the name of the attribute
value - the new value to be associated with that name
Returns:
the previous values associated with the name, or null if no values were previously known for that attribute.
Throws:
java.lang.NullPointerException - on parameter errors.

addAll

public void addAll(PDAttrs attrs)
            throws java.lang.NullPointerException,
                   java.lang.ClassCastException
Adds all of the elements in the specified PDAttrs to this PDAttrs. The behavior of this operation is undefined if the specified PDAttrs is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified PDAttrs is this PDAttrs, and this PDAttrs is nonempty.) This implementation iterates over the specified PDAttrs, and adds each PDAttr returned by the iterator to this map, in turn.
Throws:
java.lang.NullPointerException - if no PDAttrs is passed

clear

public void clear()
Clear the current PDAttrs. Remove all mappings in the current PDAttrs, reset QoP to zero, and reset the version number to the current supported level.

delete

public boolean delete(java.lang.String key)
Remove the named attribute from the PDAttrs.
Parameters:
key - the name of the attribute to be removed.
Returns:
true if the attribute was in the PDAttrs

clone

public java.lang.Object clone()
Clone the current PDAttrs. This is implemented as a deep copy.
Overrides:
clone in class java.lang.Object

entrySet

public java.util.Set entrySet()
Return a Set view of the entries in the PDAttrs. Modifications to the Set will result in modifications to the underlying PDAttrs.
Returns:
a Set containing the entries in the PDAttrs

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other Object is equal to this one. In particular, this implementation checks that the QoP and versions are the same, and then defers to the HashMap.equals check, which will devolve into a containsAll check on the current set of PDAttr.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to be compared to this one
Returns:
true if the PDAttrs are identical, false otherwise.

get

public PDAttrValues get(java.lang.String key)
Returns the value(s) to which this PDAttrs maps the specified key. Returns null if the PDAttrs contains no mapping for the specified key.
Parameters:
key - key whose associated value(s) is/are to be returned.
Returns:
the value(s) to which this PDAttrs maps the specified key.

getQoP

public int getQoP()
Returns the current value of QoP
Returns:
the current value of QoP

hashCode

public int hashCode()
Returns a hashcode for the current object.
Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode for the current object.

keySet

public java.util.Set keySet()
Returns a set view of the keys contained in this PDAttrs. The set is backed by the map, so changes to the PDAttrs are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding mapping from this PDAttrs, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
Returns:
a set view of the keys contained in this PDAttrs.

setQoP

public void setQoP(int qop)
            throws java.lang.IllegalArgumentException
Sets the current value of QoP
Throws:
java.lang.IllegalArgumentException - if the QoP value is unknown

size

public int size()
Returns the number of key-values mappings in the current PDAttrs. Note that is equivalent to the number of keys in the PDAttrs, not the number of values, as a multivalue key counts as only one key.
Returns:
the number of key-values mappings in the current PDAttrs.

toString

public java.lang.String toString()
Return a string version of this object.
Overrides:
toString in class java.lang.Object
Returns:
a String representing this object

encode

public byte[] encode()