Package netscape.ldap
Class LDAPAttribute
java.lang.Object
netscape.ldap.LDAPAttribute
- All Implemented Interfaces:
Serializable
Represents the name and values of an attribute in an entry.
- Version:
- 1.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLDAPAttribute(String attrName) Constructs an attribute with no values.LDAPAttribute(String attrName, byte[] attrValue) Constructs an attribute with a byte-formatted value.LDAPAttribute(String attrName, String attrValue) Constructs an attribute that has a single string value.LDAPAttribute(String attrName, 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
Modifier and TypeMethodDescriptionvoidaddValue(byte[] attrValue) Adds abyte[]-formatted value to the attribute.voidAdds a string value to the attribute.private static booleanequalValue(byte[] a, byte[] b) Extracts the base name from the attribute name of the currentLDAPAttributeobject.static StringgetBaseName(String attrName) Extracts the base name from the specified attribute name.Retrieves the BER (Basic Encoding Rules) representation of an attribute.byte[][]Returns the values of the attribute in an array ofbyte[]format.Enumeration<byte[]> Returns an enumerator for the values of the attribute inbyte[]format.Extracts the language subtype from the attribute name of theLDAPAttributeobject, if any.getName()Returns the name of the attribute.private StringRetrieves the string representation of attribute parameters.String[]Returns the values of the attribute as an array ofStringobjects.Returns an enumerator for the string values of an attribute.String[]Extracts the subtypes from the attribute name of the currentLDAPAttributeobject.static String[]getSubtypes(String attrName) Extracts the subtypes from the specified attribute name.booleanhasSubtype(String subtype) Reports whether the attribute name contains the specified subtype.booleanhasSubtypes(String[] subtypes) Reports if the attribute name contains all specified subtypes For example, if you check for the subtypeslang-enandphoneticand the attribute name iscn;lang-en;phonetic, this method returnstrue.voidremoveValue(byte[] attrValue) Removes abyte[]-formatted value from the attribute.voidremoveValue(String attrValue) Removes a string value from the attribute.protected voidSets the byte[] values as the attribute's values.protected voidSets the string values as the attribute's values.intsize()Returns the number of values of the attribute.toString()Retrieves the string representation of an attribute in an LDAP entry.
-
Field Details
-
serialVersionUID
static final long serialVersionUID- See Also:
-
name
-
nameBuf
private byte[] nameBuf -
values
Internally, this is a list of "byte[]"-based attribute values.
-
-
Constructor Details
-
LDAPAttribute
Constructs an attribute from another existing attribute. Effectively, this makes a copy of the existing attribute.- Parameters:
attr- the attribute to copy
-
LDAPAttribute
Constructs an attribute with no values.- Parameters:
attrName- name of the attribute
-
LDAPAttribute
Constructs an attribute with a byte-formatted value.- Parameters:
attrName- name of the attributeattrValue- value of the attribute in byte format
-
LDAPAttribute
Constructs an attribute that has a single string value.- Parameters:
attrName- name of the attributeattrValue- value of the attribute in String format
-
LDAPAttribute
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
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:
IOException- The attribute could not be created from the specified element.
-
-
Method Details
-
size
public int size()Returns the number of values of the attribute.- Returns:
- number of values for this attribute.
-
getStringValues
Returns an enumerator for the string values of an attribute.- Returns:
- enumerator for the string values.
-
getStringValueArray
Returns the values of the attribute as an array ofStringobjects.- Returns:
- array of attribute values. Each element in the array
is a
Stringobject.
-
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
Returns the name of the attribute.- Returns:
- name of the attribute.
-
getSubtypes
Extracts the subtypes from the specified attribute name. For example, if the attribute name iscn;lang-ja;phonetic, this method returns an array containinglang-jaandphonetic.- 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:
-
getSubtypes
Extracts the subtypes from the attribute name of the currentLDAPAttributeobject. For example, if the attribute name iscn;lang-ja;phonetic, this method returns an array containinglang-jaandphonetic.- Returns:
- array of subtypes, or null (if the name has no subtypes).
-
getLangSubtype
Extracts the language subtype from the attribute name of theLDAPAttributeobject, 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
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:
-
getBaseName
Extracts the base name from the attribute name of the currentLDAPAttributeobject. For example, if the attribute name iscn;lang-ja;phonetic, this method returnscn.- Returns:
- base name (the attribute name without any subtypes).
- See Also:
-
hasSubtype
Reports whether the attribute name contains the specified subtype. For example, if you check for the subtypelang-enand 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:
-
hasSubtypes
Reports if the attribute name contains all specified subtypes For example, if you check for the subtypeslang-enandphoneticand the attribute name iscn;lang-en;phonetic, this method returnstrue. If the attribute name iscn;phoneticorcn;lang-en, this method returnsfalse.- Parameters:
subtypes- an array of subtypes to check- Returns:
- true if the attribute name contains all subtypes
- See Also:
-
addValue
Adds a string value to the attribute.- Parameters:
attrValue- the string value to add to the attribute
-
setValues
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
Sets the byte[] values as the attribute's values.- Parameters:
attrValues- the values to use in the attribute
-
removeValue
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
-
equalValue
private static boolean equalValue(byte[] a, byte[] b) -
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.
-
getParamString
Retrieves the string representation of attribute parameters.- Returns:
- string representation parameters.
-
toString
Retrieves the string representation of an attribute in an LDAP entry. For example:LDAPAttribute {type='cn', values='Barbara Jensen,Babs Jensen'}
-