org.springframework.core
Class AttributeAccessorSupport

java.lang.Object
  extended by org.springframework.core.AttributeAccessorSupport
All Implemented Interfaces:
java.io.Serializable, AttributeAccessor
Direct Known Subclasses:
BeanMetadataAttributeAccessor, TestContext

public abstract class AttributeAccessorSupport
extends java.lang.Object
implements AttributeAccessor, java.io.Serializable

Support class for AttributeAccessors, providing a base implementation of all methods. To be extended by subclasses.

Serializable if subclasses and all attribute values are Serializable.

Since:
2.0
Author:
Rob Harrop, Juergen Hoeller
See Also:
Serialized Form

Constructor Summary
AttributeAccessorSupport()
           
 
Method Summary
 java.lang.String[] attributeNames()
          Return the names of all attributes.
protected  void copyAttributesFrom(AttributeAccessor source)
          Copy the attributes from the supplied AttributeAccessor to this accessor.
 boolean equals(java.lang.Object other)
           
 java.lang.Object getAttribute(java.lang.String name)
          Get the value of the attribute identified by name.
 boolean hasAttribute(java.lang.String name)
          Return true if the attribute identified by name exists.
 int hashCode()
           
 java.lang.Object removeAttribute(java.lang.String name)
          Remove the attribute identified by name and return its value.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set the attribute defined by name to the supplied value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeAccessorSupport

public AttributeAccessorSupport()
Method Detail

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Description copied from interface: AttributeAccessor
Set the attribute defined by name to the supplied value. If value is null, the attribute is removed.

In general, users should take care to prevent overlaps with other metadata attributes by using fully-qualified names, perhaps using class or package names as prefix.

Specified by:
setAttribute in interface AttributeAccessor
Parameters:
name - the unique attribute key
value - the attribute value to be attached

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface: AttributeAccessor
Get the value of the attribute identified by name. Return null if the attribute doesn't exist.

Specified by:
getAttribute in interface AttributeAccessor
Parameters:
name - the unique attribute key
Returns:
the current value of the attribute, if any

removeAttribute

public java.lang.Object removeAttribute(java.lang.String name)
Description copied from interface: AttributeAccessor
Remove the attribute identified by name and return its value. Return null if no attribute under name is found.

Specified by:
removeAttribute in interface AttributeAccessor
Parameters:
name - the unique attribute key
Returns:
the last value of the attribute, if any

hasAttribute

public boolean hasAttribute(java.lang.String name)
Description copied from interface: AttributeAccessor
Return true if the attribute identified by name exists. Otherwise return false.

Specified by:
hasAttribute in interface AttributeAccessor
Parameters:
name - the unique attribute key

attributeNames

public java.lang.String[] attributeNames()
Description copied from interface: AttributeAccessor
Return the names of all attributes.

Specified by:
attributeNames in interface AttributeAccessor

copyAttributesFrom

protected void copyAttributesFrom(AttributeAccessor source)
Copy the attributes from the supplied AttributeAccessor to this accessor.

Parameters:
source - the AttributeAccessor to copy from

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object