com.mentata.l3d
Class L3DAttribute

java.lang.Object
  extended bycom.mentata.l3d.L3DAttribute
All Implemented Interfaces:
Comparator
Direct Known Subclasses:
L3DDnAttribute, SG8StringAttribute

public class L3DAttribute
extends Object
implements Comparator

A container within an object for representing entry attribute values. This class can be extended by various attribute types that all implement the same basic functionality. Attributes are created and configured from within an object and can correspond with a specific attribute for the associated object class in the directory schema. A given L3DAttribute is configured to be optional or required and to have a single value or multiple values, not necessarily in accordance with the schema definition. Attributes can be populated with values from a corresponding entry in the directory database or manipulated with methods to initialize, set, add, or remove values. The class includes supporting methods for comparing values, sorting values, setting a limit on the number of values, setting a length limit for each value, accessing the containing object, accessing a bound connection for the containing object, and getting directory connections directly from the containing context. For its original implementation, this class stores and compares its values as simple, case-insensitive Unicode strings.

Since:
0.7
Author:
Jon Roberts

Constructor Summary
L3DAttribute()
          Constructs an empty attribute.
 
Method Summary
 void addValue(String value)
          Adds a value to the attribute.
 int compare(Object one, Object two)
          Sorts given values by locale specific string collation.
protected  L3DAttribute getAttribute(String name)
          Returns another attribute from the containing object.
protected  LDAPConnection getBind()
          Returns the bound connection from the containing object.
protected  L3DContext getContext()
          Returns the context of the containing object.
 String getLabel()
          Returns the attribute's assigned label.
 int getLengthThreshold()
          Returns the maximum number of characters an attribute value may contain.
 String getName()
          Returns the name of the attribute in the containing object.
protected  L3DObject getObject()
          Returns the containing object.
protected  L3DObject getObject(String classname)
          Returns an object from the containing context.
 String[] getPrerequisites()
          Returns the attribute names in the named list.
 String[] getShortValues()
          Returns the attribute's values as translated to a shortened text format.
 int getSize()
          Returns the number of values for the attribute.
 int getThreshold()
          Returns the number of values the attribute may contain.
 String[] getValues()
          Returns the attribute's values.
 void initialize(String[] initializers)
          Sets the attribute's values to those submitted.
 boolean isBound()
          Identifies if the containing object has an associated connection.
 boolean isExceeded()
          Identifies if the attribute exceeds its size threshold.
 boolean isGenerated()
          Records the existence of assigned values for the attribute.
 boolean isLengthExceeded()
          Identifies if an attribute value exceeds its length threshold.
 boolean isMultivalue()
          Identifies if the attribute may contain multiple values.
 boolean isRequired()
          Identifies if the attribute is required.
 void removeValue(String value)
          Removes a value from the attribute.
 boolean same(String one, String two)
          Determines if the given values are considered equal for this attribute type.
 void setGenerated(boolean value)
          Records the existence of assigned values for the attribute.
 void setLabel(String label)
          Assigns a label to the attribute.
 void setLengthThreshold(int threshold)
          Sets a threshold for the number of characters an attribute value can contain.
protected  void setPrerequisites(String[] prerequisites)
          Sets prerequisite attributes for this attribute.
 void setThreshold(int threshold)
          Sets a threshold for the number of values the attribute can contain.
protected  void setValues(String[] values)
          Sets the attribute's values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

L3DAttribute

public L3DAttribute()
Constructs an empty attribute.

Method Detail

getName

public String getName()
Returns the name of the attribute in the containing object.

Returns:
the name of the attribute

isMultivalue

public final boolean isMultivalue()
Identifies if the attribute may contain multiple values.

Returns:
whether the attribute is multivalue

isRequired

public final boolean isRequired()
Identifies if the attribute is required.

Returns:
whether the attribute is required

getObject

protected final L3DObject getObject()
Returns the containing object.

Returns:
the containing L3D object

getContext

protected final L3DContext getContext()
Returns the context of the containing object.

Returns:
the containing L3D context

getObject

protected final L3DObject getObject(String classname)
                             throws L3DException
Returns an object from the containing context.

Returns:
an L3D object
Throws:
L3DException - if the containing requested object are undefined

getAttribute

protected final L3DAttribute getAttribute(String name)
                                   throws L3DException
Returns another attribute from the containing object.

Returns:
an L3D attribute
Throws:
L3DException - if the containing object or requested attribute are undefined

isBound

public final boolean isBound()
                      throws L3DException
Identifies if the containing object has an associated connection.

Returns:
whether the containing object is bound
Throws:
L3DException

getBind

protected final LDAPConnection getBind()
                                throws L3DException
Returns the bound connection from the containing object.

Returns:
the bound LDAP connection or null if there isn't one
Throws:
L3DException - if the containing object is undefined

setLabel

public void setLabel(String label)
Assigns a label to the attribute.

Parameters:
label - a clear description of the attribute

getLabel

public String getLabel()
Returns the attribute's assigned label.

Returns:
the attribute's label

setGenerated

public void setGenerated(boolean value)
Records the existence of assigned values for the attribute.

Parameters:
value - whether values are assigned

isGenerated

public boolean isGenerated()
Records the existence of assigned values for the attribute.

Returns:
whether values are assigned

setValues

protected final void setValues(String[] values)
Sets the attribute's values.

Parameters:
values - new string values

getValues

public final String[] getValues()
Returns the attribute's values.

Returns:
the attribute's values

getSize

public final int getSize()
Returns the number of values for the attribute.

Returns:
the number of values for the attribute

setThreshold

public void setThreshold(int threshold)
Sets a threshold for the number of values the attribute can contain.

Parameters:
threshold - the number of values permitted for the attribute

getThreshold

public int getThreshold()
Returns the number of values the attribute may contain.

Returns:
the number of values permitted for the attribute

isExceeded

public boolean isExceeded()
Identifies if the attribute exceeds its size threshold.

Returns:
whether the attribute exceeds its size threshold

setLengthThreshold

public void setLengthThreshold(int threshold)
Sets a threshold for the number of characters an attribute value can contain.

Parameters:
threshold - the number of characters permitted for an attribute value

getLengthThreshold

public int getLengthThreshold()
Returns the maximum number of characters an attribute value may contain.

Returns:
the maximum number of characters permitted for an attribute value

isLengthExceeded

public boolean isLengthExceeded()
Identifies if an attribute value exceeds its length threshold.

Returns:
whether the attribute has a value that exceeds its length threshold

same

public boolean same(String one,
                    String two)
Determines if the given values are considered equal for this attribute type.

Parameters:
one - one value to compare
two - the other value to compare
Returns:
whether the values should be considered equal

compare

public int compare(Object one,
                   Object two)
Sorts given values by locale specific string collation.

Specified by:
compare in interface Comparator
Parameters:
one - first value for comparison
two - second value for comparison
Returns:
standard integer representation for less than, greater than, or equals

getShortValues

public String[] getShortValues()
Returns the attribute's values as translated to a shortened text format.

Returns:
the attribute's values in short format

addValue

public void addValue(String value)
              throws L3DException
Adds a value to the attribute.

Parameters:
value - new value to add
Throws:
L3DException

removeValue

public void removeValue(String value)
Removes a value from the attribute.

Parameters:
value - the value to remove if currently a value for the attribute

initialize

public void initialize(String[] initializers)
                throws L3DException
Sets the attribute's values to those submitted.

Parameters:
initializers - strings representing values
Throws:
L3DException - in subclasses only

setPrerequisites

protected final void setPrerequisites(String[] prerequisites)
Sets prerequisite attributes for this attribute.

Parameters:
prerequisites - a list of required attributes

getPrerequisites

public final String[] getPrerequisites()
Returns the attribute names in the named list.

Returns:
the list of attributes required in use of the named attribute