org.apache.directory.shared.ldap.message
Class AttributeImpl

java.lang.Object
  extended by org.apache.directory.shared.ldap.message.AttributeImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.naming.directory.Attribute

public class AttributeImpl
extends java.lang.Object
implements javax.naming.directory.Attribute

Permanently Lockable ordered JNDI Attribute implementation.

Version:
$Rev: 656333 $
Author:
Apache Directory Project
See Also:
Serialized Form

Constructor Summary
AttributeImpl(javax.naming.directory.Attribute attribute)
          Create a copy of an Attribute, be it an AttributeImpl instance of a BasicAttribute instance
AttributeImpl(java.lang.String id)
          Creates a permanently Attribute on id whose locking behavior is dictated by parent.
AttributeImpl(java.lang.String id, byte[] value)
          Creates a permanently Attribute on id with a single value.
AttributeImpl(java.lang.String id, java.lang.Object value)
          Creates a permanently Attribute on id with a single value.
 
Method Summary
 void add(int index, java.lang.Object attrVal)
          Inserts attrVal into the list of this Attribute's values at the specified index in the list.
 boolean add(java.lang.Object attrVal)
          Adds attrVal into the list of this Attribute's values at the end of the list.
 void clear()
          Removes all the values of this Attribute from the list backing store.
 java.lang.Object clone()
          Not a deep clone.
 boolean contains(java.lang.Object attrVal)
          Checks to see if this Attribute contains attrVal in the list.
 boolean equals(java.lang.Object obj)
          Checks for equality between this Attribute instance and another.
 java.lang.Object get()
          Gets the first value of the list or null if no values exist.
 java.lang.Object get(int index)
          Gets the value at an index.
 javax.naming.NamingEnumeration<java.lang.Object> getAll()
          Gets a NamingEnumberation wrapped around the iterator of the value list.
 javax.naming.directory.DirContext getAttributeDefinition()
          NOT SUPPORTED - throws OperationNotSupportedException
 javax.naming.directory.DirContext getAttributeSyntaxDefinition()
          NOT SUPPORTED - throws OperationNotSupportedException
 java.lang.String getID()
          Gets the id or name of this Attribute.
 int hashCode()
          Compute the hash code for this attribute.
 boolean isOrdered()
          Always returns true since list is used to preserve value addition order.
 java.lang.Object remove(int index)
          Removes the value at an index.
 boolean remove(java.lang.Object attrVal)
          Removes attrVal from the list of this Attribute's values.
 java.lang.Object set(int index, java.lang.Object attrVal)
          Sets an attribute value in the ordered list of attribute values.
 int size()
          Gets the size of the value list.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AttributeImpl

public AttributeImpl(java.lang.String id)
Creates a permanently Attribute on id whose locking behavior is dictated by parent.

Parameters:
id - the id or name of this attribute.

AttributeImpl

public AttributeImpl(java.lang.String id,
                     java.lang.Object value)
Creates a permanently Attribute on id with a single value.

Parameters:
id - the id or name of this attribute.
value - a value for the attribute

AttributeImpl

public AttributeImpl(java.lang.String id,
                     byte[] value)
Creates a permanently Attribute on id with a single value.

Parameters:
id - the id or name of this attribute.
value - a value for the attribute

AttributeImpl

public AttributeImpl(javax.naming.directory.Attribute attribute)
              throws javax.naming.NamingException
Create a copy of an Attribute, be it an AttributeImpl instance of a BasicAttribute instance

Parameters:
attribute - the Attribute instace to copy
Throws:
javax.naming.NamingException
Method Detail

getAll

public javax.naming.NamingEnumeration<java.lang.Object> getAll()
Gets a NamingEnumberation wrapped around the iterator of the value list.

Specified by:
getAll in interface javax.naming.directory.Attribute
Returns:
the Iterator wrapped as a NamingEnumberation.

get

public java.lang.Object get()
Gets the first value of the list or null if no values exist.

Specified by:
get in interface javax.naming.directory.Attribute
Returns:
the first value or null.

size

public int size()
Gets the size of the value list.

Specified by:
size in interface javax.naming.directory.Attribute
Returns:
size of the value list.

getID

public java.lang.String getID()
Gets the id or name of this Attribute.

Specified by:
getID in interface javax.naming.directory.Attribute
Returns:
the identifier for this Attribute.

contains

public boolean contains(java.lang.Object attrVal)
Checks to see if this Attribute contains attrVal in the list.

Specified by:
contains in interface javax.naming.directory.Attribute
Parameters:
attrVal - the value to test for
Returns:
true if attrVal is in the list backing store, false otherwise

add

public boolean add(java.lang.Object attrVal)
Adds attrVal into the list of this Attribute's values at the end of the list.

Specified by:
add in interface javax.naming.directory.Attribute
Parameters:
attrVal - the value to add to the end of the list.
Returns:
true if attrVal is added to the list backing store, false if it already existed there.

remove

public boolean remove(java.lang.Object attrVal)
Removes attrVal from the list of this Attribute's values.

Specified by:
remove in interface javax.naming.directory.Attribute
Parameters:
attrVal - the value to remove
Returns:
true if attrVal is remove from the list backing store, false if never existed there.

clear

public void clear()
Removes all the values of this Attribute from the list backing store.

Specified by:
clear in interface javax.naming.directory.Attribute

getAttributeSyntaxDefinition

public javax.naming.directory.DirContext getAttributeSyntaxDefinition()
                                                               throws javax.naming.NamingException
NOT SUPPORTED - throws OperationNotSupportedException

Specified by:
getAttributeSyntaxDefinition in interface javax.naming.directory.Attribute
Throws:
javax.naming.NamingException
See Also:
Attribute.getAttributeSyntaxDefinition()

getAttributeDefinition

public javax.naming.directory.DirContext getAttributeDefinition()
                                                         throws javax.naming.NamingException
NOT SUPPORTED - throws OperationNotSupportedException

Specified by:
getAttributeDefinition in interface javax.naming.directory.Attribute
Throws:
javax.naming.NamingException
See Also:
Attribute.getAttributeDefinition()

clone

public java.lang.Object clone()
Not a deep clone.

Specified by:
clone in interface javax.naming.directory.Attribute
Overrides:
clone in class java.lang.Object
Returns:
a copy of this attribute using the same parent lock and id containing references to all the values of the original.

isOrdered

public boolean isOrdered()
Always returns true since list is used to preserve value addition order.

Specified by:
isOrdered in interface javax.naming.directory.Attribute
Returns:
true.

get

public java.lang.Object get(int index)
Gets the value at an index.

Specified by:
get in interface javax.naming.directory.Attribute
Parameters:
index - the index of the value in the ordered list of attribute values. 0 <= ix < size().
Returns:
this Attribute's value at the index null if no values exist.

remove

public java.lang.Object remove(int index)
Removes the value at an index.

Specified by:
remove in interface javax.naming.directory.Attribute
Parameters:
index - the index of the value in the ordered list of attribute values. 0 <= ix < size().
Returns:
this Attribute's value removed at the index

add

public void add(int index,
                java.lang.Object attrVal)
Inserts attrVal into the list of this Attribute's values at the specified index in the list.

Specified by:
add in interface javax.naming.directory.Attribute
Parameters:
index - the index to add the value at.
attrVal - the value to add to the end of the list.

set

public java.lang.Object set(int index,
                            java.lang.Object attrVal)
Sets an attribute value in the ordered list of attribute values.

Specified by:
set in interface javax.naming.directory.Attribute
Parameters:
index - the index to set the value to.
attrVal - the value to set at the index.
Returns:
the old value at the specified index.

hashCode

public int hashCode()
Compute the hash code for this attribute. It's a combinaison of the ID and all the values' hash codes.

Overrides:
hashCode in class java.lang.Object
Returns:
the instance's hash code
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object obj)
Checks for equality between this Attribute instance and another. The Attribute ID's aren't compared with regard to case. TODO start looking at comparing syntaxes to determine if attributes are really equal

Overrides:
equals in class java.lang.Object
Parameters:
obj - the Attribute to test for equality
Returns:
true if the obj is an Attribute and equals this Attribute false otherwise

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.