oracle.ldap.util
Class LDIFAttribute

java.lang.Object
  |
  +--oracle.ldap.util.LDIFAttribute

public class LDIFAttribute
extends java.lang.Object

The LDIFAttribute class represents the name and values of an attribute. It is used to specify an attribute to be added to, deleted from, or modified in a Directory entry. It is also returned on a search of a Directory.


Constructor Summary
LDIFAttribute(LDIFAttribute ldapAttribute)
          Constructs an attribute with copies of all values of the input LDIFAttribute.
LDIFAttribute(java.lang.String attrName)
          Constructs an attribute with no values.
LDIFAttribute(java.lang.String attrName, byte[] attrBytes)
          Constructs an attribute with a byte-formatted value.
LDIFAttribute(java.lang.String attrName, java.lang.String attrString)
          Constructs an attribute that has a single string value.
LDIFAttribute(java.lang.String attrName, java.lang.String[] attrStrings)
          Constructs an attribute that has an array of string values.
 
Method Summary
 void addValue(byte[] attrBytes)
          Adds a byte[]-formatted value to the attribute.
 void addValue(java.lang.String attrString)
          Adds a string value to the attribute.
 void addValue(java.lang.String[] attrValues)
          Adds an array of string values to the attribute.
 boolean contains(byte[] attrBytes)
          Reports whether this object contains the specified attribute value.
 boolean contains(java.lang.String attrString)
          Reports whether this object contains the specified attribute value.
 boolean equals(java.lang.Object ldifAttr)
           
 java.lang.String getBaseName()
          Returns the base name of this object.
static java.lang.String getBaseName(java.lang.String attrName)
          Returns the base name.
 byte[][] getByteValueArray()
          Returns the values of the attribute as an array of byte[]
 java.util.Enumeration getByteValues()
          Returns an enumerator for the values of the attribute in byte[] format.
 int getChangeType()
          Return this the change type associated with this attribute(if any).
 javax.naming.directory.Attribute getJNDIAttribute()
          Returns an object of javax.naming.directory.Attribute that describes the attribute
 javax.naming.directory.ModificationItem getJNDIModificationItem()
          Returns an object of javax.naming.directory.ModificationItem that represents a JNDI modification item.
 java.lang.String getLangSubtype()
          Returns the language subtype if any.
 java.lang.String getName()
          Returns the name of the attribute.
 java.lang.String[] getStringValueArray()
          Returns the values of the attribute as an array of Strings
 java.util.Enumeration getStringValues()
          Returns an enumerator for the string values of an attribute.
 java.lang.String[] getSubtypes()
          Extracts the subtypes from the attribute name of this object.
static java.lang.String[] getSubtypes(java.lang.String attrName)
          Extracts the subtypes from the specified attribute name.
 java.lang.String getValue()
          Retruns the value of a single value attribute.
 boolean hasSubtype(java.lang.String subtype)
          Reports whether the attribute name contains the specified subtype.
 boolean hasSubtypes(java.lang.String[] subtypes)
          Reports if the attribute name contains all specified subtypes.
 void removeValue(byte[] attrBytes)
          Removes a byte[]-formatted value from the attribute.
 void removeValue(java.lang.String attrString)
          Removes a string value from the attribute.
 void setChangeType(int changeType)
          Sets the change type for this attribute.
 void setValues(java.lang.String[] attrValues)
          Sets the string values as the attribute's values.
 int size()
          Returns the number of values of the attribute.
 java.lang.String toString()
          Retrieves the string representation of an attribute in an LDAP entry.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LDIFAttribute

public LDIFAttribute(java.lang.String attrName)
Constructs an attribute with no values.
Parameters:
attrName - name of the attribute

LDIFAttribute

public LDIFAttribute(LDIFAttribute ldapAttribute)
Constructs an attribute with copies of all values of the input LDIFAttribute.
Parameters:
ldapAttribute - An attribute to use as template.

LDIFAttribute

public LDIFAttribute(java.lang.String attrName,
                     byte[] attrBytes)
Constructs an attribute with a byte-formatted value.
Parameters:
attrName - Name of the attribute
attrBytes - Value of the attribute as raw bytes

LDIFAttribute

public LDIFAttribute(java.lang.String attrName,
                     java.lang.String attrString)
Constructs an attribute that has a single string value.
Parameters:
attrName - name of the attribute
attrString - value of the attribute in String format

LDIFAttribute

public LDIFAttribute(java.lang.String attrName,
                     java.lang.String[] attrStrings)
Constructs an attribute that has an array of string values.
Parameters:
attrName - name of the attribute
attrStrings - the list of string values for this attribute
Method Detail

addValue

public void addValue(java.lang.String attrString)
Adds a string value to the attribute.
Parameters:
attrString - Value of the attribute as a String.

addValue

public void addValue(byte[] attrBytes)
Adds a byte[]-formatted value to the attribute.
Parameters:
attrBytes - the value of attribute as raw bytes. add to the attribute

addValue

public void addValue(java.lang.String[] attrValues)
Adds an array of string values to the attribute.
Parameters:
values - array of string values. add to the attribute

getByteValues

public java.util.Enumeration getByteValues()
Returns an enumerator for the values of the attribute in byte[] format.
Returns:
a set of attribute values. Each element in the enumeration is of type byte[].

getStringValues

public java.util.Enumeration getStringValues()
Returns an enumerator for the string values of an attribute.
Returns:
enumerator for the string values.

getByteValueArray

public byte[][] getByteValueArray()
Returns the values of the attribute as an array of byte[]
Returns:
array of attribute values in byte[] format.

getStringValueArray

public java.lang.String[] getStringValueArray()
Returns the values of the attribute as an array of Strings
Returns:
array of attribute values as String object.

setValues

public void setValues(java.lang.String[] attrValues)
Sets the string values as the attribute's values.
Parameters:
attrValues - an array of string values which represent the attribute values.

getLangSubtype

public java.lang.String getLangSubtype()
Returns the language subtype if any. For example, if the attribute name is cn;lang-fr;phonetic, this method returns the String lang-fr.
Returns:
the language subtype, or null (if the name has no language subtype).

getBaseName

public static java.lang.String getBaseName(java.lang.String attrName)
Returns the base name. For example, if the attribute name is cn;lang-fr;phonetic, this method returns cn.
Parameters:
attrName - name of the attribute to extract the base name from
Returns:
base name (i.e. the attribute name without subtypes).

getBaseName

public java.lang.String getBaseName()
Returns the base name of this object. For example, if the attribute name is cn;lang-fr;phonetic, this method returns cn.
Returns:
base name (i.e. the attribute name without subtypes).

getName

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

getSubtypes

public static java.lang.String[] getSubtypes(java.lang.String attrName)
Extracts the subtypes from the specified attribute name. For example, if the attribute name is cn;lang-fr;phonetic, this method returns an array containing lang-fr and phonetic.
Parameters:
attrName - name of the attribute to extract the subtypes from.
Returns:
array of subtypes, or null (if no subtypes).

getSubtypes

public java.lang.String[] getSubtypes()
Extracts the subtypes from the attribute name of this object. For example, if the attribute name is cn;lang-fr;phonetic, then this method returns an array containing lang-ja and phonetic.
Returns:
array of subtypes, or null (if no subtypes).

hasSubtype

public boolean hasSubtype(java.lang.String subtype)
Reports whether the attribute name contains the specified subtype. For example, if you check for the subtype lang-fr and the attribute name is cn;lang-fr, this method returns true.
Parameters:
subtype - the single subtype to check for
Returns:
true if the attribute name contains the specified subtype.

hasSubtypes

public boolean hasSubtypes(java.lang.String[] subtypes)
Reports if the attribute name contains all specified subtypes. For example, if you check for the subtypes lang-fr and phonetic and if the attribute name is cn;lang-fr;phonetic, this method returns true. If the attribute name is cn;phonetic or cn;lang-fr, this method returns false.
Parameters:
subtypes - an array of subtypes to check for
Returns:
true if the attribute name contains all subtypes

removeValue

public void removeValue(java.lang.String attrString)
Removes a string value from the attribute.
Parameters:
attrString - the string value to remove

removeValue

public void removeValue(byte[] attrBytes)
Removes a byte[]-formatted value from the attribute.
Parameters:
attrBytes - byte[]-formatted value to remove

size

public int size()
Returns the number of values of the attribute.
Returns:
number of values for this attribute.

getChangeType

public int getChangeType()
Return this the change type associated with this attribute(if any).
Returns:
a Change Type constant defined in the LDIF class

setChangeType

public void setChangeType(int changeType)
Sets the change type for this attribute.
Parameters:
changeType - Change Type constant defined in the LDIF class

getValue

public java.lang.String getValue()
Retruns the value of a single value attribute. In case of a multivalued attribute the first value is returned. If the attribute does contain not any value then null is returned.
Returns:
an attribute value or null if the attribute has no value.

contains

public boolean contains(java.lang.String attrString)
Reports whether this object contains the specified attribute value.
Parameters:
attrString - value as String object that needs to be checked for
Returns:
true if the attribute contains the specified value, else false.

contains

public boolean contains(byte[] attrBytes)
Reports whether this object contains the specified attribute value.
Parameters:
attrValue - value as byte[] formatted representation that needs to be checked for
Returns:
true if the attribute contains the specified value, else false.

getJNDIAttribute

public javax.naming.directory.Attribute getJNDIAttribute()
Returns an object of javax.naming.directory.Attribute that describes the attribute
Returns:
javax.naming.directory.Attribute object describing the attribute

getJNDIModificationItem

public javax.naming.directory.ModificationItem getJNDIModificationItem()
Returns an object of javax.naming.directory.ModificationItem that represents a JNDI modification item.
Returns:
javax.naming.directory.ModificationItem that represents a modification item

toString

public java.lang.String toString()
Retrieves the string representation of an attribute in an LDAP entry. For example:
LDIFAttribute {type='cn', values='Barbara Jensen,Babs Jensen'}
Overrides:
toString in class java.lang.Object
Returns:
string representation of the attribute.

equals

public boolean equals(java.lang.Object ldifAttr)
Overrides:
equals in class java.lang.Object