org.pf.directory
Class MultiValueAttribute

java.lang.Object
  extended by org.pf.util.Association<java.lang.String,V>
      extended by org.pf.util.NamedValue
          extended by org.pf.directory.MultiValueAttribute
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, java.util.Map.Entry

public class MultiValueAttribute
extends NamedValue

An attribute with multiple values associated

Version:
1.3
Author:
M.Duchrow
See Also:
Serialized Form

Constructor Summary
MultiValueAttribute(java.lang.String attrName)
          Initialize the new instance with a name.
MultiValueAttribute(java.lang.String attrName, boolean encoded)
          Initialize the new instance with a name.
 
Method Summary
 void addValue(java.lang.Object value)
          Add the given value if it not already exists in the attributes values
 void addValues(java.util.List values)
          Adds all given values to this attribute skipping duplicate values.
 void addValues(java.lang.Object[] values)
          Adds all given values to this attribute skipping duplicate values.
 boolean containsValue(java.lang.Object value)
          Returns true if the given value is one of the values of this attribute.
 MultiValueAttribute copy()
          Returns a copy of this object
 java.lang.Object getFirstValue()
          Returns the first value of this attribute
 java.lang.String getFirstValueAsString()
          Returns the first value of this attribute as String
 boolean getIgnoreCase()
          Returns true if this MultiValueAttribute is treated case-insensitive.
 java.lang.String getName()
          Returns the name of this attribute
 java.util.List getValues()
          Returns the values of this attribute
 java.lang.String[] getValuesAsStrings()
          Returns the values of this attribute as string array
 boolean isEmpty()
          Returns true if the attribute has no values
 boolean mustBeEncoded()
          Returns whether or not the value of this attribute must be encoded if written to a stream
 void mustBeEncoded(boolean newValue)
          Sets whether or not the value of this attribute must be encoded if written to a stream
 void setIgnoreCase(boolean newValue)
          Sets whether or not this MultiValueAttribute is treated case-insensitive.
 void setSoleValue(java.lang.Object value)
          Sets the given value as the only value of this attribute
 int valueCount()
          Returns the number of values associated with this attribute
 
Methods inherited from class org.pf.util.NamedValue
compareTo, copyNamedValue, key, name, name
 
Methods inherited from class org.pf.util.Association
copyAssociation, equals, getKey, getValue, hashCode, key, setValue, toString, value, value
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiValueAttribute

public MultiValueAttribute(java.lang.String attrName)
Initialize the new instance with a name.

Parameters:
attrName - The name of the new attribute

MultiValueAttribute

public MultiValueAttribute(java.lang.String attrName,
                           boolean encoded)
Initialize the new instance with a name.

Parameters:
attrName - The name of the new attribute
encoded - A marker that indicates if the values of this attribute must be encoded
Method Detail

mustBeEncoded

public boolean mustBeEncoded()
Returns whether or not the value of this attribute must be encoded if written to a stream


mustBeEncoded

public void mustBeEncoded(boolean newValue)
Sets whether or not the value of this attribute must be encoded if written to a stream


getIgnoreCase

public boolean getIgnoreCase()
Returns true if this MultiValueAttribute is treated case-insensitive. That is, comparison of string values is done case-insensitive.


setIgnoreCase

public void setIgnoreCase(boolean newValue)
Sets whether or not this MultiValueAttribute is treated case-insensitive. That is, comparison of string values is done case-insensitive.


getName

public java.lang.String getName()
Returns the name of this attribute


getValues

public java.util.List getValues()
Returns the values of this attribute


getValuesAsStrings

public java.lang.String[] getValuesAsStrings()
Returns the values of this attribute as string array

Throws:
java.lang.ClassCastException - If any value of this attribute is not of type String

getFirstValue

public java.lang.Object getFirstValue()
Returns the first value of this attribute


getFirstValueAsString

public java.lang.String getFirstValueAsString()
Returns the first value of this attribute as String

Throws:
java.lang.NullPointerException - if the attribute has no value at all

addValue

public void addValue(java.lang.Object value)
Add the given value if it not already exists in the attributes values


addValues

public void addValues(java.lang.Object[] values)
Adds all given values to this attribute skipping duplicate values.


addValues

public void addValues(java.util.List values)
Adds all given values to this attribute skipping duplicate values.


containsValue

public boolean containsValue(java.lang.Object value)
Returns true if the given value is one of the values of this attribute. Comparison of string values are done according to the current ignoreCase state.


setSoleValue

public void setSoleValue(java.lang.Object value)
Sets the given value as the only value of this attribute


copy

public MultiValueAttribute copy()
Returns a copy of this object


valueCount

public int valueCount()
Returns the number of values associated with this attribute


isEmpty

public boolean isEmpty()
Returns true if the attribute has no values