org.springframework.webflow.core.collection
Class LocalAttributeMap

java.lang.Object
  extended by org.springframework.webflow.core.collection.LocalAttributeMap
All Implemented Interfaces:
java.io.Serializable, org.springframework.binding.collection.MapAdaptable, AttributeMap, MutableAttributeMap
Direct Known Subclasses:
LocalSharedAttributeMap

public class LocalAttributeMap
extends java.lang.Object
implements MutableAttributeMap, java.io.Serializable

A generic, mutable attribute map with string keys.

Author:
Keith Donald
See Also:
Serialized Form

Constructor Summary
LocalAttributeMap()
          Creates a new attribute map, initially empty.
LocalAttributeMap(int size, int loadFactor)
          Creates a new attribute map, initially empty.
LocalAttributeMap(java.util.Map map)
          Creates a new attribute map wrapping the specified map.
LocalAttributeMap(java.lang.String attributeName, java.lang.Object attributeValue)
          Creates a new attribute map with a single entry.
 
Method Summary
 java.util.Map asMap()
           
 MutableAttributeMap clear()
          Remove all attributes in this map.
 boolean contains(java.lang.String attributeName)
          Does the attribute with the provided name exist in this map?
 boolean contains(java.lang.String attributeName, java.lang.Class requiredType)
          Does the attribute with the provided name exist in this map and is its value of the specified required type?
protected  java.util.Map createTargetMap()
          Factory method that returns the target map storing the data in this attribute map.
protected  java.util.Map createTargetMap(int size, int loadFactor)
          Factory method that returns the target map storing the data in this attribute map.
 boolean equals(java.lang.Object o)
           
 java.lang.Object get(java.lang.String attributeName)
          Get an attribute value out of this map, returning null if not found.
 java.lang.Object get(java.lang.String attributeName, java.lang.Class requiredType)
          Get an attribute value, asserting the value is of the required type.
 java.lang.Object get(java.lang.String attributeName, java.lang.Class requiredType, java.lang.Object defaultValue)
          Get an attribute value, asserting the value is of the required type and returning the default value if not found.
 java.lang.Object get(java.lang.String attributeName, java.lang.Object defaultValue)
          Get an attribute value, returning the default value if no value is found.
 java.lang.Object[] getArray(java.lang.String attributeName, java.lang.Class requiredType)
          Returns an array attribute value in the map and makes sure it is of the required type.
 java.lang.Boolean getBoolean(java.lang.String attributeName)
          Returns a boolean attribute value in the map, returning null if no value was found.
 java.lang.Boolean getBoolean(java.lang.String attributeName, java.lang.Boolean defaultValue)
          Returns a boolean attribute value in the map, returning the default value if no value was found.
 java.util.Collection getCollection(java.lang.String attributeName)
          Returns a collection attribute value in the map.
 java.util.Collection getCollection(java.lang.String attributeName, java.lang.Class requiredType)
          Returns a collection attribute value in the map and make sure it is of the required type.
 java.lang.Integer getInteger(java.lang.String attributeName)
          Returns an integer attribute value in the map, returning null if no value was found.
 java.lang.Integer getInteger(java.lang.String attributeName, java.lang.Integer defaultValue)
          Returns an integer attribute value in the map, returning the default value if no value was found.
 java.lang.Long getLong(java.lang.String attributeName)
          Returns a long attribute value in the map, returning null if no value was found.
 java.lang.Long getLong(java.lang.String attributeName, java.lang.Long defaultValue)
          Returns a long attribute value in the map, returning the default value if no value was found.
protected  java.util.Map getMapInternal()
          Returns the wrapped, modifiable map implementation.
 java.lang.Number getNumber(java.lang.String attributeName, java.lang.Class requiredType)
          Returns a number attribute value in the map that is of the specified type, returning null if no value was found.
 java.lang.Number getNumber(java.lang.String attributeName, java.lang.Class requiredType, java.lang.Number defaultValue)
          Returns a number attribute value in the map of the specified type, returning the default value if no value was found.
 java.lang.Object getRequired(java.lang.String attributeName)
          Get the value of a required attribute, throwing an exception of no attribute is found.
 java.lang.Object getRequired(java.lang.String attributeName, java.lang.Class requiredType)
          Get the value of a required attribute and make sure it is of the required type.
 java.lang.Object[] getRequiredArray(java.lang.String attributeName, java.lang.Class requiredType)
          Returns an array attribute value in the map, throwing an exception if the attribute is not present or not an array of the required type.
 java.lang.Boolean getRequiredBoolean(java.lang.String attributeName)
          Returns a boolean attribute value in the map, throwing an exception if the attribute is not present and of the correct type.
 java.util.Collection getRequiredCollection(java.lang.String attributeName)
          Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a collection.
 java.util.Collection getRequiredCollection(java.lang.String attributeName, java.lang.Class requiredType)
          Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a collection of the required type.
 java.lang.Integer getRequiredInteger(java.lang.String attributeName)
          Returns an integer attribute value in the map, throwing an exception if the attribute is not present and of the correct type.
 java.lang.Long getRequiredLong(java.lang.String attributeName)
          Returns a long attribute value in the map, throwing an exception if the attribute is not present and of the correct type.
 java.lang.Number getRequiredNumber(java.lang.String attributeName, java.lang.Class requiredType)
          Returns a number attribute value in the map, throwing an exception if the attribute is not present and of the correct type.
 java.lang.String getRequiredString(java.lang.String attributeName)
          Returns a string attribute value in the map, throwing an exception if the attribute is not present and of the correct type.
 java.lang.String getString(java.lang.String attributeName)
          Returns a string attribute value in the map, returning null if no value was found.
 java.lang.String getString(java.lang.String attributeName, java.lang.String defaultValue)
          Returns a string attribute value in the map, returning the default value if no value was found.
 int hashCode()
           
protected  void initAttributes(java.util.Map attributes)
          Initializes this attribute map.
 boolean isEmpty()
          Is this attribute map empty with a size of 0?
 java.lang.Object put(java.lang.String attributeName, java.lang.Object attributeValue)
          Put the attribute into this map.
 MutableAttributeMap putAll(AttributeMap attributes)
          Put all the attributes into this map.
 java.lang.Object remove(java.lang.String attributeName)
          Remove an attribute from this map.
 MutableAttributeMap replaceWith(AttributeMap attributes)
          Replace the contents of this attribute map with the contents of the provided collection.
 int size()
          Returns the size of this map.
 java.lang.String toString()
           
 AttributeMap union(AttributeMap attributes)
          Returns a new attribute map containing the union of this map with the provided map.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalAttributeMap

public LocalAttributeMap()
Creates a new attribute map, initially empty.


LocalAttributeMap

public LocalAttributeMap(int size,
                         int loadFactor)
Creates a new attribute map, initially empty.

Parameters:
size - the initial size
loadFactor - the load factor

LocalAttributeMap

public LocalAttributeMap(java.lang.String attributeName,
                         java.lang.Object attributeValue)
Creates a new attribute map with a single entry.


LocalAttributeMap

public LocalAttributeMap(java.util.Map map)
Creates a new attribute map wrapping the specified map.

Method Detail

asMap

public java.util.Map asMap()
Specified by:
asMap in interface org.springframework.binding.collection.MapAdaptable

size

public int size()
Description copied from interface: AttributeMap
Returns the size of this map.

Specified by:
size in interface AttributeMap
Returns:
the nubmer of entries in the map

get

public java.lang.Object get(java.lang.String attributeName)
Description copied from interface: AttributeMap
Get an attribute value out of this map, returning null if not found.

Specified by:
get in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the attribute value

isEmpty

public boolean isEmpty()
Description copied from interface: AttributeMap
Is this attribute map empty with a size of 0?

Specified by:
isEmpty in interface AttributeMap
Returns:
true if empty, false if not

contains

public boolean contains(java.lang.String attributeName)
Description copied from interface: AttributeMap
Does the attribute with the provided name exist in this map?

Specified by:
contains in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
true if so, false otherwise

contains

public boolean contains(java.lang.String attributeName,
                        java.lang.Class requiredType)
                 throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Does the attribute with the provided name exist in this map and is its value of the specified required type?

Specified by:
contains in interface AttributeMap
Parameters:
attributeName - the attribute name
requiredType - the required class of the attribute value
Returns:
true if so, false otherwise
Throws:
java.lang.IllegalArgumentException - when the value is not of the required type

get

public java.lang.Object get(java.lang.String attributeName,
                            java.lang.Object defaultValue)
Description copied from interface: AttributeMap
Get an attribute value, returning the default value if no value is found.

Specified by:
get in interface AttributeMap
Parameters:
attributeName - the name of the attribute
defaultValue - the default value
Returns:
the attribute value, falling back to the default if no such attribute exists

get

public java.lang.Object get(java.lang.String attributeName,
                            java.lang.Class requiredType)
                     throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Get an attribute value, asserting the value is of the required type.

Specified by:
get in interface AttributeMap
Parameters:
attributeName - the name of the attribute
requiredType - the required type of the attribute value
Returns:
the attribute value, or null if not found
Throws:
java.lang.IllegalArgumentException - when the value is not of the required type

get

public java.lang.Object get(java.lang.String attributeName,
                            java.lang.Class requiredType,
                            java.lang.Object defaultValue)
                     throws java.lang.IllegalStateException
Description copied from interface: AttributeMap
Get an attribute value, asserting the value is of the required type and returning the default value if not found.

Specified by:
get in interface AttributeMap
Parameters:
attributeName - the name of the attribute
requiredType - the value required type
defaultValue - the default value
Returns:
the attribute value, or the default if not found
Throws:
java.lang.IllegalStateException

getRequired

public java.lang.Object getRequired(java.lang.String attributeName)
                             throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Get the value of a required attribute, throwing an exception of no attribute is found.

Specified by:
getRequired in interface AttributeMap
Parameters:
attributeName - the name of the attribute
Returns:
the attribute value
Throws:
java.lang.IllegalArgumentException - when the attribute is not found

getRequired

public java.lang.Object getRequired(java.lang.String attributeName,
                                    java.lang.Class requiredType)
                             throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Get the value of a required attribute and make sure it is of the required type.

Specified by:
getRequired in interface AttributeMap
Parameters:
attributeName - name of the attribute to get
requiredType - the required type of the attribute value
Returns:
the attribute value
Throws:
java.lang.IllegalArgumentException - when the attribute is not found or not of the required type

getString

public java.lang.String getString(java.lang.String attributeName)
                           throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a string attribute value in the map, returning null if no value was found.

Specified by:
getString in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the string attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not a string

getString

public java.lang.String getString(java.lang.String attributeName,
                                  java.lang.String defaultValue)
                           throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a string attribute value in the map, returning the default value if no value was found.

Specified by:
getString in interface AttributeMap
Parameters:
attributeName - the attribute name
defaultValue - the default
Returns:
the string attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not a string

getRequiredString

public java.lang.String getRequiredString(java.lang.String attributeName)
                                   throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a string attribute value in the map, throwing an exception if the attribute is not present and of the correct type.

Specified by:
getRequiredString in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the string attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is not present or present but not a string

getCollection

public java.util.Collection getCollection(java.lang.String attributeName)
                                   throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a collection attribute value in the map.

Specified by:
getCollection in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the collection attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not a collection

getCollection

public java.util.Collection getCollection(java.lang.String attributeName,
                                          java.lang.Class requiredType)
                                   throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a collection attribute value in the map and make sure it is of the required type.

Specified by:
getCollection in interface AttributeMap
Parameters:
attributeName - the attribute name
requiredType - the required type of the attribute value
Returns:
the collection attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not a collection of the required type

getRequiredCollection

public java.util.Collection getRequiredCollection(java.lang.String attributeName)
                                           throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a collection.

Specified by:
getRequiredCollection in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the collection attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is not present or is present but not a collection

getRequiredCollection

public java.util.Collection getRequiredCollection(java.lang.String attributeName,
                                                  java.lang.Class requiredType)
                                           throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a collection of the required type.

Specified by:
getRequiredCollection in interface AttributeMap
Parameters:
attributeName - the attribute name
requiredType - the required collection type
Returns:
the collection attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is not present or is present but not a collection of the required type

getArray

public java.lang.Object[] getArray(java.lang.String attributeName,
                                   java.lang.Class requiredType)
                            throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns an array attribute value in the map and makes sure it is of the required type.

Specified by:
getArray in interface AttributeMap
Parameters:
attributeName - the attribute name
requiredType - the required type of the attribute value
Returns:
the array attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not an array of the required type

getRequiredArray

public java.lang.Object[] getRequiredArray(java.lang.String attributeName,
                                           java.lang.Class requiredType)
                                    throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns an array attribute value in the map, throwing an exception if the attribute is not present or not an array of the required type.

Specified by:
getRequiredArray in interface AttributeMap
Parameters:
attributeName - the attribute name
requiredType - the required array type
Returns:
the collection attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is not present or is present but not a array of the required type

getNumber

public java.lang.Number getNumber(java.lang.String attributeName,
                                  java.lang.Class requiredType)
                           throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a number attribute value in the map that is of the specified type, returning null if no value was found.

Specified by:
getNumber in interface AttributeMap
Parameters:
attributeName - the attribute name
requiredType - the required number type
Returns:
the number attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not a number of the required type

getNumber

public java.lang.Number getNumber(java.lang.String attributeName,
                                  java.lang.Class requiredType,
                                  java.lang.Number defaultValue)
                           throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a number attribute value in the map of the specified type, returning the default value if no value was found.

Specified by:
getNumber in interface AttributeMap
Parameters:
attributeName - the attribute name
defaultValue - the default
Returns:
the number attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not a number of the required type

getRequiredNumber

public java.lang.Number getRequiredNumber(java.lang.String attributeName,
                                          java.lang.Class requiredType)
                                   throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a number attribute value in the map, throwing an exception if the attribute is not present and of the correct type.

Specified by:
getRequiredNumber in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the number attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is not present or present but not a number of the required type

getInteger

public java.lang.Integer getInteger(java.lang.String attributeName)
                             throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns an integer attribute value in the map, returning null if no value was found.

Specified by:
getInteger in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the integer attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not an integer

getInteger

public java.lang.Integer getInteger(java.lang.String attributeName,
                                    java.lang.Integer defaultValue)
                             throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns an integer attribute value in the map, returning the default value if no value was found.

Specified by:
getInteger in interface AttributeMap
Parameters:
attributeName - the attribute name
defaultValue - the default
Returns:
the integer attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not an integer

getRequiredInteger

public java.lang.Integer getRequiredInteger(java.lang.String attributeName)
                                     throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns an integer attribute value in the map, throwing an exception if the attribute is not present and of the correct type.

Specified by:
getRequiredInteger in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the integer attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is not present or present but not an integer

getLong

public java.lang.Long getLong(java.lang.String attributeName)
                       throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a long attribute value in the map, returning null if no value was found.

Specified by:
getLong in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the long attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not a long

getLong

public java.lang.Long getLong(java.lang.String attributeName,
                              java.lang.Long defaultValue)
                       throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a long attribute value in the map, returning the default value if no value was found.

Specified by:
getLong in interface AttributeMap
Parameters:
attributeName - the attribute name
defaultValue - the default
Returns:
the long attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not a long

getRequiredLong

public java.lang.Long getRequiredLong(java.lang.String attributeName)
                               throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a long attribute value in the map, throwing an exception if the attribute is not present and of the correct type.

Specified by:
getRequiredLong in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the long attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is not present or present but not a long

getBoolean

public java.lang.Boolean getBoolean(java.lang.String attributeName)
                             throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a boolean attribute value in the map, returning null if no value was found.

Specified by:
getBoolean in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the long attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not a boolean

getBoolean

public java.lang.Boolean getBoolean(java.lang.String attributeName,
                                    java.lang.Boolean defaultValue)
                             throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a boolean attribute value in the map, returning the default value if no value was found.

Specified by:
getBoolean in interface AttributeMap
Parameters:
attributeName - the attribute name
defaultValue - the default
Returns:
the boolean attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is present but not a boolean

getRequiredBoolean

public java.lang.Boolean getRequiredBoolean(java.lang.String attributeName)
                                     throws java.lang.IllegalArgumentException
Description copied from interface: AttributeMap
Returns a boolean attribute value in the map, throwing an exception if the attribute is not present and of the correct type.

Specified by:
getRequiredBoolean in interface AttributeMap
Parameters:
attributeName - the attribute name
Returns:
the boolean attribute value
Throws:
java.lang.IllegalArgumentException - if the attribute is not present or present but is not a boolean

union

public AttributeMap union(AttributeMap attributes)
Description copied from interface: AttributeMap
Returns a new attribute map containing the union of this map with the provided map.

Specified by:
union in interface AttributeMap
Parameters:
attributes - the map to combine with this map
Returns:
a new, combined map

put

public java.lang.Object put(java.lang.String attributeName,
                            java.lang.Object attributeValue)
Description copied from interface: MutableAttributeMap
Put the attribute into this map.

If the attribute value is an AttributeMapBindingListener this map will publish binding events such as on "bind" and "unbind" if supported.

Note: not all MutableAttributeMap implementations support this.

Specified by:
put in interface MutableAttributeMap
Parameters:
attributeName - the attribute name
attributeValue - the attribute value
Returns:
the previous value of the attribute, or null of there was no previous value

putAll

public MutableAttributeMap putAll(AttributeMap attributes)
Description copied from interface: MutableAttributeMap
Put all the attributes into this map.

Specified by:
putAll in interface MutableAttributeMap
Parameters:
attributes - the attributes to put into this map
Returns:
this, to support call chaining

remove

public java.lang.Object remove(java.lang.String attributeName)
Description copied from interface: MutableAttributeMap
Remove an attribute from this map.

Specified by:
remove in interface MutableAttributeMap
Parameters:
attributeName - the name of the attribute to remove
Returns:
previous value associated with specified attribute name, or null if there was no mapping for the name

clear

public MutableAttributeMap clear()
                          throws java.lang.UnsupportedOperationException
Description copied from interface: MutableAttributeMap
Remove all attributes in this map.

Specified by:
clear in interface MutableAttributeMap
Returns:
this, to support call chaining
Throws:
java.lang.UnsupportedOperationException

replaceWith

public MutableAttributeMap replaceWith(AttributeMap attributes)
                                throws java.lang.UnsupportedOperationException
Description copied from interface: MutableAttributeMap
Replace the contents of this attribute map with the contents of the provided collection.

Specified by:
replaceWith in interface MutableAttributeMap
Parameters:
attributes - the attribute collection
Returns:
this, to support call chaining
Throws:
java.lang.UnsupportedOperationException

initAttributes

protected void initAttributes(java.util.Map attributes)
Initializes this attribute map.

Parameters:
attributes - the attributes

getMapInternal

protected java.util.Map getMapInternal()
Returns the wrapped, modifiable map implementation.


createTargetMap

protected java.util.Map createTargetMap()
Factory method that returns the target map storing the data in this attribute map.

Returns:
the target map

createTargetMap

protected java.util.Map createTargetMap(int size,
                                        int loadFactor)
Factory method that returns the target map storing the data in this attribute map.

Parameters:
size - the initial size of the map
loadFactor - the load factor
Returns:
the target map

equals

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

hashCode

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

toString

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


Copyright © 2009 Spring Framework. All Rights Reserved.