org.springframework.core
Class AttributeAccessorSupport
- java.lang.Object
-
- org.springframework.core.AttributeAccessorSupport
-
- All Implemented Interfaces:
- Serializable, AttributeAccessor
public abstract class AttributeAccessorSupport extends Object implements AttributeAccessor, Serializable
Support class forAttributeAccessors
, providing a base implementation of all methods. To be extended by subclasses.Serializable
if subclasses and all attribute values areSerializable
.- Since:
- 2.0
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor and Description AttributeAccessorSupport()
Method Summary
Methods Modifier and Type Method and Description 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(Object other)
Object
getAttribute(String name)
Get the value of the attribute identified byname
.boolean
hasAttribute(String name)
Returntrue
if the attribute identified byname
exists.int
hashCode()
Object
removeAttribute(String name)
Remove the attribute identified byname
and return its value.void
setAttribute(String name, Object value)
Set the attribute defined byname
to the suppliedvalue
.
-
Method Detail
setAttribute
public void setAttribute(String name, Object value)
Description copied from interface:AttributeAccessor
Set the attribute defined byname
to the suppliedvalue
. Ifvalue
isnull
, the attribute isremoved
.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 interfaceAttributeAccessor
- Parameters:
-
name
- the unique attribute key -
value
- the attribute value to be attached
getAttribute
public Object getAttribute(String name)
Description copied from interface:AttributeAccessor
Get the value of the attribute identified byname
. Returnnull
if the attribute doesn't exist.- Specified by:
-
getAttribute
in interfaceAttributeAccessor
- Parameters:
-
name
- the unique attribute key - Returns:
- the current value of the attribute, if any
removeAttribute
public Object removeAttribute(String name)
Description copied from interface:AttributeAccessor
Remove the attribute identified byname
and return its value. Returnnull
if no attribute undername
is found.- Specified by:
-
removeAttribute
in interfaceAttributeAccessor
- Parameters:
-
name
- the unique attribute key - Returns:
- the last value of the attribute, if any
hasAttribute
public boolean hasAttribute(String name)
Description copied from interface:AttributeAccessor
Returntrue
if the attribute identified byname
exists. Otherwise returnfalse
.- Specified by:
-
hasAttribute
in interfaceAttributeAccessor
- Parameters:
-
name
- the unique attribute key
attributeNames
public String[] attributeNames()
Description copied from interface:AttributeAccessor
Return the names of all attributes.- Specified by:
-
attributeNames
in interfaceAttributeAccessor
copyAttributesFrom
protected void copyAttributesFrom(AttributeAccessor source)
Copy the attributes from the supplied AttributeAccessor to this accessor.- Parameters:
-
source
- the AttributeAccessor to copy from