| java.lang.Object org.springframework.binding.collection.MapAccessor
MapAccessor | public class MapAccessor implements MapAdaptable(Code) | | A simple, generic decorator for getting attributes out of a map. May be
instantiated directly or used as a base class as a convenience.
author: Keith Donald |
Constructor Summary | |
public | MapAccessor(Map map) Creates a new attribute map accessor. |
Method Summary | |
public Map | asMap() | public void | assertContainsKey(Object key) Asserts that the attribute is present in the attribute map. | public Object | assertKeyValueInstanceOf(Object key, Object value, Class requiredType) Assert that the key value is an instance of the required type. | public Object | assertKeyValueOfType(Object key, Class requiredType) Assert that value of the mak key is of the required type. | public boolean | containsKey(Object key, Class requiredType) Indicates if the attribute is present in the attribute map and of the
required type. | public Object | get(Object key, Object defaultValue) Returns a value in the map, returning the defaultValue if no value was
found. | public Object | get(Object key, Class requiredType) Returns a value in the map, asserting it is of the required type if
present and returning null if not found. | public Object | get(Object key, Class requiredType, Object defaultValue) Returns a value in the map of the specified type, returning the
defaultValue if no value is found. | public Object[] | getArray(Object key, Class requiredType) Returns a array value in the map, asserting it is of the required type if
present and returning null if not found. | public Boolean | getBoolean(Object key) Returns a boolean value in the map, returning null if no
value was found. | public Boolean | getBoolean(Object key, Boolean defaultValue) Returns a boolean value in the map, returning the defaultValue if no
value was found. | public Collection | getCollection(Object key) Returns a collection value in the map, returning null if
no value was found. | public Collection | getCollection(Object key, Class requiredType) Returns a collection value in the map, asserting it is of the required
type if present and returning null if not found. | public Integer | getInteger(Object key) Returns an integer value in the map, returning null if no
value was found. | public Integer | getInteger(Object key, Integer defaultValue) Returns an integer value in the map, returning the defaultValue if no
value was found. | public Long | getLong(Object key) Returns a long value in the map, returning null if no
value was found. | public Long | getLong(Object key, Long defaultValue) Returns a long value in the map, returning the defaultValue if no value
was found. | public Number | getNumber(Object key, Class requiredType) Returns a number value in the map that is of the specified type,
returning null if no value was found. | public Number | getNumber(Object key, Class requiredType, Number defaultValue) Returns a number attribute value in the map of the specified type,
returning the defaultValue if no value was found. | public Object | getRequired(Object key) Returns a value in the map, throwing an exception if the attribute is not
present and of the correct type. | public Object | getRequired(Object key, Class requiredType) Returns an value in the map, asserting it is present and of the required
type. | public Object[] | getRequiredArray(Object key, Class requiredType) Returns an array value in the map, asserting it is of the required type
if present and throwing an exception if not found. | public Boolean | getRequiredBoolean(Object key) Returns a boolean value in the map, throwing an exception if the value is
not present and of the correct type. | public Collection | getRequiredCollection(Object key) Returns a collection value in the map, throwing an exception if not
found. | public Collection | getRequiredCollection(Object key, Class requiredType) Returns a collection value in the map, asserting it is of the required
type if present and throwing an exception if not found. | public Integer | getRequiredInteger(Object key) Returns an integer value in the map, throwing an exception if the value
is not present and of the correct type. | public Long | getRequiredLong(Object key) Returns a long value in the map, throwing an exception if the value is
not present and of the correct type. | public Number | getRequiredNumber(Object key, Class requiredType) Returns a number value in the map, throwing an exception if the attribute
is not present and of the correct type. | public String | getRequiredString(Object key) Returns a string value in the map, throwing an exception if the attribute
is not present and of the correct type. | public String | getString(Object key) Returns a string value in the map, returning null if no
value was found. | public String | getString(Object key, String defaultValue) Returns a string value in the map, returning the defaultValue if no value
was found. |
MapAccessor | public MapAccessor(Map map)(Code) | | Creates a new attribute map accessor.
Parameters: map - the map |
assertKeyValueInstanceOf | public Object assertKeyValueInstanceOf(Object key, Object value, Class requiredType)(Code) | | Assert that the key value is an instance of the required type.
Parameters: key - the key Parameters: value - the value Parameters: requiredType - the required type the value |
assertKeyValueOfType | public Object assertKeyValueOfType(Object key, Class requiredType)(Code) | | Assert that value of the mak key is of the required type.
Parameters: key - the attribute name Parameters: requiredType - the required attribute value type the attribute value |
containsKey | public boolean containsKey(Object key, Class requiredType) throws IllegalArgumentException(Code) | | Indicates if the attribute is present in the attribute map and of the
required type.
Parameters: key - the attribute name true if present and of the required type, false if not present. |
get | public Object get(Object key, Object defaultValue)(Code) | | Returns a value in the map, returning the defaultValue if no value was
found.
Parameters: key - the key Parameters: defaultValue - the default the attribute value |
get | public Object get(Object key, Class requiredType) throws IllegalArgumentException(Code) | | Returns a value in the map, asserting it is of the required type if
present and returning null if not found.
Parameters: key - the key Parameters: requiredType - the required type the value throws: IllegalArgumentException - if the key is present but the value isnot of the required type |
get | public Object get(Object key, Class requiredType, Object defaultValue)(Code) | | Returns a value in the map of the specified type, returning the
defaultValue if no value is found.
Parameters: key - the key Parameters: requiredType - the required type Parameters: defaultValue - the default the attribute value throws: IllegalArgumentException - if the key is present but the value isnot of the required type |
getArray | public Object[] getArray(Object key, Class requiredType) throws IllegalArgumentException(Code) | | Returns a array value in the map, asserting it is of the required type if
present and returning null if not found.
Parameters: key - the key the array value throws: IllegalArgumentException - if the key is present but the value isnot an array of the required type |
getLong | public Long getLong(Object key, Long defaultValue) throws IllegalArgumentException(Code) | | Returns a long value in the map, returning the defaultValue if no value
was found.
Parameters: key - the key Parameters: defaultValue - the default the long attribute value throws: IllegalArgumentException - if the key is present but the value isnot a long |
getNumber | public Number getNumber(Object key, Class requiredType) throws IllegalArgumentException(Code) | | Returns a number value in the map that is of the specified type,
returning null if no value was found.
Parameters: key - the key Parameters: requiredType - the required number type the numbervalue throws: IllegalArgumentException - if the key is present but the value isnot a number of the required type |
getNumber | public Number getNumber(Object key, Class requiredType, Number defaultValue) throws IllegalArgumentException(Code) | | Returns a number attribute value in the map of the specified type,
returning the defaultValue if no value was found.
Parameters: key - the attribute name the number value Parameters: defaultValue - the default throws: IllegalArgumentException - if the key is present but the value isnot a number of the required type |
getRequired | public Object getRequired(Object key) throws IllegalArgumentException(Code) | | Returns a value in the map, throwing an exception if the attribute is not
present and of the correct type.
Parameters: key - the key the value |
getRequired | public Object getRequired(Object key, Class requiredType) throws IllegalArgumentException(Code) | | Returns an value in the map, asserting it is present and of the required
type.
Parameters: key - the key Parameters: requiredType - the required type the value |
getRequiredArray | public Object[] getRequiredArray(Object key, Class requiredType) throws IllegalArgumentException(Code) | | Returns an array value in the map, asserting it is of the required type
if present and throwing an exception if not found.
Parameters: key - the key the array value throws: IllegalArgumentException - if the key is not present or present butthe value is not a array of the required type |
getRequiredBoolean | public Boolean getRequiredBoolean(Object key) throws IllegalArgumentException(Code) | | Returns a boolean value in the map, throwing an exception if the value is
not present and of the correct type.
Parameters: key - the attribute the boolean value throws: IllegalArgumentException - if the key is not present or present butthe value is not a boolean |
getRequiredCollection | public Collection getRequiredCollection(Object key, Class requiredType) throws IllegalArgumentException(Code) | | Returns a collection value in the map, asserting it is of the required
type if present and throwing an exception if not found.
Parameters: key - the key the collection value throws: IllegalArgumentException - if the key is not present or present butthe value is not a collection of the required type |
getRequiredInteger | public Integer getRequiredInteger(Object key) throws IllegalArgumentException(Code) | | Returns an integer value in the map, throwing an exception if the value
is not present and of the correct type.
Parameters: key - the attribute name the integer attribute value throws: IllegalArgumentException - if the key is not present or present butthe value is not an integer |
getRequiredLong | public Long getRequiredLong(Object key) throws IllegalArgumentException(Code) | | Returns a long value in the map, throwing an exception if the value is
not present and of the correct type.
Parameters: key - the key the long attribute value throws: IllegalArgumentException - if the key is not present or present butthe value is not a long |
getRequiredNumber | public Number getRequiredNumber(Object key, Class requiredType) throws IllegalArgumentException(Code) | | Returns a number value in the map, throwing an exception if the attribute
is not present and of the correct type.
Parameters: key - the key the number value throws: IllegalArgumentException - if the key is not present or present butthe value is not a number of the required type |
getRequiredString | public String getRequiredString(Object key) throws IllegalArgumentException(Code) | | Returns a string value in the map, throwing an exception if the attribute
is not present and of the correct type.
Parameters: key - the key the string value throws: IllegalArgumentException - if the key is not present or present butthe value is not a string |
|
|