APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.naming.directory

public Class BasicAttributes

extends Object
implements Attributes
Class Inheritance
All Implemented Interfaces
javax.naming.directory.Attributes, java.io.Serializable, java.lang.Cloneable
Imports
java.util.Hashtable, .Enumeration, .Locale, javax.naming.NamingException, .NamingEnumeration

This class provides a basic implementation of the Attributes interface.

BasicAttributes is either case-sensitive or case-insensitive (case-ignore). This property is determined at the time the BasicAttributes constructor is called. In a case-insensitive BasicAttributes, the case of its attribute identifiers is ignored when searching for an attribute, or adding attributes. In a case-sensitive BasicAttributes, the case is significant.

When the BasicAttributes class needs to create an Attribute, it uses BasicAttribute. There is no other dependency on BasicAttribute.

Note that updates to BasicAttributes (such as adding or removing an attribute) does not affect the corresponding representation in the directory. Updates to the directory can only be effected using operations in the DirContext interface.

A BasicAttributes instance is not synchronized against concurrent multithreaded access. Multiple threads trying to access and modify a single BasicAttributes instance should lock the object.

Authors
Rosanna Lee, Scott Seligman
Since
1.3
See Also
DirContext#getAttributes, DirContext#modifyAttributes, DirContext#bind, DirContext#rebind, DirContext#createSubcontext, DirContext#search

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
pack-priv transient Hashtable<String, Attribute>
private boolean
ignoreCase

Indicates whether case of attribute ids is ignored.

private static final long
serialVersionUID

Use serialVersionUID from JNDI 1.1.1 for interoperability.

Constructor Summary

AccessConstructor and Description
public
BasicAttributes()

Constructs a new instance of Attributes.

public
BasicAttributes(boolean
true means this attribute set will ignore the case of its attribute identifiers when retrieving or adding attributes; false means case is respected.
ignoreCase
)

Constructs a new instance of Attributes.

public
BasicAttributes(String
non-null The id of the attribute to add.
attrID
,
Object
The value of the attribute to add. If null, a null value is added to the attribute.
val
)

Constructs a new instance of Attributes with one attribute.

public
BasicAttributes(String
non-null The id of the attribute to add. If this attribute set ignores the character case of its attribute ids, the case of attrID is ignored.
attrID
,
Object
The value of the attribute to add. If null, a null value is added to the attribute.
val
,
boolean
true means this attribute set will ignore the case of its attribute identifiers when retrieving or adding attributes; false means case is respected.
ignoreCase
)

Constructs a new instance of Attributes with one attribute.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Implements javax.naming.directory.Attributes.clone.

Makes a copy of the attribute set.

public boolean

Returns:

true If obj is equal to this BasicAttributes.
equals
(Object
the possibly null object to compare against.
obj
)

Overrides java.lang.Object.equals.

Determines whether this BasicAttributes is equal to another Attributes Two Attributes are equal if they are both instances of Attributes, treat the case of attribute IDs the same way, and contain the same attributes.

public Attribute
get(String attrID)

Implements javax.naming.directory.Attributes.get.

Retrieves the attribute with the given attribute id from the attribute set.

public NamingEnumeration<Attribute>
getAll()

Implements javax.naming.directory.Attributes.getAll.

Retrieves an enumeration of the attributes in the attribute set.

public NamingEnumeration<String>
getIDs()

Implements javax.naming.directory.Attributes.getIDs.

Retrieves an enumeration of the ids of the attributes in the attribute set.

public int

Returns:

an int representing the hash code of this BasicAttributes instance.
hashCode
()

Overrides java.lang.Object.hashCode.

Calculates the hash code of this BasicAttributes.

public boolean
isCaseIgnored()

Implements javax.naming.directory.Attributes.isCaseIgnored.

Determines whether the attribute set ignores the case of attribute identifiers when retrieving or adding attributes.

public Attribute
put(String attrID, Object val)

Implements javax.naming.directory.Attributes.put.

Adds a new attribute to the attribute set.

public Attribute
put(Attribute attr)

Implements javax.naming.directory.Attributes.put.

Adds a new attribute to the attribute set.

private void
readObject(ObjectInputStream
the ObjectInputStream to read from
s
)

The readObject method is called to restore the state of the BasicAttributes from a stream.

public Attribute
remove(String attrID)

Implements javax.naming.directory.Attributes.remove.

Removes the attribute with the attribute id 'attrID' from the attribute set.

public int
size()

Implements javax.naming.directory.Attributes.size.

Retrieves the number of attributes in the attribute set.

public String

Returns:

A non-null string listing the contents of this attribute set.
toString
()

Overrides java.lang.Object.toString.

Generates the string representation of this attribute set.

private void
writeObject(ObjectOutputStream
the ObjectOutputStream to write to
s
)

The writeObject method is called to save the state of the BasicAttributes to a stream.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

attrsback to summary
pack-priv transient Hashtable<String, Attribute> attrs
ignoreCaseback to summary
private boolean ignoreCase

Indicates whether case of attribute ids is ignored.

serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JNDI 1.1.1 for interoperability.

Annotations
@Serial

Constructor Detail

BasicAttributesback to summary
public BasicAttributes()

Constructs a new instance of Attributes. The character case of attribute identifiers is significant when subsequently retrieving or adding attributes.

BasicAttributesback to summary
public BasicAttributes(boolean ignoreCase)

Constructs a new instance of Attributes. If ignoreCase is true, the character case of attribute identifiers is ignored; otherwise the case is significant.

Parameters
ignoreCase:boolean

true means this attribute set will ignore the case of its attribute identifiers when retrieving or adding attributes; false means case is respected.

BasicAttributesback to summary
public BasicAttributes(String attrID, Object val)

Constructs a new instance of Attributes with one attribute. The attribute specified by attrID and val are added to the newly created attribute. The character case of attribute identifiers is significant when subsequently retrieving or adding attributes.

Parameters
attrID:String

non-null The id of the attribute to add.

val:Object

The value of the attribute to add. If null, a null value is added to the attribute.

BasicAttributesback to summary
public BasicAttributes(String attrID, Object val, boolean ignoreCase)

Constructs a new instance of Attributes with one attribute. The attribute specified by attrID and val are added to the newly created attribute. If ignoreCase is true, the character case of attribute identifiers is ignored; otherwise the case is significant.

Parameters
attrID:String

non-null The id of the attribute to add. If this attribute set ignores the character case of its attribute ids, the case of attrID is ignored.

val:Object

The value of the attribute to add. If null, a null value is added to the attribute.

ignoreCase:boolean

true means this attribute set will ignore the case of its attribute identifiers when retrieving or adding attributes; false means case is respected.

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Implements javax.naming.directory.Attributes.clone.

Doc from javax.naming.directory.Attributes.clone.

Makes a copy of the attribute set. The new set contains the same attributes as the original set: the attributes are not themselves cloned. Changes to the copy will not affect the original and vice versa.

Annotations
@SuppressWarnings:unchecked
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Determines whether this BasicAttributes is equal to another Attributes Two Attributes are equal if they are both instances of Attributes, treat the case of attribute IDs the same way, and contain the same attributes. Each Attribute in this BasicAttributes is checked for equality using Object.equals(), which may have be overridden by implementations of Attribute). If a subclass overrides equals(), it should override hashCode() as well so that two Attributes instances that are equal have the same hash code.

Parameters
obj:Object

the possibly null object to compare against.

Returns:boolean

true If obj is equal to this BasicAttributes.

See Also
hashCode
getback to summary
public Attribute get(String attrID)

Implements javax.naming.directory.Attributes.get.

Doc from javax.naming.directory.Attributes.get.

Retrieves the attribute with the given attribute id from the attribute set.

getAllback to summary
public NamingEnumeration<Attribute> getAll()

Implements javax.naming.directory.Attributes.getAll.

Doc from javax.naming.directory.Attributes.getAll.

Retrieves an enumeration of the attributes in the attribute set. The effects of updates to this attribute set on this enumeration are undefined.

getIDsback to summary
public NamingEnumeration<String> getIDs()

Implements javax.naming.directory.Attributes.getIDs.

Doc from javax.naming.directory.Attributes.getIDs.

Retrieves an enumeration of the ids of the attributes in the attribute set. The effects of updates to this attribute set on this enumeration are undefined.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Calculates the hash code of this BasicAttributes.

The hash code is computed by adding the hash code of the attributes of this object. If this BasicAttributes ignores case of its attribute IDs, one is added to the hash code. If a subclass overrides hashCode(), it should override equals() as well so that two Attributes instances that are equal have the same hash code.

Returns:int

an int representing the hash code of this BasicAttributes instance.

See Also
equals
isCaseIgnoredback to summary
public boolean isCaseIgnored()

Implements javax.naming.directory.Attributes.isCaseIgnored.

Doc from javax.naming.directory.Attributes.isCaseIgnored.

Determines whether the attribute set ignores the case of attribute identifiers when retrieving or adding attributes.

putback to summary
public Attribute put(String attrID, Object val)

Implements javax.naming.directory.Attributes.put.

Doc from javax.naming.directory.Attributes.put.

Adds a new attribute to the attribute set.

putback to summary
public Attribute put(Attribute attr)

Implements javax.naming.directory.Attributes.put.

Doc from javax.naming.directory.Attributes.put.

Adds a new attribute to the attribute set.

readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

The readObject method is called to restore the state of the BasicAttributes from a stream. See writeObject for a description of the serial form.

Parameters
s:ObjectInputStream

the ObjectInputStream to read from

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if the class of a serialized object could not be found
removeback to summary
public Attribute remove(String attrID)

Implements javax.naming.directory.Attributes.remove.

Doc from javax.naming.directory.Attributes.remove.

Removes the attribute with the attribute id 'attrID' from the attribute set. If the attribute does not exist, ignore.

sizeback to summary
public int size()

Implements javax.naming.directory.Attributes.size.

Doc from javax.naming.directory.Attributes.size.

Retrieves the number of attributes in the attribute set.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Generates the string representation of this attribute set. The string consists of each attribute identifier and the contents of each attribute. The contents of this string is useful for debugging and is not meant to be interpreted programmatically.

Returns:String

A non-null string listing the contents of this attribute set.

writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

The writeObject method is called to save the state of the BasicAttributes to a stream.

Parameters
s:ObjectOutputStream

the ObjectOutputStream to write to

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
Serial data
Default field (ignoreCase flag - a boolean), followed by the number of attributes in the set (an int), and then the individual Attribute objects.
javax.naming.directory back to summary

pack-priv Class BasicAttributes.AttrEnumImpl

extends Object
implements NamingEnumeration<Attribute>
Class Inheritance
All Implemented Interfaces
javax.naming.NamingEnumeration, java.util.Enumeration

Field Summary

Modifier and TypeField and Description
pack-priv Enumeration<Attribute>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements javax.naming.NamingEnumeration.close.

Closes this enumeration.

public boolean
hasMore()

Implements javax.naming.NamingEnumeration.hasMore.

Determines whether there are any more elements in the enumeration.

public boolean
hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.

public Attribute
next()

Implements javax.naming.NamingEnumeration.next.

Retrieves the next element in the enumeration.

public Attribute
nextElement()

Implements java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

elementsback to summary
pack-priv Enumeration<Attribute> elements

Constructor Detail

AttrEnumImplback to summary
public AttrEnumImpl()

Method Detail

closeback to summary
public void close() throws NamingException

Implements javax.naming.NamingEnumeration.close.

Doc from javax.naming.NamingEnumeration.close.

Closes this enumeration. After this method has been invoked on this enumeration, the enumeration becomes invalid and subsequent invocation of any of its methods will yield undefined results. This method is intended for aborting an enumeration to free up resources. If an enumeration proceeds to the end--that is, until hasMoreElements() or hasMore() returns false-- resources will be freed up automatically and there is no need to explicitly call close().

This method indicates to the service provider that it is free to release resources associated with the enumeration, and can notify servers to cancel any outstanding requests. The close() method is a hint to implementations for managing their resources. Implementations are encouraged to use appropriate algorithms to manage their resources when client omits the close() calls.

Exceptions
NamingException:
If a naming exception is encountered while closing the enumeration.
hasMoreback to summary
public boolean hasMore() throws NamingException

Implements javax.naming.NamingEnumeration.hasMore.

Doc from javax.naming.NamingEnumeration.hasMore.

Determines whether there are any more elements in the enumeration. This method allows naming exceptions encountered while determining whether there are more elements to be caught and handled by the application.

Exceptions
NamingException:
If a naming exception is encountered while attempting to determine whether there is another element in the enumeration. See NamingException and its subclasses for the possible naming exceptions.
hasMoreElementsback to summary
public boolean hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Doc from java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.

nextback to summary
public Attribute next() throws NamingException

Implements javax.naming.NamingEnumeration.next.

Doc from javax.naming.NamingEnumeration.next.

Retrieves the next element in the enumeration. This method allows naming exceptions encountered while retrieving the next element to be caught and handled by the application.

Note that next() can also throw the runtime exception NoSuchElementException to indicate that the caller is attempting to enumerate beyond the end of the enumeration. This is different from a NamingException, which indicates that there was a problem in obtaining the next element, for example, due to a referral or server unavailability, etc.

Exceptions
NamingException:
If a naming exception is encountered while attempting to retrieve the next element. See NamingException and its subclasses for the possible naming exceptions.
nextElementback to summary
public Attribute nextElement()

Implements java.util.Enumeration.nextElement.

Doc from java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

javax.naming.directory back to summary

pack-priv Class BasicAttributes.IDEnumImpl

extends Object
implements NamingEnumeration<String>
Class Inheritance
All Implemented Interfaces
javax.naming.NamingEnumeration, java.util.Enumeration

Field Summary

Modifier and TypeField and Description
pack-priv Enumeration<Attribute>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements javax.naming.NamingEnumeration.close.

Closes this enumeration.

public boolean
hasMore()

Implements javax.naming.NamingEnumeration.hasMore.

Determines whether there are any more elements in the enumeration.

public boolean
hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.

public String
next()

Implements javax.naming.NamingEnumeration.next.

Retrieves the next element in the enumeration.

public String
nextElement()

Implements java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

elementsback to summary
pack-priv Enumeration<Attribute> elements

Constructor Detail

IDEnumImplback to summary
public IDEnumImpl()

Method Detail

closeback to summary
public void close() throws NamingException

Implements javax.naming.NamingEnumeration.close.

Doc from javax.naming.NamingEnumeration.close.

Closes this enumeration. After this method has been invoked on this enumeration, the enumeration becomes invalid and subsequent invocation of any of its methods will yield undefined results. This method is intended for aborting an enumeration to free up resources. If an enumeration proceeds to the end--that is, until hasMoreElements() or hasMore() returns false-- resources will be freed up automatically and there is no need to explicitly call close().

This method indicates to the service provider that it is free to release resources associated with the enumeration, and can notify servers to cancel any outstanding requests. The close() method is a hint to implementations for managing their resources. Implementations are encouraged to use appropriate algorithms to manage their resources when client omits the close() calls.

Exceptions
NamingException:
If a naming exception is encountered while closing the enumeration.
hasMoreback to summary
public boolean hasMore() throws NamingException

Implements javax.naming.NamingEnumeration.hasMore.

Doc from javax.naming.NamingEnumeration.hasMore.

Determines whether there are any more elements in the enumeration. This method allows naming exceptions encountered while determining whether there are more elements to be caught and handled by the application.

Exceptions
NamingException:
If a naming exception is encountered while attempting to determine whether there is another element in the enumeration. See NamingException and its subclasses for the possible naming exceptions.
hasMoreElementsback to summary
public boolean hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Doc from java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.

nextback to summary
public String next() throws NamingException

Implements javax.naming.NamingEnumeration.next.

Doc from javax.naming.NamingEnumeration.next.

Retrieves the next element in the enumeration. This method allows naming exceptions encountered while retrieving the next element to be caught and handled by the application.

Note that next() can also throw the runtime exception NoSuchElementException to indicate that the caller is attempting to enumerate beyond the end of the enumeration. This is different from a NamingException, which indicates that there was a problem in obtaining the next element, for example, due to a referral or server unavailability, etc.

Exceptions
NamingException:
If a naming exception is encountered while attempting to retrieve the next element. See NamingException and its subclasses for the possible naming exceptions.
nextElementback to summary
public String nextElement()

Implements java.util.Enumeration.nextElement.

Doc from java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.