public class LocalAttributeMap extends java.lang.Object implements MutableAttributeMap, java.io.Serializable
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
extract(java.lang.String attributeName)
Extract an attribute from this map, getting it and removing it in a single operation.
|
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 |
removeAll(MutableAttributeMap attributes)
Remove all attributes in the map provided 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.
|
public LocalAttributeMap()
public LocalAttributeMap(int size,
int loadFactor)
size - the initial sizeloadFactor - the load factorpublic LocalAttributeMap(java.lang.String attributeName,
java.lang.Object attributeValue)
public LocalAttributeMap(java.util.Map map)
public java.util.Map asMap()
asMap in interface org.springframework.binding.collection.MapAdaptablepublic int size()
AttributeMapsize in interface AttributeMappublic java.lang.Object get(java.lang.String attributeName)
AttributeMapnull if not found.get in interface AttributeMapattributeName - the attribute namepublic boolean isEmpty()
AttributeMapisEmpty in interface AttributeMappublic boolean contains(java.lang.String attributeName)
AttributeMapcontains in interface AttributeMapattributeName - the attribute namepublic boolean contains(java.lang.String attributeName,
java.lang.Class requiredType)
throws java.lang.IllegalArgumentException
AttributeMapcontains in interface AttributeMapattributeName - the attribute namerequiredType - the required class of the attribute valuejava.lang.IllegalArgumentException - when the value is not of the required typepublic java.lang.Object get(java.lang.String attributeName,
java.lang.Object defaultValue)
AttributeMapget in interface AttributeMapattributeName - the name of the attributedefaultValue - the default valuepublic java.lang.Object get(java.lang.String attributeName,
java.lang.Class requiredType)
throws java.lang.IllegalArgumentException
AttributeMapget in interface AttributeMapattributeName - the name of the attributerequiredType - the required type of the attribute valuejava.lang.IllegalArgumentException - when the value is not of the required typepublic java.lang.Object get(java.lang.String attributeName,
java.lang.Class requiredType,
java.lang.Object defaultValue)
throws java.lang.IllegalStateException
AttributeMapget in interface AttributeMapattributeName - the name of the attributerequiredType - the value required typedefaultValue - the default valuejava.lang.IllegalStateExceptionpublic java.lang.Object getRequired(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapgetRequired in interface AttributeMapattributeName - the name of the attributejava.lang.IllegalArgumentException - when the attribute is not foundpublic java.lang.Object getRequired(java.lang.String attributeName,
java.lang.Class requiredType)
throws java.lang.IllegalArgumentException
AttributeMapgetRequired in interface AttributeMapattributeName - name of the attribute to getrequiredType - the required type of the attribute valuejava.lang.IllegalArgumentException - when the attribute is not found or not of the required typepublic java.lang.String getString(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapnull if no value was found.getString in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is present but not a stringpublic java.lang.String getString(java.lang.String attributeName,
java.lang.String defaultValue)
throws java.lang.IllegalArgumentException
AttributeMapgetString in interface AttributeMapattributeName - the attribute namedefaultValue - the defaultjava.lang.IllegalArgumentException - if the attribute is present but not a stringpublic java.lang.String getRequiredString(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapgetRequiredString in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is not present or present but not a stringpublic java.util.Collection getCollection(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapgetCollection in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is present but not a collectionpublic java.util.Collection getCollection(java.lang.String attributeName,
java.lang.Class requiredType)
throws java.lang.IllegalArgumentException
AttributeMapgetCollection in interface AttributeMapattributeName - the attribute namerequiredType - the required type of the attribute valuejava.lang.IllegalArgumentException - if the attribute is present but not a collection of the required typepublic java.util.Collection getRequiredCollection(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapgetRequiredCollection in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is not present or is present but not a collectionpublic java.util.Collection getRequiredCollection(java.lang.String attributeName,
java.lang.Class requiredType)
throws java.lang.IllegalArgumentException
AttributeMapgetRequiredCollection in interface AttributeMapattributeName - the attribute namerequiredType - the required collection typejava.lang.IllegalArgumentException - if the attribute is not present or is present but not a collection of the
required typepublic java.lang.Object[] getArray(java.lang.String attributeName,
java.lang.Class requiredType)
throws java.lang.IllegalArgumentException
AttributeMapgetArray in interface AttributeMapattributeName - the attribute namerequiredType - the required type of the attribute valuejava.lang.IllegalArgumentException - if the attribute is present but not an array of the required typepublic java.lang.Object[] getRequiredArray(java.lang.String attributeName,
java.lang.Class requiredType)
throws java.lang.IllegalArgumentException
AttributeMapgetRequiredArray in interface AttributeMapattributeName - the attribute namerequiredType - the required array typejava.lang.IllegalArgumentException - if the attribute is not present or is present but not a array of the required
typepublic java.lang.Number getNumber(java.lang.String attributeName,
java.lang.Class requiredType)
throws java.lang.IllegalArgumentException
AttributeMapnull if no
value was found.getNumber in interface AttributeMapattributeName - the attribute namerequiredType - the required number typejava.lang.IllegalArgumentException - if the attribute is present but not a number of the required typepublic java.lang.Number getNumber(java.lang.String attributeName,
java.lang.Class requiredType,
java.lang.Number defaultValue)
throws java.lang.IllegalArgumentException
AttributeMapgetNumber in interface AttributeMapattributeName - the attribute namedefaultValue - the defaultjava.lang.IllegalArgumentException - if the attribute is present but not a number of the required typepublic java.lang.Number getRequiredNumber(java.lang.String attributeName,
java.lang.Class requiredType)
throws java.lang.IllegalArgumentException
AttributeMapgetRequiredNumber in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is not present or present but not a number of the required typepublic java.lang.Integer getInteger(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapnull if no value was found.getInteger in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is present but not an integerpublic java.lang.Integer getInteger(java.lang.String attributeName,
java.lang.Integer defaultValue)
throws java.lang.IllegalArgumentException
AttributeMapgetInteger in interface AttributeMapattributeName - the attribute namedefaultValue - the defaultjava.lang.IllegalArgumentException - if the attribute is present but not an integerpublic java.lang.Integer getRequiredInteger(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapgetRequiredInteger in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is not present or present but not an integerpublic java.lang.Long getLong(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapnull if no value was found.getLong in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is present but not a longpublic java.lang.Long getLong(java.lang.String attributeName,
java.lang.Long defaultValue)
throws java.lang.IllegalArgumentException
AttributeMapgetLong in interface AttributeMapattributeName - the attribute namedefaultValue - the defaultjava.lang.IllegalArgumentException - if the attribute is present but not a longpublic java.lang.Long getRequiredLong(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapgetRequiredLong in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is not present or present but not a longpublic java.lang.Boolean getBoolean(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapnull if no value was found.getBoolean in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is present but not a booleanpublic java.lang.Boolean getBoolean(java.lang.String attributeName,
java.lang.Boolean defaultValue)
throws java.lang.IllegalArgumentException
AttributeMapgetBoolean in interface AttributeMapattributeName - the attribute namedefaultValue - the defaultjava.lang.IllegalArgumentException - if the attribute is present but not a booleanpublic java.lang.Boolean getRequiredBoolean(java.lang.String attributeName)
throws java.lang.IllegalArgumentException
AttributeMapgetRequiredBoolean in interface AttributeMapattributeName - the attribute namejava.lang.IllegalArgumentException - if the attribute is not present or present but is not a booleanpublic AttributeMap union(AttributeMap attributes)
AttributeMapunion in interface AttributeMapattributes - the map to combine with this mappublic java.lang.Object put(java.lang.String attributeName,
java.lang.Object attributeValue)
MutableAttributeMap
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.
put in interface MutableAttributeMapattributeName - the attribute nameattributeValue - the attribute valuenull of there was no previous valuepublic MutableAttributeMap putAll(AttributeMap attributes)
MutableAttributeMapputAll in interface MutableAttributeMapattributes - the attributes to put into this mappublic MutableAttributeMap removeAll(MutableAttributeMap attributes)
MutableAttributeMapremoveAll in interface MutableAttributeMapattributes - the attributes to remove from this mappublic java.lang.Object remove(java.lang.String attributeName)
MutableAttributeMapremove in interface MutableAttributeMapattributeName - the name of the attribute to removepublic java.lang.Object extract(java.lang.String attributeName)
MutableAttributeMapextract in interface MutableAttributeMapattributeName - the attribute namenull of there was no valuepublic MutableAttributeMap clear() throws java.lang.UnsupportedOperationException
MutableAttributeMapclear in interface MutableAttributeMapjava.lang.UnsupportedOperationExceptionpublic MutableAttributeMap replaceWith(AttributeMap attributes) throws java.lang.UnsupportedOperationException
MutableAttributeMapreplaceWith in interface MutableAttributeMapattributes - the attribute collectionjava.lang.UnsupportedOperationExceptionprotected void initAttributes(java.util.Map attributes)
attributes - the attributesprotected java.util.Map getMapInternal()
protected java.util.Map createTargetMap()
protected java.util.Map createTargetMap(int size,
int loadFactor)
size - the initial size of the maploadFactor - the load factorpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object