|
All LDAP Classes Internal LDAP Classes |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet
com.novell.ldap.LDAPAttributeSet
public class LDAPAttributeSet
A set of LDAPAttribute
objects.
An LDAPAttributeSet
is a collection of LDAPAttribute
classes as returned from an LDAPEntry
on a search or read
operation. LDAPAttributeSet
may be also used to contruct an entry
to be added to a directory. If the add()
or addAll()
methods are called and one or more of the objects to be added is not
an LDAPAttribute, ClassCastException
is thrown (as discussed in the
documentation for java.util.Collection
).
Sample Code: AddEntry.java
LDAPAttribute
,
LDAPEntry
,
Serialized FormField Summary | |
---|---|
private java.util.HashMap |
map
This is the underlying data structure for this set. |
Constructor Summary | |
---|---|
LDAPAttributeSet()
Constructs an empty set of attributes. |
Method Summary | |
---|---|
boolean |
add(java.lang.Object attr)
Adds the specified attribute to this set if it is not already present. |
boolean |
addAll(java.util.Collection c)
Adds all LDAPAttribute objects in the specified collection to
this collection. |
void |
clear()
Removes all of the elements from this set. |
java.lang.Object |
clone()
Returns a deep copy of this attribute set. |
boolean |
contains(java.lang.Object attr)
Returns true if this set contains an attribute of the same name
as the specified attribute. |
LDAPAttribute |
getAttribute(java.lang.String attrName)
Returns the attribute matching the specified attrName. |
LDAPAttribute |
getAttribute(java.lang.String attrName,
java.lang.String lang)
Returns a single best-match attribute, or null if no match is
available in the entry. |
LDAPAttributeSet |
getSubset(java.lang.String subtype)
Creates a new attribute set containing only the attributes that have the specified subtypes. |
(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 |
isEmpty()
Returns true if this set contains no elements |
java.util.Iterator |
iterator()
Returns an iterator over the attributes in this set. |
(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. |
boolean |
remove(java.lang.Object object)
Removes the specified object from this set if it is present. |
int |
size()
Returns the number of attributes in this set. |
java.lang.String |
toString()
Returns a string representation of this LDAPAttributeSet |
private void |
writeAttribute(LDAPAttribute attr,
java.lang.StringBuffer buff)
|
private void |
writeAttribute(LDAPAttribute attr,
java.io.Writer out)
|
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 |
Methods inherited from class java.util.AbstractSet |
---|
equals, hashCode, removeAll |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, retainAll, toArray, toArray |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
Field Detail |
---|
private java.util.HashMap map
HashSet is similar to the functionality of this set. The difference is we use the name of an attribute as keys in the Map and LDAPAttributes as the values. We also do not declare the map as transient, making the map serializable.
Constructor Detail |
---|
public LDAPAttributeSet()
Method Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
public LDAPAttribute getAttribute(java.lang.String attrName)
For example:
getAttribute("cn")
returns only the "cn" attributegetAttribute("cn;lang-en")
returns only the "cn;lang-en"
attribute.In both cases, null
is returned if there is no exact match to
the specified attrName.
Note: Novell eDirectory does not currently support language subtypes. It does support the "binary" subtype.
attrName
- The name of an attribute to retrieve, with or without
subtype specifications. For example, "cn", "cn;phonetic", and
"cn;binary" are valid attribute names.
null
if there is no exact match.public LDAPAttribute getAttribute(java.lang.String attrName, java.lang.String lang)
null
if no match is
available in the entry.
LDAP version 3 allows adding a subtype specification to an attribute name. For example, "cn;lang-ja" indicates a Japanese language subtype of the "cn" attribute and "cn;lang-ja-JP-kanji" may be a subtype of "cn;lang-ja". This feature may be used to provide multiple localizations in the same directory. For attributes which do not vary among localizations, only the base attribute may be stored, whereas for others there may be varying degrees of specialization.
For example, getAttribute(attrName,lang)
returns the
LDAPAttribute
that exactly matches attrName and that
best matches lang.
If there are subtypes other than "lang" subtypes included
in attrName, for example, "cn;binary", only attributes with all of
those subtypes are returned. If lang is null
or empty, the
method behaves as getAttribute(attrName). If there are no matching
attributes, null
is returned.
Assume the entry contains only the following attributes:
Examples:
getAttribute( "cn" )
returns null
.getAttribute( "sn" )
returns the "sn" attribute.getAttribute( "cn", "lang-en-us" )
returns the "cn;lang-en" attribute.getAttribute( "cn", "lang-en" )
returns the "cn;lang-en" attribute.getAttribute( "cn", "lang-ja" )
returns null
.getAttribute( "sn", "lang-en" )
returns the "sn" attribute.Note: Novell eDirectory does not currently support language subtypes. It does support the "binary" subtype.
attrName
- The name of an attribute to retrieve, with or without
subtype specifications. For example, "cn", "cn;phonetic", and
cn;binary" are valid attribute names.
lang
- A language specification with optional subtypes
appended using "-" as separator. For example, "lang-en", "lang-en-us",
"lang-ja", and "lang-ja-JP-kanji" are valid language specification.
LDAPAttribute
, or null
if no match is found in the entry.public LDAPAttributeSet getSubset(java.lang.String subtype)
For example, suppose an attribute set contains the following attributes:
Calling the getSubset
method and passing lang-ja as the
argument, the method returns an attribute set containing the following
attributes:
subtype
- Semi-colon delimited list of subtypes to include. For
example:
Note: Novell eDirectory does not currently support language subtypes. It does support the "binary" subtype.
public java.util.Iterator iterator()
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
iterator
in interface java.util.Set
iterator
in class java.util.AbstractCollection
public int size()
size
in interface java.util.Collection
size
in interface java.util.Set
size
in class java.util.AbstractCollection
public boolean isEmpty()
true
if this set contains no elements
isEmpty
in interface java.util.Collection
isEmpty
in interface java.util.Set
isEmpty
in class java.util.AbstractCollection
true
if this set contains no elementspublic boolean contains(java.lang.Object attr)
true
if this set contains an attribute of the same name
as the specified attribute.
contains
in interface java.util.Collection
contains
in interface java.util.Set
contains
in class java.util.AbstractCollection
attr
- Object of type LDAPAttribute
java.lang.ClassCastException
- occurs the specified Object
is not of type LDAPAttribute.public boolean add(java.lang.Object attr)
If an attribute with the same name already exists in the set then the specified attribute will not be added.
add
in interface java.util.Collection
add
in interface java.util.Set
add
in class java.util.AbstractCollection
attr
- Object of type LDAPAttribute
java.lang.ClassCastException
- occurs the specified Object
is not of type LDAPAttribute
.public boolean remove(java.lang.Object object)
If the specified object is of type LDAPAttribute
, the
specified attribute will be removed. If the specified object is of type
String
, the attribute with a name that matches the string will
be removed.
remove
in interface java.util.Collection
remove
in interface java.util.Set
remove
in class java.util.AbstractCollection
object
- LDAPAttribute to be removed or String
naming
the attribute to be removed.
java.lang.ClassCastException
- occurs the specified Object
is not of type LDAPAttribute
or of type String
.public void clear()
clear
in interface java.util.Collection
clear
in interface java.util.Set
clear
in class java.util.AbstractCollection
public boolean addAll(java.util.Collection c)
LDAPAttribute
objects in the specified collection to
this collection.
addAll
in interface java.util.Collection
addAll
in interface java.util.Set
addAll
in class java.util.AbstractCollection
c
- Collection of LDAPAttribute
objects.
java.lang.ClassCastException
- occurs when an element in the
collection is not of type LDAPAttribute
.public java.lang.String toString()
toString
in class java.util.AbstractCollection
void newLine(int indentTabs, java.io.Writer out) throws java.io.IOException
java.io.IOException
private void writeAttribute(LDAPAttribute attr, 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 OutputStreampublic 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.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.
private void writeAttribute(LDAPAttribute attr, java.lang.StringBuffer buff) throws java.io.IOException
java.io.IOException
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 occurpublic 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.
|
All LDAP Classes Internal LDAP Classes |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |