Package netscape.ldap
Class LDAPAttribute
- java.lang.Object
-
- netscape.ldap.LDAPAttribute
-
- All Implemented Interfaces:
java.io.Serializable
public class LDAPAttribute extends java.lang.Object implements java.io.Serializable
Represents the name and values of an attribute in an entry.- Version:
- 1.0
- See Also:
LDAPAttributeSet
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description 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.LDAPAttribute(BERElement element)
Constructs an attribute from a BER (Basic Encoding Rules) element.LDAPAttribute(LDAPAttribute attr)
Constructs an attribute from another existing attribute.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addValue(byte[] attrValue)
Adds abyte[]
-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 currentLDAPAttribute
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 ofbyte[]
format.java.util.Enumeration<byte[]>
getByteValues()
Returns an enumerator for the values of the attribute inbyte[]
format.java.lang.String
getLangSubtype()
Extracts the language subtype from the attribute name of theLDAPAttribute
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 ofString
objects.java.util.Enumeration<java.lang.String>
getStringValues()
Returns an enumerator for the string values of an attribute.java.lang.String[]
getSubtypes()
Extracts the subtypes from the attribute name of the currentLDAPAttribute
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 subtypeslang-en
andphonetic
and the attribute name iscn;lang-en;phonetic
, this method returnstrue
.void
removeValue(byte[] attrValue)
Removes abyte[]
-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.
-
-
-
Constructor Detail
-
LDAPAttribute
public LDAPAttribute(LDAPAttribute attr)
Constructs an attribute from another existing attribute. Effectively, this makes a copy of the existing attribute.- Parameters:
attr
- the attribute to copy
-
LDAPAttribute
public LDAPAttribute(java.lang.String attrName)
Constructs an attribute with no values.- Parameters:
attrName
- name of the attribute
-
LDAPAttribute
public LDAPAttribute(java.lang.String attrName, byte[] attrValue)
Constructs an attribute with a byte-formatted value.- Parameters:
attrName
- name of the attributeattrValue
- value of the attribute in byte format
-
LDAPAttribute
public LDAPAttribute(java.lang.String attrName, java.lang.String attrValue)
Constructs an attribute that has a single string value.- Parameters:
attrName
- name of the attributeattrValue
- value of the attribute in String format
-
LDAPAttribute
public LDAPAttribute(java.lang.String attrName, java.lang.String[] attrValues)
Constructs an attribute that has an array of string values.- Parameters:
attrName
- name of the attributeattrValues
- the list of string values for this attribute
-
LDAPAttribute
public LDAPAttribute(BERElement element) throws java.io.IOException
Constructs an attribute from a BER (Basic Encoding Rules) element. (The protocol elements of LDAP are encoded for exchange using the Basic Encoding Rules.)- Parameters:
element
- element that you want translated into an attribute- Throws:
java.io.IOException
- The attribute could not be created from the specified element.
-
-
Method Detail
-
size
public int size()
Returns the number of values of the attribute.- Returns:
- number of values for this attribute.
-
getStringValues
public java.util.Enumeration<java.lang.String> getStringValues()
Returns an enumerator for the string values of an attribute.- Returns:
- enumerator for the string values.
-
getStringValueArray
public java.lang.String[] getStringValueArray()
Returns the values of the attribute as an array ofString
objects.- Returns:
- array of attribute values. Each element in the array
is a
String
object.
-
getByteValues
public java.util.Enumeration<byte[]> getByteValues()
Returns an enumerator for the values of the attribute inbyte[]
format.- Returns:
- a set of attribute values. Each element in the enumeration
is of type
byte[]
.
-
getByteValueArray
public byte[][] getByteValueArray()
Returns the values of the attribute in an array ofbyte[]
format.- Returns:
- array of attribute values. Each element in the array
will be of type
byte[]
.
-
getName
public java.lang.String getName()
Returns the name of the attribute.- Returns:
- name of the attribute.
-
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 iscn;lang-ja;phonetic
, this method returns an array containinglang-ja
andphonetic
.- Parameters:
attrName
- name of the attribute from which to extract the subtypes- Returns:
- array of subtypes, or null (if the name has no subtypes).
- See Also:
getBaseName(java.lang.String)
-
getSubtypes
public java.lang.String[] getSubtypes()
Extracts the subtypes from the attribute name of the currentLDAPAttribute
object. For example, if the attribute name iscn;lang-ja;phonetic
, this method returns an array containinglang-ja
andphonetic
.- Returns:
- array of subtypes, or null (if the name has no subtypes).
-
getLangSubtype
public java.lang.String getLangSubtype()
Extracts the language subtype from the attribute name of theLDAPAttribute
object, if any. For example, if the attribute name iscn;lang-ja;phonetic
, this method returns the Stringlang-ja
.- Returns:
- the language subtype, or null (if the name has no language subtype).
-
getBaseName
public static java.lang.String getBaseName(java.lang.String attrName)
Extracts the base name from the specified attribute name. For example, if the attribute name iscn;lang-ja;phonetic
, this method returnscn
.- Parameters:
attrName
- name of the attribute from which to extract the base name- Returns:
- base name (the attribute name without any subtypes).
- See Also:
getSubtypes(java.lang.String)
-
getBaseName
public java.lang.String getBaseName()
Extracts the base name from the attribute name of the currentLDAPAttribute
object. For example, if the attribute name iscn;lang-ja;phonetic
, this method returnscn
.- Returns:
- base name (the attribute name without any subtypes).
- See Also:
getSubtypes(java.lang.String)
-
hasSubtype
public boolean hasSubtype(java.lang.String subtype)
Reports whether the attribute name contains the specified subtype. For example, if you check for the subtypelang-en
and the attribute name iscn;lang-en
, this method returnstrue
.- Parameters:
subtype
- the single subtype for which you want to check- Returns:
- true if the attribute name contains the specified subtype.
- See Also:
getSubtypes(java.lang.String)
-
hasSubtypes
public boolean hasSubtypes(java.lang.String[] subtypes)
Reports if the attribute name contains all specified subtypes For example, if you check for the subtypeslang-en
andphonetic
and the attribute name iscn;lang-en;phonetic
, this method returnstrue
. If the attribute name iscn;phonetic
orcn;lang-en
, this method returnsfalse
.- Parameters:
subtypes
- an array of subtypes to check- Returns:
- true if the attribute name contains all subtypes
- See Also:
getSubtypes(java.lang.String)
-
addValue
public void addValue(java.lang.String attrValue)
Adds a string value to the attribute.- Parameters:
attrValue
- the string value to add to the attribute
-
setValues
protected void setValues(java.lang.String[] attrValues)
Sets the string values as the attribute's values.- Parameters:
attrValues
- the string values to use in the attribute
-
addValue
public void addValue(byte[] attrValue)
Adds abyte[]
-formatted value to the attribute.- Parameters:
attrValue
- thebyte[]
-formatted value to add to the attribute
-
setValues
protected void setValues(java.lang.Object[] attrValues)
Sets the byte[] values as the attribute's values.- Parameters:
attrValues
- the values to use in the attribute
-
removeValue
public void removeValue(java.lang.String attrValue)
Removes a string value from the attribute.- Parameters:
attrValue
- the string value to remove
-
removeValue
public void removeValue(byte[] attrValue)
Removes abyte[]
-formatted value from the attribute.- Parameters:
attrValue
-byte[]
-formatted value to remove
-
getBERElement
public BERElement getBERElement()
Retrieves the BER (Basic Encoding Rules) representation of an attribute. (The protocol elements of LDAP are encoded for exchange using the Basic Encoding Rules.)- Returns:
- the BER representation of the attribute.
-
toString
public java.lang.String toString()
Retrieves the string representation of an attribute in an LDAP entry. For example:LDAPAttribute {type='cn', values='Barbara Jensen,Babs Jensen'}
- Overrides:
toString
in classjava.lang.Object
- Returns:
- string representation of the attribute.
-
-