|
JNDI 1.1.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.naming.directory.BasicAttribute
This class provides a basic implementation of the Attribute interface.
This implementation does not support schema. The schema methods, getAttributeDefinition() and getAttributeSyntaxDefinition(), simply throw OperationNotSupportedException. Subclasses of BasicAttribute should override these methods if they support schemas.
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 java.lang.String |
attrID
Holds the attribute's id. |
protected java.util.Vector |
values
Holds the attribute's values. |
Constructor Summary | |
BasicAttribute(java.lang.String id)
Constructs a new instance of an attribute with no value. |
|
BasicAttribute(java.lang.String id,
java.lang.Object value)
Constructs a new instance of an attribute with a single value. |
Method Summary | |
boolean |
add(java.lang.Object attrVal)
Adds a new value to this attribute. |
void |
clear()
Removes all values from this attribute. |
java.lang.Object |
clone()
Makes a copy of this attribute. |
boolean |
contains(java.lang.Object attrVal)
Determines whether a value is in this attribute. |
boolean |
equals(java.lang.Object obj)
Determines whether obj is equal to this attribute. |
java.lang.Object |
get()
Retrieves one of this attribute's values. |
NamingEnumeration |
getAll()
Retrieves an enumeration of this attribute's values. |
DirContext |
getAttributeDefinition()
Retrieves this attribute's schema definition. |
DirContext |
getAttributeSyntaxDefinition()
Retrieves the syntax definition associated with this attribute. |
java.lang.String |
getID()
Retrieves the id of this attribute. |
int |
hashCode()
Calculates the hash code of this attribute. |
boolean |
remove(java.lang.Object attrval)
Removes a specified value from this attribute. |
int |
size()
Retrieves the number of values in this attribute. |
java.lang.String |
toString()
Generates the string representation of this attribute. |
Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected java.lang.String attrID
protected transient java.util.Vector values
Constructor Detail |
public BasicAttribute(java.lang.String id)
id
- The attribute's id. It cannot be null.public BasicAttribute(java.lang.String id, java.lang.Object value)
id
- The attribute's id. It cannot be null.value
- The attribute's value. If null, a null
value is added to the attribute.Method Detail |
public java.lang.Object clone()
public boolean equals(java.lang.Object obj)
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.
obj
- The possibly null object to check.hashCode()
,
contains(java.lang.Object)
public int hashCode()
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.
equals(java.lang.Object)
public java.lang.String toString()
public NamingEnumeration getAll() throws NamingException
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.
public java.lang.Object get() throws NamingException
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.
public int size()
public java.lang.String getID()
public boolean contains(java.lang.Object attrVal)
attrVal
- The possibly null value to check.equals(java.lang.Object)
public boolean add(java.lang.Object attrVal)
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.
attrVal
- The new possibly null value to add.public boolean remove(java.lang.Object attrval)
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.
attrVal
- The possibly null value to remove from this attribute.public void clear()
public DirContext getAttributeSyntaxDefinition() throws NamingException
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. This method by default throws OperationNotSupportedException. A subclass should override this method if it supports schema.
public DirContext getAttributeDefinition() throws NamingException
|
JNDI 1.1.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |