public class LDIFAttribute
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public LDIFAttribute(java.lang.String attrName)
attrName
- name of the attributepublic LDIFAttribute(java.lang.String attrName, boolean isBinary)
attrName
- name of the attributeisBinary
- whether the attribute is binary or not ?public LDIFAttribute(LDIFAttribute ldapAttribute)
ldapAttribute
- An attribute to use as template.public LDIFAttribute(java.lang.String attrName, byte[] attrBytes, boolean isBinary)
attrName
- Name of the attributeattrBytes
- Value of the attribute as raw bytesisBinary
- Wether the attribute is a binary attribute or not ?public LDIFAttribute(java.lang.String attrName, byte[] attrBytes)
attrName
- Name of the attributeattrBytes
- Value of the attribute as raw bytespublic LDIFAttribute(java.lang.String attrName, java.lang.String attrString)
attrName
- name of the attributeattrString
- value of the attribute in String formatpublic LDIFAttribute(java.lang.String attrName, java.lang.String[] attrStrings)
attrName
- name of the attributeattrStrings
- the list of string values for this attributepublic void addValue(java.lang.String attrString)
attrString
- Value of the attribute as a String.
If the attribute is in Base64 encoded format, then
this will decode and store the valuepublic void addValue(byte[] attrBytes)
byte[]
-formatted value to the attribute.attrBytes
- the value of attribute as raw bytes.
A copy of the byte sequence will be made and added to the attribute.public void addValue(java.lang.String[] attrValues)
attrValues
- array of string values. Note that the
strings must be in UTF8 encoding format.public java.util.Enumeration getByteValues()
byte[]
format.byte[]
.public java.util.Enumeration getStringValues()
public java.util.Enumeration getValsAsObject()
public byte[][] getByteValueArray()
byte[]
byte[]
format.public java.lang.String[] getStringValueArray()
Strings
String
object.public void setValues(java.lang.String[] attrValues)
attrValues
- an array of string values which represent
the attribute values.public java.lang.String getLangSubtype()
cn;lang-fr;phonetic
, this method returns the
String lang-fr
.public static java.lang.String getBaseName(java.lang.String attrName)
cn;lang-fr;phonetic
, this method returns cn
.attrName
- name of the attribute to extract the base name frompublic java.lang.String getBaseName()
cn;lang-fr;phonetic
, this method returns cn
.public java.lang.String getName()
public static java.lang.String[] getSubtypes(java.lang.String attrName)
cn;lang-fr;phonetic
,
this method returns an array containing lang-fr
and
phonetic
.attrName
- name of the attribute to extract the subtypes from.public java.lang.String[] getSubtypes()
cn;lang-fr;phonetic
,
then this method returns an array containing lang-ja
and phonetic
.public boolean hasSubtype(java.lang.String subtype)
lang-fr
and the attribute name is cn;lang-fr
, this method
returns true
.subtype
- the single subtype to check forpublic boolean hasSubtypes(java.lang.String[] 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
.subtypes
- an array of subtypes to check forpublic boolean removeValue(java.lang.String attrString)
attrString
- the string value to removepublic void removeValue(byte[] attrBytes)
byte[]
-formatted value from the attribute.attrBytes
- byte[]
-formatted value to removepublic void removeAll()
public int size()
public int getChangeType()
public void setChangeType(int changeType)
changeType
- Change Type constant defined in the LDIF classpublic java.lang.String getValue()
public boolean contains(java.lang.String attrString)
attrString
- value as String
object that needs to
be checked forpublic boolean contains(byte[] attrBytes)
attrBytes
- - value as byte[]
formatted representation
that needs to be checked forpublic javax.naming.directory.Attribute getJNDIAttribute()
javax.naming.directory.Attribute
that describes the attributepublic javax.naming.directory.ModificationItem getJNDIModificationItem()
javax.naming.directory.ModificationItem
that represents a JNDI modification item.public java.lang.String getAttributeAsString(boolean asComment)
asComment
- will return the attribute string with '#' prepended.public java.lang.String getAttributeAsString(boolean asComment, boolean wrap)
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.public boolean isBinary()
public boolean setBinary(boolean binary)
binary
- true if the attribute is created to contain binary values;
false otherwisepublic java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object ldifAttr)
equals
in class java.lang.Object
ldifAttr
- an Object that you want to check for equalitypublic java.lang.Object clone()
clone
in class java.lang.Object