|
All LDAP Classes Internal LDAP Classes |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.novell.ldap.LDAPAttribute
public class LDAPAttribute
The name and values of one attribute of a directory entry.
LDAPAttribute objects are used when searching for, adding,
modifying, and deleting attributes from the directory.
LDAPAttributes are often used in conjunction with an
LDAPAttributeSet
when retrieving or adding multiple
attributes to an entry.
Sample Code: AddEntry.java
LDAPEntry
,
LDAPAttributeSet
,
LDAPModification
,
Serialized FormField Summary | |
---|---|
private java.lang.String |
baseName
|
private java.lang.String |
name
|
private java.lang.String[] |
subTypes
|
private java.lang.Object[] |
values
|
Constructor Summary | |
---|---|
LDAPAttribute()
This constructor was added to support default Serialization |
|
LDAPAttribute(LDAPAttribute attr)
Constructs an attribute with copies of all values of the input attribute. |
|
LDAPAttribute(java.lang.String attrName)
Constructs an attribute with no values. |
|
LDAPAttribute(java.lang.String attrName,
byte[] attrBytes)
Constructs an attribute with a byte-formatted value. |
|
LDAPAttribute(java.lang.String attrName,
java.lang.String attrString)
Constructs an attribute with a single string value. |
|
LDAPAttribute(java.lang.String attrName,
java.lang.String[] attrStrings)
Constructs an attribute with an array of string values. |
Method Summary | |
---|---|
private void |
add(byte[] bytes)
Adds an object to this object's list of attribute values |
void |
addBase64Value(char[] attrChars)
Adds a base64 encoded value to the attribute. |
void |
addBase64Value(java.lang.String attrString)
Adds a base64 encoded value to the attribute. |
void |
addBase64Value(java.lang.StringBuffer attrString,
int start,
int end)
Adds a base64 encoded value to the attribute. |
void |
addURLValue(java.lang.String url)
Adds a URL, indicating a file or other resource that contains the value of the attribute. |
void |
addURLValue(java.net.URL url)
Adds a URL, indicating a file or other resource that contains the value of the attribute. |
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. |
java.lang.Object |
clone()
Returns a clone of this LDAPAttribute. |
int |
compareTo(java.lang.Object attribute)
Compares this object with the specified object for order. |
private boolean |
equals(byte[] e1,
byte[] e2)
Returns true if the two specified arrays of bytes are equal to each another. |
java.lang.String |
getBaseName()
Returns the base name of the attribute. |
static java.lang.String |
getBaseName(java.lang.String attrName)
Returns the base name of the specified attribute name. |
byte[] |
getByteValue()
Returns the the first value of the attribute as a byte array. |
byte[][] |
getByteValueArray()
Returns the values of the attribute as an array of bytes. |
java.util.Enumeration |
getByteValues()
Returns an enumerator for the values of the attribute in byte format. |
java.lang.String |
getLangSubtype()
Returns the language subtype of the attribute, if any. |
java.lang.String |
getName()
Returns the name of the attribute. |
java.lang.String |
getStringValue()
Returns the the first value of the attribute as a String . |
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. |
static java.lang.String[] |
getSubtypes(java.lang.String attrName)
Extracts the subtypes from the specified attribute name. |
private static LDAPXMLHandler |
getTopXMLHandler(java.lang.String tagname,
LDAPXMLHandler parenthandler)
|
(package private) static LDAPXMLHandler |
getXMLHandler(java.lang.String tagname,
LDAPXMLHandler parenthandler)
This method return the LDAPHandler which handles the XML (DSML) tags for this class |
boolean |
hasSubtype(java.lang.String subtype)
Reports if the attribute name contains the specified subtype. |
boolean |
hasSubtypes(java.lang.String[] subtypes)
Reports if the attribute name contains all the specified subtypes. |
(package private) void |
newLine(int indentTabs,
java.io.Writer out)
|
static java.lang.Object |
readDSML(java.io.InputStream input)
This method is used to deserialize the DSML encoded representation of this class. |
void |
readExternal(java.io.ObjectInput in)
Reads the serialized object from the underlying input stream. |
void |
removeValue(byte[] attrBytes)
Removes a byte-formatted value from the attribute. |
void |
removeValue(java.lang.String attrString)
Removes a string value from the attribute. |
protected void |
setDeserializedValues(java.io.BufferedInputStream istream)
|
protected void |
setValue(java.lang.String value)
Replaces all values with the specified value. |
int |
size()
Returns the number of values in the attribute. |
java.lang.String |
toString()
Returns a string representation of this LDAPAttribute |
void |
writeDSML(java.io.OutputStream oout)
This method does DSML serialization of the instance. |
void |
writeExternal(java.io.ObjectOutput out)
Writes the object state to a stream in XML format |
protected void |
writeValue(java.lang.StringBuffer buff)
|
protected void |
writeValue(java.io.Writer out)
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.String name
private java.lang.String baseName
private java.lang.String[] subTypes
private java.lang.Object[] values
Constructor Detail |
---|
public LDAPAttribute()
public LDAPAttribute(LDAPAttribute attr)
attr
- An LDAPAttribute to use as a template.
java.lang.IllegalArgumentException
- if attr is nullpublic LDAPAttribute(java.lang.String attrName)
attrName
- Name of the attribute.
java.lang.IllegalArgumentException
- if attrName is nullpublic LDAPAttribute(java.lang.String attrName, byte[] attrBytes)
attrName
- Name of the attribute.attrBytes
- Value of the attribute as raw bytes.
Note: If attrBytes represents a string it should be UTF-8 encoded.
java.lang.IllegalArgumentException
- if attrName or attrBytes is nullpublic LDAPAttribute(java.lang.String attrName, java.lang.String attrString)
attrName
- Name of the attribute.attrString
- Value of the attribute as a string.
java.lang.IllegalArgumentException
- if attrName or attrString is nullpublic LDAPAttribute(java.lang.String attrName, java.lang.String[] attrStrings)
attrName
- Name of the attribute.attrStrings
- Array of values as strings.
java.lang.IllegalArgumentException
- if attrName, attrStrings, or a member
of attrStrings is nullMethod Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
public void addValue(java.lang.String attrString)
attrString
- Value of the attribute as a String.
java.lang.IllegalArgumentException
- if attrString is nullpublic void addValue(byte[] attrBytes)
attrBytes
- Value of the attribute as raw bytes.
Note: If attrBytes represents a string it should be UTF-8 encoded.
java.lang.IllegalArgumentException
- if attrBytes is nullpublic void addBase64Value(java.lang.String attrString)
attrString
- The base64 value of the attribute as a String.
java.lang.IllegalArgumentException
- if attrString is nullpublic void addBase64Value(java.lang.StringBuffer attrString, int start, int end)
attrString
- The base64 value of the attribute as a StringBuffer.start
- The start index of base64 encoded part, inclusive.end
- The end index of base encoded part, exclusive.
java.lang.IllegalArgumentException
- if attrString is nullpublic void addBase64Value(char[] attrChars)
attrChars
- The base64 value of the attribute as an array of
characters.
java.lang.IllegalArgumentException
- if attrString is nullpublic void addURLValue(java.lang.String url) throws java.net.MalformedURLException, java.io.IOException
url
- String value of a URL pointing to the resource containing
the value of the attribute.
java.lang.IllegalArgumentException
- if url is null
java.net.MalformedURLException
java.io.IOException
public void addURLValue(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException
url
- A URL class pointing to the resource containing the value
of the attribute.
java.lang.IllegalArgumentException
- if url is null
java.net.MalformedURLException
java.io.IOException
public java.util.Enumeration getByteValues()
Note: All string values will be UTF-8 encoded. To decode use the String constructor. Example: new String( byteArray, "UTF-8" );
public java.util.Enumeration getStringValues()
public byte[][] getByteValueArray()
public java.lang.String[] getStringValueArray()
public java.lang.String getStringValue()
String
.
String
value of the attribute's
value. If the value wasn't a UTF-8 encoded String
to begin with the value of the returned String
is
non deterministic.
If this
attribute has more than one value the
first value is converted to a UTF-8 encoded String
and returned. It should be noted, that the directory may
return attribute values in any order, so that the first
value may vary from one call to another.
If the attribute has no values null
is returned
public byte[] getByteValue()
this
attribute or
null
if this
attribute doesn't have a value.
If the attribute has no values null
is returned
public java.lang.String getLangSubtype()
For example, if the attribute name is cn;lang-ja;phonetic, this method returns the string, lang-ja.
public java.lang.String getBaseName()
For example, if the attribute name is cn;lang-ja;phonetic, this method returns cn.
public static java.lang.String getBaseName(java.lang.String attrName)
For example, if the attribute name is cn;lang-ja;phonetic, this method returns cn.
attrName
- Name of the attribute from which to extract the
base name.
java.lang.IllegalArgumentException
- if attrName is nullpublic java.lang.String getName()
public java.lang.String[] getSubtypes()
For example, if the attribute name is cn;lang-ja;phonetic, this method returns an array containing lang-ja and phonetic.
public static java.lang.String[] getSubtypes(java.lang.String attrName)
For example, if the attribute name is cn;lang-ja;phonetic, this method returns an array containing lang-ja and phonetic.
attrName
- Name of the attribute from which to extract
the subtypes.
java.lang.IllegalArgumentException
- if attrName is nullpublic boolean hasSubtype(java.lang.String subtype)
For example, if you check for the subtype lang-en and the attribute name is cn;lang-en, this method returns true.
subtype
- The single subtype to check for.
java.lang.IllegalArgumentException
- if subtype is nullpublic boolean hasSubtypes(java.lang.String[] subtypes)
For example, if you check for the subtypes lang-en and phonetic and if 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 check for.
java.lang.IllegalArgumentException
- if subtypes is null or if array member
is null.public void removeValue(java.lang.String attrString)
attrString
- Value of the attribute as a string.
Note: Removing a value which is not present in the attribute has no effect.
java.lang.IllegalArgumentException
- if attrString is nullpublic void removeValue(byte[] attrBytes)
attrBytes
- Value of the attribute as raw bytes.
Note: If attrBytes represents a string it should be UTF-8 encoded.
Example: String.getBytes("UTF-8");
Note: Removing a value which is not present in the attribute has no effect.
java.lang.IllegalArgumentException
- if attrBytes is nullpublic int size()
public int compareTo(java.lang.Object attribute)
Ordering is determined by comparing attribute names (see
getName()
) using the method compareTo() of the String class.
compareTo
in interface java.lang.Comparable
attribute
- The LDAPAttribute to be compared to this object.
private void add(byte[] bytes)
this
object's list of attribute values
bytes
- Ultimately all of this attribute's values are treated
as binary data so we simplify the process by requiring
that all data added to our list is in binary form.
Note: If attrBytes represents a string it should be UTF-8 encoded.
protected void setValue(java.lang.String value)
private boolean equals(byte[] e1, byte[] e2)
e1
- the first array to be testede2
- the second array to be tested
public java.lang.String toString()
toString
in class java.lang.Object
void newLine(int indentTabs, java.io.Writer out) throws java.io.IOException
java.io.IOException
public void writeDSML(java.io.OutputStream oout) throws java.io.IOException
oout
- Outputstream where the serialzed data has to be written
java.io.IOException
- if write fails on OutputStreamprotected void writeValue(java.io.Writer out) throws java.io.IOException
java.io.IOException
public static java.lang.Object readDSML(java.io.InputStream input) throws java.io.IOException
input
- InputStream for the DSML formatted data.
java.io.IOException
- when serialization fails.private static LDAPXMLHandler getTopXMLHandler(java.lang.String tagname, LDAPXMLHandler parenthandler)
static LDAPXMLHandler getXMLHandler(java.lang.String tagname, LDAPXMLHandler parenthandler)
tagname
- Name of the Root tag used to represent this class.parenthandler
- Parent LDAPXMLHandler for this tag.
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- The ObjectOutput stream where the Object in XML format
is being written to
java.io.IOException
- - If I/O errors occurprotected void writeValue(java.lang.StringBuffer buff)
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- The ObjectInput stream where the Serialized Object is being read from
java.io.IOException
- - If I/O errors occur
java.lang.ClassNotFoundException
- - If the class for an object being restored
cannot be found.protected void setDeserializedValues(java.io.BufferedInputStream istream) throws java.io.IOException
java.io.IOException
|
All LDAP Classes Internal LDAP Classes |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |