This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.naming.directory
class BasicAttribute

java.lang.Object extended by javax.naming.directory.BasicAttribute
All Implemented Interfaces:
Attribute

Most common ways to construct:

BasicAttribute objectclass = new BasicAttribute("objectclass");

Based on 10 examples

 

String groupdn = …;

BasicAttribute oc = new BasicAttribute("groupMembership", groupdn);

Based on 10 examples


public class BasicAttribute
extends Object
implements Attribute

This class provides a basic implementation of the Attribute interface.

This implementation does not support the schema methods getAttributeDefinition() and getAttributeSyntaxDefinition(). They simply throw OperationNotSupportedException. Subclasses of BasicAttribute should override these methods if they support them.

The BasicAttribute class by default uses Object.equals() to determine equality of attribute values when testing for equality or when searching for values, except when the value is an array. For an array, each element of the array is checked using Object.equals(). Subclasses of BasicAttribute can make use of schema information when doing similar equality checks by overriding methods in which such use of schema is meaningful. Similarly, the BasicAttribute class by default returns the values passed to its constructor and/or manipulated using the add/remove methods. Subclasses of BasicAttribute can override get() and getAll() to get the values dynamically from the directory (or implement the Attribute interface directly instead of subclassing BasicAttribute).

Note that updates to BasicAttribute (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.

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


Field Summary
protected String attrID
          Holds the attribute's id.
protected boolean ordered
          A flag for recording whether this attribute's values are ordered.
protected transient Vector values
          Holds the attribute's values.
 
Constructor Summary

          Constructs a new instance of an unordered attribute with no value.
BasicAttribute(String id, boolean ordered)

          Constructs a new instance of a possibly ordered attribute with no value.

          Constructs a new instance of an unordered attribute with a single value.
BasicAttribute(String id, Object value, boolean ordered)

          Constructs a new instance of a possibly ordered attribute with a single value.
 
Method Summary
 void
add(int ix, Object attrVal)

          
 boolean
add(Object attrVal)

          Adds a new value to this attribute.
 void

          
 Object

          Creates and returns a copy of this object.
 boolean
contains(Object attrVal)

          Determines whether a value is in this attribute.
 boolean

          Determines whether obj is equal to this attribute.
 Object
get()

          Retrieves one of this attribute's values.
 Object
get(int ix)

          
 NamingEnumeration

          Retrieves an enumeration of this attribute's values.
 DirContext

          Retrieves this attribute's schema definition.
 DirContext

          Retrieves the syntax definition associated with this attribute.
 String

          
 int

          Calculates the hash code of this attribute.
 boolean

          
 Object
remove(int ix)

          
 boolean
remove(Object attrval)

          Removes a specified value from this attribute.
 Object
set(int ix, Object attrVal)

          
 int

          
 String

          Generates the string representation of this attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attrID

protected String attrID
Holds the attribute's id. It is initialized by the public constructor and cannot be null unless methods in BasicAttribute that use attrID have been overridden.

ordered

protected boolean ordered
A flag for recording whether this attribute's values are ordered.

values

protected transient Vector values
Holds the attribute's values. Initialized by public constructors. Cannot be null unless methods in BasicAttribute that use values have been overridden.
Constructor Detail

BasicAttribute

public BasicAttribute(String id)
Constructs a new instance of an unordered attribute with no value.

Parameters:
id - The attribute's id. It cannot be null.

BasicAttribute

public BasicAttribute(String id,
                      boolean ordered)
Constructs a new instance of a possibly ordered attribute with no value.

Parameters:
id - The attribute's id. It cannot be null.
ordered - true means the attribute's values will be ordered; false otherwise.

BasicAttribute

public BasicAttribute(String id,
                      Object value)
Constructs a new instance of an unordered attribute with a single value.

Parameters:
id - The attribute's id. It cannot be null.
value - The attribute's value. If null, a null value is added to the attribute.

BasicAttribute

public BasicAttribute(String id,
                      Object value,
                      boolean ordered)
Constructs a new instance of a possibly ordered attribute with a single value.

Parameters:
id - The attribute's id. It cannot be null.
value - The attribute's value. If null, a null value is added to the attribute.
ordered - true means the attribute's values will be ordered; false otherwise.
Method Detail

add

public void add(int ix,
                Object attrVal)
Parameters:
ix
attrVal

add

public boolean add(Object attrVal)
Adds a new value to this attribute.

By default, Object.equals() is used when comparing attrVal with this attribute's values except when attrVal is an array. For an array, each element of the array is checked using Object.equals(). A subclass may use schema information to determine equality.

Parameters:
attrVal

clear

public void clear()

clone

public Object clone()
Overrides:
clone in class Object

contains

public boolean contains(Object attrVal)
Determines whether a value is in this attribute.

By default, Object.equals() is used when comparing attrVal with this attribute's values except when attrVal is an array. For an array, each element of the array is checked using Object.equals(). A subclass may use schema information to determine equality.

Parameters:
attrVal

equals

public boolean equals(Object obj)
Determines whether obj is equal to this attribute. Two attributes are equal if their attribute-ids, syntaxes and values are equal. If the attribute values are unordered, the order that the values were added are irrelevant. If the attribute values are ordered, then the order the values must match. If obj is null or not an Attribute, false is returned.

By default Object.equals() is used when comparing the attribute id and its values except when a value is an array. For an array, each element of the array is checked using Object.equals(). A subclass may override this to make use of schema syntax information and matching rules, which define what it means for two attributes to be equal. How and whether a subclass makes use of the schema information is determined by the subclass. If a subclass overrides equals(), it should also override hashCode() such that two attributes that are equal have the same hash code.

Overrides:
equals in class Object
Parameters:
obj - The possibly null object to check.
Returns:
true if obj is equal to this attribute; false otherwise.

get

public Object get()
           throws NamingException
Retrieves one of this attribute's values.

By default, the value returned is one of those passed to the constructor and/or manipulated using the add/replace/remove methods. A subclass may override this to retrieve the value dynamically from the directory.

Throws:
NamingException

get

public Object get(int ix)
           throws NamingException
Parameters:
ix
Throws:
NamingException

getAll

public NamingEnumeration getAll()
                         throws NamingException
Retrieves an enumeration of this attribute's values.

By default, the values returned are those passed to the constructor and/or manipulated using the add/replace/remove methods. A subclass may override this to retrieve the values dynamically from the directory.

Throws:
NamingException

getAttributeDefinition

public DirContext getAttributeDefinition()
                                  throws NamingException
Retrieves this attribute's schema definition.

This method by default throws OperationNotSupportedException. A subclass should override this method if it supports schema.

Throws:
NamingException

getAttributeSyntaxDefinition

public DirContext getAttributeSyntaxDefinition()
                                        throws NamingException
Retrieves the syntax definition associated with this attribute.

This method by default throws OperationNotSupportedException. A subclass should override this method if it supports schema.

Throws:
NamingException

getID

public String getID()

hashCode

public int hashCode()
Calculates the hash code of this attribute.

The hash code is computed by adding the hash code of the attribute's id and that of all of its values except for values that are arrays. For an array, the hash code of each element of the array is summed. If a subclass overrides hashCode(), it should override equals() as well so that two attributes that are equal have the same hash code.

Overrides:
hashCode in class Object
Returns:
an int representing the hash code of this attribute.

isOrdered

public boolean isOrdered()

remove

public Object remove(int ix)
Parameters:
ix

remove

public boolean remove(Object attrval)
Removes a specified value from this attribute.

By default, Object.equals() is used when comparing attrVal with this attribute's values except when attrVal is an array. For an array, each element of the array is checked using Object.equals(). A subclass may use schema information to determine equality.

Parameters:
attrval

set

public Object set(int ix,
                  Object attrVal)
Parameters:
ix
attrVal

size

public int size()

toString

public String toString()
Generates the string representation of this attribute. The string consists of the attribute's id and its values. This string is meant for debugging and not meant to be interpreted programmatically.

Overrides:
toString in class Object
Returns:
The non-null string representation of this attribute.


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.