public class LDAPAttribute
extends java.lang.Object
implements java.io.Serializable
LDAPAttributeSet
,
Serialized FormConstructor and Description |
---|
LDAPAttribute(BERElement element)
Constructs an attribute from a BER (Basic Encoding Rules) element.
|
LDAPAttribute(LDAPAttribute attr)
Constructs an attribute from another existing attribute.
|
LDAPAttribute(java.lang.String attrName)
Constructs an attribute with no values.
|
LDAPAttribute(java.lang.String attrName,
byte[] attrValue)
Constructs an attribute with a byte-formatted value.
|
LDAPAttribute(java.lang.String attrName,
java.lang.String attrValue)
Constructs an attribute that has a single string value.
|
LDAPAttribute(java.lang.String attrName,
java.lang.String[] attrValues)
Constructs an attribute that has an array of string values.
|
Modifier and Type | Method and Description |
---|---|
void |
addValue(byte[] attrValue)
Adds a
byte[] -formatted value to the attribute. |
void |
addValue(java.lang.String attrValue)
Adds a string value to the attribute.
|
java.lang.String |
getBaseName()
Extracts the base name from the attribute name of the current
LDAPAttribute object. |
static java.lang.String |
getBaseName(java.lang.String attrName)
Extracts the base name from the specified attribute name.
|
BERElement |
getBERElement()
Retrieves the BER (Basic Encoding Rules) representation of an attribute.
|
byte[][] |
getByteValueArray()
Returns the values of the attribute in an array of
byte[]
format. |
java.util.Enumeration |
getByteValues()
Returns an enumerator for the values of the attribute in
byte[]
format. |
java.lang.String |
getLangSubtype()
Extracts the language subtype from the attribute name of the
LDAPAttribute object, 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
String
objects. |
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 the current
LDAPAttribute object. |
static java.lang.String[] |
getSubtypes(java.lang.String attrName)
Extracts the subtypes from the specified attribute name.
|
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
For example, if you check for the subtypes
lang-en
and phonetic and the attribute name is
cn;lang-en;phonetic , this method returns true . |
void |
removeValue(byte[] attrValue)
Removes a
byte[] -formatted value from the attribute. |
void |
removeValue(java.lang.String attrValue)
Removes a string value from the attribute.
|
protected void |
setValues(java.lang.Object[] attrValues)
Sets the byte[] values as the attribute's values.
|
protected 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 LDAPAttribute(LDAPAttribute attr)
attr
- the attribute to copypublic LDAPAttribute(java.lang.String attrName)
attrName
- name of the attributepublic LDAPAttribute(java.lang.String attrName, byte[] attrValue)
attrName
- name of the attributeattrValue
- value of the attribute in byte formatpublic LDAPAttribute(java.lang.String attrName, java.lang.String attrValue)
attrName
- name of the attributeattrValue
- value of the attribute in String formatpublic LDAPAttribute(java.lang.String attrName, java.lang.String[] attrValues)
attrName
- name of the attributeattrValues
- the list of string values for this attributepublic LDAPAttribute(BERElement element) throws java.io.IOException
element
- element that you want translated into an attributejava.io.IOException
- The attribute could not be created from
the specified element.public int size()
public java.util.Enumeration getStringValues()
public java.lang.String[] getStringValueArray()
String
objects.String
object.public java.util.Enumeration getByteValues()
byte[]
format.byte[]
.public byte[][] getByteValueArray()
byte[]
format.byte[]
.public java.lang.String getName()
public static java.lang.String[] getSubtypes(java.lang.String attrName)
cn;lang-ja;phonetic
,
this method returns an array containing lang-ja
and phonetic
.
attrName
- name of the attribute from which to extract the subtypesgetBaseName(java.lang.String)
public java.lang.String[] getSubtypes()
LDAPAttribute
object. For example, if the attribute
name is cn;lang-ja;phonetic
, this method returns an array
containing lang-ja
and phonetic
.
public java.lang.String getLangSubtype()
LDAPAttribute
object, if any. For example, if the
attribute name is cn;lang-ja;phonetic
, this method
returns the String lang-ja
.
public static java.lang.String getBaseName(java.lang.String attrName)
cn;lang-ja;phonetic
,
this method returns cn
.
attrName
- name of the attribute from which to extract the base namegetSubtypes(java.lang.String)
public java.lang.String getBaseName()
LDAPAttribute
object. For example, if the attribute
name is cn;lang-ja;phonetic
, this method returns
cn
.
getSubtypes(java.lang.String)
public boolean hasSubtype(java.lang.String subtype)
lang-en
and the attribute name is cn;lang-en
, this method
returns true
.
subtype
- the single subtype for which you want to checkgetSubtypes(java.lang.String)
public boolean hasSubtypes(java.lang.String[] subtypes)
lang-en
and phonetic
and the attribute name is
cn;lang-en;phonetic
, this method returns true
.
If the attribute name is cn;phonetic
or
cn;lang-en
, this method returns false
.
subtypes
- an array of subtypes to checkgetSubtypes(java.lang.String)
public void addValue(java.lang.String attrValue)
attrValue
- the string value to add to the attributeprotected void setValues(java.lang.String[] attrValues)
attrValues
- the string values to use in the attributepublic void addValue(byte[] attrValue)
byte[]
-formatted value to the attribute.attrValue
- the byte[]
-formatted value to
add to the attributeprotected void setValues(java.lang.Object[] attrValues)
attrValues
- the values to use in the attributepublic void removeValue(java.lang.String attrValue)
attrValue
- the string value to removepublic void removeValue(byte[] attrValue)
byte[]
-formatted value from the attribute.attrValue
- byte[]
-formatted value to removepublic BERElement getBERElement()
public java.lang.String toString()
LDAPAttribute {type='cn', values='Barbara Jensen,Babs Jensen'}
toString
in class java.lang.Object