Skip navigation links

Oracle Internet Directory API Reference
11g Release 1 (11.1.1)

E10664-01


oracle.ldap.util
Class LDIFAttribute

java.lang.Object
  extended by oracle.ldap.util.LDIFAttribute

All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

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

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.

See Also:
Serialized Form

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, boolean isBinary)
          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, byte[] attrBytes, boolean isBinary)
          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.
 java.lang.Object clone()
          Returns a copy of this object
 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)
          Checks for the equality of the attribute with the given one.
 java.lang.String getAttributeAsString(boolean asComment)
          Retrieves the string representation of an attribute in an LDAP entry.
 java.lang.String getAttributeAsString(boolean asComment, boolean wrap)
          Retrieves the string representation of an attribute in an LDAP entry.
 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.util.Enumeration getValsAsObject()
          Returns the attributes as enumeration.
 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.
 boolean isBinary()
          Returns whether the attribute is a Binary attribute or not.
 void removeAll()
          removes All the values of the attributes
 void removeValue(byte[] attrBytes)
          Removes a byte[]-formatted value from the attribute.
 boolean removeValue(java.lang.String attrString)
          Removes a string value from the attribute.
 boolean setBinary(boolean binary)
          set this attribute as binary 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
finalize, 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(java.lang.String attrName,
                     boolean isBinary)
Constructs an attribute with no values.
Parameters:
attrName - name of the attribute
isBinary - whether the attribute is binary or not ?

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,
                     boolean isBinary)
Constructs an attribute with a byte-formatted value.
Parameters:
attrName - Name of the attribute
attrBytes - Value of the attribute as raw bytes
isBinary - Wether the attribute is a binary attribute or not ?

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. If the attribute is in Base64 encoded format, then this will decode and store the value

addValue

public void addValue(byte[] attrBytes)
Adds a byte[]-formatted value to the attribute.
Parameters:
attrBytes - the value of attribute as raw bytes. A copy of the byte sequence will be made and added to the attribute.

addValue

public void addValue(java.lang.String[] attrValues)
Adds an array of string values to the attribute.
Parameters:
attrValues - array of string values. Note that the strings must be in UTF8 encoding format.

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.

getValsAsObject

public java.util.Enumeration getValsAsObject()
Returns the attributes as enumeration. In case of binary attribute the enumeration will contain byte[] and in case of no binary attributes it will be String element
Returns:
Enumeration of object

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 boolean 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

removeAll

public void removeAll()
removes All the values of the attributes

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:
attrBytes - - 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

getAttributeAsString

public java.lang.String getAttributeAsString(boolean asComment)
Retrieves the string representation of an attribute in an LDAP entry.
Parameters:
asComment - will return the attribute string with '#' prepended.
Returns:
string representation of the attribute.

getAttributeAsString

public java.lang.String getAttributeAsString(boolean asComment,
                                             boolean wrap)
Retrieves the string representation of an attribute in an LDAP entry.
Parameters:
asComment - will return the attribute string with '#' prepended.
wrap - if true the line will be wrapped and continued in the next line with ' ' at the begining.
Returns:
string representation of the attribute.

isBinary

public boolean isBinary()
Returns whether the attribute is a Binary attribute or not.
Returns:
true if the attribute is created to contain binary values; false otherwise

setBinary

public boolean setBinary(boolean binary)
set this attribute as binary attribute.
Parameters:
binary - true if the attribute is created to contain binary values; false otherwise

toString

public java.lang.String toString()
Retrieves the string representation of an attribute in an LDAP entry. For example:
Overrides:
toString in class java.lang.Object
Returns:
string representation of the attribute.

equals

public boolean equals(java.lang.Object ldifAttr)
Checks for the equality of the attribute with the given one.
Overrides:
equals in class java.lang.Object
Parameters:
ldifAttr - an Object that you want to check for equality
Returns:
ture if ldifAttr has same name as this object then

clone

public java.lang.Object clone()
Returns a copy of this object
Overrides:
clone in class java.lang.Object
Returns:
Object a copy of this object

Skip navigation links

Oracle Internet Directory API Reference
11g Release 1 (11.1.1)

E10664-01


Copyright © 1999, 2009 Oracle. All Rights Reserved.