com.tivoli.pd.jutil
Class PDAttrs

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

public class PDAttrs
extends com.tivoli.pd.jutil.PDEnvironmentObject
implements java.lang.Cloneable, java.io.Serializable

This class represents what would is 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. PDAttrs, if constructed to do so, will allow duplicate entries in the multi-valued attributes.

See Also:
Serialized Form

Constructor Summary
PDAttrs(PDAttrs that)
          Constructs a new PDAttrs containing the elements in the specified PDAttrs.
PDAttrs(com.tivoli.pd.jutil.PDBasicContext context)
          Constructs a new, empty PDAttrs with the specified initial capacity and default load factor, which is 0.75.
PDAttrs(com.tivoli.pd.jutil.PDBasicContext context, com.tivoli.pd.jasn1.attrlist_t alt)
           
PDAttrs(com.tivoli.pd.jutil.PDBasicContext context, boolean allowDuplicates)
          Constructs a new, empty PDAttrs that specifies whether the value for each attribute can consist of an unordered list that allows duplicate items.
PDAttrs(com.tivoli.pd.jutil.PDBasicContext context, byte[] serverData)
          Creates a PDAttrs from the data returned from the Policy Director server.
 
Method Summary
 java.util.Collection add(java.lang.String name, byte[] value)
          Adds the specified byte array value to the collection of values for the specified name in this PDAttrs.
 java.util.Collection add(java.lang.String name, java.util.Collection vals)
          Associates the specified values with the specified name in this PDAttrs.
 java.util.Collection add(java.lang.String name, java.lang.Long value)
          Adds the specified Long value to the collection of values for the specified name in this PDAttrs.
 java.util.Collection add(java.lang.String name, PDAdmSvcPobj value)
          Adds the specified PDAdmSvcPobj value to the collection of values for the specified name in this PDAttrs.
 java.util.Collection add(java.lang.String name, PDAttrValues vals)
          Deprecated. Use add instead
 java.util.Collection add(java.lang.String name, java.lang.String value)
          Adds the specified String value to the collection of values for the specified name in this PDAttrs.
 void addAll(PDAttrs attrs)
          Adds all of the elements in the specified PDAttrs to this PDAttrs.
 boolean allowDups()
          Returns the current value of allowDups.
 void clear()
          Clears the current PDAttrs.
 java.lang.Object clone()
          Clones the current PDAttrs.
 boolean delete(java.lang.String key)
          Removes the named attribute from the PDAttrs.
 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)
          Deprecated. Use getValues instead.
 com.tivoli.pd.jasn1.attrlist_t getAttrlist_t()
           
 void getAttrlist_t(com.tivoli.pd.jasn1.attrlist_t alt)
           
 int getQoP()
          Returns the current value of QoP.
 java.util.Collection getValues(java.lang.String key)
          Returns the value(s) to which this PDAttrs maps the specified key.
 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()
          Returns a String representation of this object.
 
Methods inherited from class com.tivoli.pd.jutil.PDEnvironmentObject
getContext, setContext
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PDAttrs

public PDAttrs(com.tivoli.pd.jutil.PDBasicContext context)
        throws PDException
Constructs a new, empty PDAttrs with the specified initial capacity and default load factor, which is 0.75.
Parameters:
context - the context that defines values for logging and tracing. Cannot be null.
Throws:
PDException - if an error occurs. This exception may contain error and message codes defined in the product Error Message Reference document.

PDAttrs

public PDAttrs(com.tivoli.pd.jutil.PDBasicContext context,
               boolean allowDuplicates)
        throws PDException
Constructs a new, empty PDAttrs that specifies whether the value for each attribute can consist of an unordered list that allows duplicate items. The PDAttrs will have the default load factor (.75).
Parameters:
context - the context that defines values for logging and tracing. Cannot be null.
allowDuplicates - A boolean indicating whether each attribute value can be an unordered list that allows duplicate items.
Throws:
PDException - if an error occurs. This exception may contain error and message codes defined in the product Error Message Reference document.

PDAttrs

public PDAttrs(PDAttrs that)
        throws PDException
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:
PDException - if one or more of the elements in the PDAttrs to be added are not PDAttr objects, or if no PDAttrs is passed in. This exception may contain error and message codes defined in the product Error Message Reference document.

PDAttrs

public PDAttrs(com.tivoli.pd.jutil.PDBasicContext context,
               byte[] serverData)
        throws PDException
Creates a PDAttrs from the data returned from the Policy Director server. This is not intended for public use.
Parameters:
context - the context that defines values for logging and tracing. Cannot be null.
serverData - ASN.1 rendition of an Attrlist.

PDAttrs

public PDAttrs(com.tivoli.pd.jutil.PDBasicContext context,
               com.tivoli.pd.jasn1.attrlist_t alt)
        throws PDException
Method Detail

add

public java.util.Collection add(java.lang.String name,
                                PDAttrValues vals)
                         throws PDException
Deprecated. Use add instead

Associates the specified values with the specified name in this PDAttrs. If this PDAttrs previously contained values for the name, then the input values are added to the values already known for the name.
Parameters:
name - the name of the attribute.
vals - the new values to be associated with the name.
Returns:
the previous values associated with the name, or null if no values were previously known for the name.
Throws:
PDException - on parameter errors. This exception may contain error and message codes defined in the product Error Message Reference document.

add

public java.util.Collection add(java.lang.String name,
                                java.util.Collection vals)
                         throws PDException
Associates the specified values with the specified name in this PDAttrs. If this PDAttrs previously contained values for the name, then the input values are added to the values already known for the name.
Parameters:
name - the name of the attribute.
vals - the new values to be associated with the name. Must be either a PDAttrValues or a PDAttrValueList.
Returns:
the previous values associated with the name, or null if no values were previously known for the name.
Throws:
PDException - on parameter errors. This exception may contain error and message codes defined in the product Error Message Reference document.

add

public java.util.Collection add(java.lang.String name,
                                java.lang.String value)
                         throws PDException
Adds the specified String value to the collection of values for 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 the name.
Parameters:
name - the name of the attribute.
value - the new String value to be added for the name.
Returns:
the previous values associated with the name, or null if no values were previously known for the name.
Throws:
PDException - if the input value contains an object other than a PDAttrValue, or on parameter errors. This exception may contain error and message codes defined in the product Error Message Reference document.

add

public java.util.Collection add(java.lang.String name,
                                java.lang.Long value)
                         throws PDException
Adds the specified Long value to the collection of values for the specified name in this PDAttrs. If this PDAttrs previously contained values for the name, then the input value is added to the values already known for the name.
Parameters:
name - the name of the attribute.
value - the new Long value to be added for the name.
Returns:
the previous values associated with the name, or null if no values were previously known for the name.
Throws:
PDException - if the input value contains an object other than a PDAttrValue, or on parameter errors. This exception may contain error and message codes defined in the product Error Message Reference document.

add

public java.util.Collection add(java.lang.String name,
                                PDAdmSvcPobj value)
                         throws PDException
Adds the specified PDAdmSvcPobj value to the collection of values for 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 the name.
Parameters:
name - the name of the attribute.
value - the new PDAdmSvcPobj value to be added for the name.
Returns:
the previous values associated with the name, or null if no values were previously known for the name.
Throws:
PDException - if the input contains an object other than a PDAttrValue, or on parameter errors. This exception may contain error and message codes defined in the product Error Message Reference document.

add

public java.util.Collection add(java.lang.String name,
                                byte[] value)
                         throws PDException
Adds the specified byte array value to the collection of values for the specified name in this PDAttrs. If this PDAttrs previously contained values for the name, then the input value is added to the values already known for the name.
Parameters:
name - the name of the attribute.
value - the new byte array value to be added for the name.
Returns:
the previous values associated with the name, or null if no values were previously known for the name.
Throws:
PDException - if the input value contains an object other than a PDAttrValue, or on parameter errors. This exception may contain error and message codes defined in the product Error Message Reference document.

addAll

public void addAll(PDAttrs attrs)
            throws PDException
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.
Parameters:
attrs - the PDAttrs to be added.
Throws:
PDException - if no PDAttrs is passed. This exception may contain error and message codes defined in the product Error Message Reference document.

clear

public void clear()
Clears the current PDAttrs. Remove all mappings in the current PDAttrs, reset QoP to zero, and reset the version number to the current supported level. Leave allowDups as it was when the PDAttrs was originally created.

delete

public boolean delete(java.lang.String key)
Removes 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()
Clones the current PDAttrs. This is implemented as a deep copy.

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.

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, version, and allowDups are the same, and then defers to the equals check, which will devolve into a containsAll check on the current PDAttrs set.
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)
                 throws PDException
Deprecated. Use getValues instead.

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.
Throws:
Throws - PDException. This exception may contain error and message codes defined in the product Error Message Reference document.

getValues

public java.util.Collection getValues(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.

getQoP

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

allowDups

public boolean allowDups()
Returns the current value of allowDups.

hashCode

public int hashCode()
Returns a hashcode for the current object.
Overrides:
hashCode in class java.lang.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.

setQoP

public void setQoP(int qop)
            throws PDException
Sets the current value of QoP.
Parameters:
qop - the new value for QoP.
Throws:
PDException - if the QoP value is unknown. This exception may contain error and message codes defined in the product Error Message Reference document.

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.

toString

public java.lang.String toString()
Returns a String representation of this object.
Overrides:
toString in class java.lang.Object

getAttrlist_t

public com.tivoli.pd.jasn1.attrlist_t getAttrlist_t()
                                             throws PDException

getAttrlist_t

public void getAttrlist_t(com.tivoli.pd.jasn1.attrlist_t alt)
                   throws PDException