All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface javax.naming.directory.Attribute

public interface Attribute
extends Cloneable, Serializable
This interface represents an attribute associated with a named object.

In a directory, named objects can have associated with them attributes. The Attribute interface represents an attribute associated with a named object. An attribute contains 0 or more values. The values are unordered, with no duplicates, and can be null.

The content and representation of an attribute and its values is defined by the attribute's schema. The schema contains information about the attribute's syntax and other properties about the attribute. See getAttributeDefinition() and getAttributeSyntaxDefinition() for details regarding how to get schema information about an attribute if the underlying directory service supports schemas.

Equality of two attributes is determined by the implementation class. A simple implementation can use Object.equals() to determine equality of attribute values, while a more sophisticated implementation might make use of schema information to determine equality. Similarly, one implementation might provide a static storage structure which simply returns the values passed to its constructor, while another implementation might define get() and getAll() to get the values dynamically from the directory.

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

See Also:
BasicAttribute

Method Index

 o add(Object)
Adds a new value to the attribute.
 o clear()
Removes all values from this attribute.
 o clone()
Makes a copy of the attribute.
 o contains(Object)
Determines whether a value is in the attribute.
 o get()
Retrieves one of this attribute's values.
 o getAll()
Retrieves an enumeration of the attribute's values.
 o getAttributeDefinition()
Retrieves the attribute's schema definition.
 o getAttributeSyntaxDefinition()
Retrieves the syntax definition associated with the attribute.
 o getID()
Retrieves the id of this attribute.
 o remove(Object)
Removes a specified value from the attribute.
 o size()
Retrieves the number of values in this attribute.

Methods

 o getAll
 public abstract NamingEnumeration getAll() throws NamingException
Retrieves an enumeration of the attribute's values. The behaviour of this enumeration is unspecified if the the attribute's values are added, changed, or removed while the enumeration is in progress.

Returns:
A non-null enumeration of the attribute's values. Each element of the enumeration is a possibly null Object. The object's class is the class of the attribute value. The element is null if the attribute's value is null. If the attribute has zero values, an empty enumeration is returned.
Throws: NamingException
If a naming exception was encountered while retrieving the values.
 o get
 public abstract Object get() throws NamingException
Retrieves one of this attribute's values. If the attribute has more than one value, any of the values are returned.

Returns:
A possibly null object representing one of the attribute's value. It is null if the attribute's value is null.
Throws: NamingException
If a naming exception was encountered while retrieving the value.
Throws: NoSuchElementException
If this attribute has no values.
 o size
 public abstract int size()
Retrieves the number of values in this attribute.

Returns:
The nonnegative number of values in this attribute.
 o getID
 public abstract String getID()
Retrieves the id of this attribute.

Returns:
The id of this attribute. It cannot be null.
 o contains
 public abstract boolean contains(Object attrVal)
Determines whether a value is in the attribute. Equality is determined by the implementation, which may use Object.equals() or schema information to determine equality.

Parameters:
attrVal - The possibly null value to check. If null, check whether the attribute has an attribute value whose value is null.
Returns:
true if attrVal is one of this attribute's values; false otherwise.
See Also:
equals, equals
 o add
 public abstract boolean add(Object attrVal)
Adds a new value to the attribute. If attrVal is already in the attribute, this method does nothing.

Equality is determined by the implementation, which may use Object.equals() or schema information to determine equality.

Parameters:
attrVal - The new possibly null value to add. If null, null is added as an attribute value.
Returns:
true If this attribute did not already have attrVal.
 o remove
 public abstract boolean remove(Object attrval)
Removes a specified value from the attribute. If attrval is not in the attribute, this method does nothing.

Equality is determined by the implementation, which may use Object.equals() or schema information to determine equality.

Parameters:
attrVal - The possibly null value to remove from this attribute. If null, remove the attribute value that is null.
Returns:
true if the value was removed; false otherwise.
 o clear
 public abstract void clear()
Removes all values from this attribute.

 o getAttributeSyntaxDefinition
 public abstract DirContext getAttributeSyntaxDefinition() throws NamingException
Retrieves the syntax definition associated with the attribute. An attribute's syntax definition specifies the format of the attribute's value(s). Note that this is different from the attribute value's representation as a Java object. Syntax definition refers to the directory's notion of syntax.

For example, even though a value might be a Java String object, its directory syntax might be "Printable String" or "Telephone Number". Or a value might be a byte array, and its directory syntax is "JPEG" or "Certificate". For example, if this attribute's syntax is "JPEG", this method would return the syntax definition for "JPEG".

The information that you can retrieve from a syntax definition is directory-dependent.

If an implementation does not support schemas, it should throw OperationNotSupportedException. If an implementation does support schemas, it should define this method to return the appropriate information.

Returns:
The attribute's syntax definition. Null if the implementation supports schemas but this particular attribute does not have any schema information.
Throws: OperationNotSupportedException
If getting the schema is not supported.
Throws: NamingException
If a naming exception occurs while getting the schema.
 o getAttributeDefinition
 public abstract DirContext getAttributeDefinition() throws NamingException
Retrieves the attribute's schema definition. An attribute's schema definition contains information such as whether the attribute is multivalued or single-valued, the matching rules to use when comparing the attribiute's values. The information that you can retrieve from an attribute definition is directory-dependent.

If an implementation does not support schemas, it should throw OperationNotSupportedException. If an implementation does support schemas, it should define this method to return the appropriate information.

Returns:
This attribute's schema definition. Null if the implementation supports schemas but this particular attribute does not have any schema information.
Throws: OperationNotSupportedException
If getting the schema is not supported.
Throws: NamingException
If a naming exception occurs while getting the schema.
 o clone
 public abstract Object clone()
Makes a copy of the attribute. The copy contains the same attribute values as the original attribute: the attribute values are not themselves cloned. Changes to the copy will not affect the original and vice versa.

Returns:
A non-null copy of the attribute.
Overrides:
clone in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index