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

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

public class LockableAttributeImpl
extends Object
implements Attribute

Permanently Lockable ordered JNDI Attribute implementation.

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

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

Constructor Detail

LockableAttributeImpl

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

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

LockableAttributeImpl

public LockableAttributeImpl(String id,
                             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

LockableAttributeImpl

public LockableAttributeImpl(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
Method Detail

getAll

public NamingEnumeration getAll()
Gets a NamingEnumberation wrapped around the iterator of the value list.

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

get

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

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

size

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

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

getID

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

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

contains

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

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

add

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

Specified by:
add in interface 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(Object attrVal)
Removes attrVal from the list of this Attribute's values.

Specified by:
remove in interface 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 Attribute

getAttributeSyntaxDefinition

public DirContext getAttributeSyntaxDefinition()
                                        throws NamingException
NOT SUPPORTED - throws OperationNotSupportedException

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

getAttributeDefinition

public DirContext getAttributeDefinition()
                                  throws NamingException
NOT SUPPORTED - throws OperationNotSupportedException

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

clone

public Object clone()
Not a deep clone.

Specified by:
clone in interface Attribute
Overrides:
clone in class 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 Attribute
Returns:
true.

get

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

Specified by:
get in interface 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 Object remove(int index)
Removes the value at an index.

Specified by:
remove in interface 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,
                Object attrVal)
Inserts attrVal into the list of this Attribute's values at the specified index in the list.

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

set

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

Specified by:
set in interface 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.

equals

public boolean equals(Object obj)
Checks for equality between this Attribute instance and another. The lockable properties are not factored into the equality semantics and neither is the Attribute implementation. The Attribute ID's are compared with regard to case and value order is only considered if the Attribute arguement is ordered itself. TODO start looking at comparing syntaxes to determine if attributes are really equal

Overrides:
equals in class 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 String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2004-2012. All Rights Reserved.