Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Web Flow
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.binding.collection
Class MapAccessor

    java.lang.Object
      org.springframework.binding.collection.MapAccessor

All Implemented Interfaces:
  MapAdaptable

    public class MapAccessor

extends java.lang.Object
implements MapAdaptable

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
`MapAccessor(java.util.Map map)` Creates a new attribute map accessor.

Method Summary
`java.util.Map` | `asMap()` Returns this object's contents as a `Map`.
`void` | `assertContainsKey(java.lang.Object key)` Asserts that the attribute is present in the attribute map.
`java.lang.Object` | `assertKeyValueInstanceOf(java.lang.Object key, java.lang.Object value, java.lang.Class requiredType)` Assert that the key value, if non null, is an instance of the required type.
`java.lang.Object` | `assertKeyValueOfType(java.lang.Object key, java.lang.Class requiredType)` Assert that value of the map key, if non-null, is of the required type.
`boolean` | `containsKey(java.lang.Object key, java.lang.Class requiredType)` Indicates if the attribute is present in the attribute map and of the required type.
`java.lang.Object` | `get(java.lang.Object key)` Returns a value in the map, returning null if the attribute is not present.
`java.lang.Object` | `get(java.lang.Object key, java.lang.Class requiredType)` Returns a value in the map, asserting it is of the required type if present and returning `null` if not found.
`java.lang.Object` | `get(java.lang.Object key, java.lang.Class requiredType, java.lang.Object defaultValue)` Returns a value in the map of the specified type, returning the defaultValue if no value is found.
`java.lang.Object` | `get(java.lang.Object key, java.lang.Object defaultValue)` Returns a value in the map, returning the defaultValue if no value was found.
`java.lang.Object[]` | `getArray(java.lang.Object key, java.lang.Class requiredType)` Returns a array value in the map, asserting it is of the required type if present and returning `null` if not found.
`java.lang.Boolean` | `getBoolean(java.lang.Object key)` Returns a boolean value in the map, returning `null` if no value was found.
`java.lang.Boolean` | `getBoolean(java.lang.Object key, java.lang.Boolean defaultValue)` Returns a boolean value in the map, returning the defaultValue if no value was found.
`java.util.Collection` | `getCollection(java.lang.Object key)` Returns a collection value in the map, returning `null` if no value was found.
`java.util.Collection` | `getCollection(java.lang.Object key, java.lang.Class requiredType)` Returns a collection value in the map, asserting it is of the required type if present and returning `null` if not found.
`java.lang.Integer` | `getInteger(java.lang.Object key)` Returns an integer value in the map, returning `null` if no value was found.
`java.lang.Integer` | `getInteger(java.lang.Object key, java.lang.Integer defaultValue)` Returns an integer value in the map, returning the defaultValue if no value was found.
`java.lang.Long` | `getLong(java.lang.Object key)` Returns a long value in the map, returning `null` if no value was found.
`java.lang.Long` | `getLong(java.lang.Object key, java.lang.Long defaultValue)` Returns a long value in the map, returning the defaultValue if no value was found.
`java.lang.Number` | `getNumber(java.lang.Object key, java.lang.Class requiredType)` Returns a number value in the map that is of the specified type, returning `null` if no value was found.
`java.lang.Number` | `getNumber(java.lang.Object key, java.lang.Class requiredType, java.lang.Number defaultValue)` Returns a number attribute value in the map of the specified type, returning the defaultValue if no value was found.
`java.lang.Object` | `getRequired(java.lang.Object key)` Returns a value in the map, throwing an exception if the attribute is not present and of the correct type.
`java.lang.Object` | `getRequired(java.lang.Object key, java.lang.Class requiredType)` Returns an value in the map, asserting it is present and of the required type.
`java.lang.Object[]` | `getRequiredArray(java.lang.Object key, java.lang.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.
`java.lang.Boolean` | `getRequiredBoolean(java.lang.Object key)` Returns a boolean value in the map, throwing an exception if the value is not present and of the correct type.
`java.util.Collection` | `getRequiredCollection(java.lang.Object key)` Returns a collection value in the map, throwing an exception if not found.
`java.util.Collection` | `getRequiredCollection(java.lang.Object key, java.lang.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.
`java.lang.Integer` | `getRequiredInteger(java.lang.Object key)` Returns an integer value in the map, throwing an exception if the value is not present and of the correct type.
`java.lang.Long` | `getRequiredLong(java.lang.Object key)` Returns a long value in the map, throwing an exception if the value is not present and of the correct type.
`java.lang.Number` | `getRequiredNumber(java.lang.Object key, java.lang.Class requiredType)` Returns a number value in the map, throwing an exception if the attribute is not present and of the correct type.
`java.lang.String` | `getRequiredString(java.lang.Object key)` Returns a string value in the map, throwing an exception if the attribute is not present and of the correct type.
`java.lang.String` | `getString(java.lang.Object key)` Returns a string value in the map, returning `null` if no value was found.
`java.lang.String` | `getString(java.lang.Object key, java.lang.String defaultValue)` Returns a string value in the map, returning the defaultValue if no value was found.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MapAccessor

    public MapAccessor(java.util.Map map)

  Creates a new attribute map accessor.

  Parameters:
    `map` - the map

Method Detail

### asMap

    public java.util.Map asMap()

  Description copied from interface: `MapAdaptable`
  Returns this object's contents as a `Map`. The returned map may or may not be modifiable depending on this implementation.

  Warning: this operation may be called frequently; if so care should be taken so that the map contents (if calculated) be cached as appropriate.

  Specified by:
    `asMap` in interface `MapAdaptable`
  Returns:
    the object's contents as a map

### get

    public java.lang.Object get(java.lang.Object key)

  Returns a value in the map, returning null if the attribute is not present.

  Parameters:
    `key` - the key
  Returns:
    the value

### get

    public java.lang.Object get(java.lang.Object key,
                                java.lang.Object defaultValue)

  Returns a value in the map, returning the defaultValue if no value was found.

  Parameters:
    `key` - the key
    `defaultValue` - the default
  Returns:
    the attribute value

### get

    public java.lang.Object get(java.lang.Object key,
                                java.lang.Class requiredType)
                         throws java.lang.IllegalArgumentException

  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
    `requiredType` - the required type
  Returns:
    the value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not of the required type

### get

    public java.lang.Object get(java.lang.Object key,
                                java.lang.Class requiredType,
                                java.lang.Object defaultValue)

  Returns a value in the map of the specified type, returning the defaultValue if no value is found.

  Parameters:
    `key` - the key
    `requiredType` - the required type
    `defaultValue` - the default
  Returns:
    the attribute value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not of the required type

### getRequired

    public java.lang.Object getRequired(java.lang.Object key)
                                 throws java.lang.IllegalArgumentException

  Returns a value in the map, throwing an exception if the attribute is not present and of the correct type.

  Parameters:
    `key` - the key
  Returns:
    the value
  Throws:
    `java.lang.IllegalArgumentException`

### getRequired

    public java.lang.Object getRequired(java.lang.Object key,
                                        java.lang.Class requiredType)
                                 throws java.lang.IllegalArgumentException

  Returns an value in the map, asserting it is present and of the required type.

  Parameters:
    `key` - the key
    `requiredType` - the required type
  Returns:
    the value
  Throws:
    `java.lang.IllegalArgumentException`

### getString

    public java.lang.String getString(java.lang.Object key)
                               throws java.lang.IllegalArgumentException

  Returns a string value in the map, returning `null` if no value was found.

  Parameters:
    `key` - the key
  Returns:
    the string value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not a string

### getString

    public java.lang.String getString(java.lang.Object key,
                                      java.lang.String defaultValue)
                               throws java.lang.IllegalArgumentException

  Returns a string value in the map, returning the defaultValue if no value was found.

  Parameters:
    `key` - the key
    `defaultValue` - the default
  Returns:
    the string value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not a string

### getRequiredString

    public java.lang.String getRequiredString(java.lang.Object key)
                                       throws java.lang.IllegalArgumentException

  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
  Returns:
    the string value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is not present or present but the value is not a string

### getCollection

    public java.util.Collection getCollection(java.lang.Object key)
                                       throws java.lang.IllegalArgumentException

  Returns a collection value in the map, returning `null` if no value was found.

  Parameters:
    `key` - the key
  Returns:
    the collection value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not a collection

### getCollection

    public java.util.Collection getCollection(java.lang.Object key,
                                              java.lang.Class requiredType)
                                       throws java.lang.IllegalArgumentException

  Returns a collection value in the map, asserting it is of the required type if present and returning `null` if not found.

  Parameters:
    `key` - the key
  Returns:
    the collection value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not a collection

### getRequiredCollection

    public java.util.Collection getRequiredCollection(java.lang.Object key)
                                               throws java.lang.IllegalArgumentException

  Returns a collection value in the map, throwing an exception if not found.

  Parameters:
    `key` - the key
  Returns:
    the collection value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is not present or present but the value is not a collection

### getRequiredCollection

    public java.util.Collection getRequiredCollection(java.lang.Object key,
                                                      java.lang.Class requiredType)
                                               throws java.lang.IllegalArgumentException

  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
  Returns:
    the collection value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is not present or present but the value is not a collection of the required type

### getArray

    public java.lang.Object[] getArray(java.lang.Object key,
                                       java.lang.Class requiredType)
                                throws java.lang.IllegalArgumentException

  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
  Returns:
    the array value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not an array of the required type

### getRequiredArray

    public java.lang.Object[] getRequiredArray(java.lang.Object key,
                                               java.lang.Class requiredType)
                                        throws java.lang.IllegalArgumentException

  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
  Returns:
    the array value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is not present or present but the value is not a array of the required type

### getNumber

    public java.lang.Number getNumber(java.lang.Object key,
                                      java.lang.Class requiredType)
                               throws java.lang.IllegalArgumentException

  Returns a number value in the map that is of the specified type, returning `null` if no value was found.

  Parameters:
    `key` - the key
    `requiredType` - the required number type
  Returns:
    the numbervalue
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not a number of the required type

### getNumber

    public java.lang.Number getNumber(java.lang.Object key,
                                      java.lang.Class requiredType,
                                      java.lang.Number defaultValue)
                               throws java.lang.IllegalArgumentException

  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
    `defaultValue` - the default
  Returns:
    the number value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not a number of the required type

### getRequiredNumber

    public java.lang.Number getRequiredNumber(java.lang.Object key,
                                              java.lang.Class requiredType)
                                       throws java.lang.IllegalArgumentException

  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
  Returns:
    the number value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is not present or present but the value is not a number of the required type

### getInteger

    public java.lang.Integer getInteger(java.lang.Object key)
                                 throws java.lang.IllegalArgumentException

  Returns an integer value in the map, returning `null` if no value was found.

  Parameters:
    `key` - the key
  Returns:
    the integer value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not an integer

### getInteger

    public java.lang.Integer getInteger(java.lang.Object key,
                                        java.lang.Integer defaultValue)
                                 throws java.lang.IllegalArgumentException

  Returns an integer value in the map, returning the defaultValue if no value was found.

  Parameters:
    `key` - the key
    `defaultValue` - the default
  Returns:
    the integer value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not an integer

### getRequiredInteger

    public java.lang.Integer getRequiredInteger(java.lang.Object key)
                                         throws java.lang.IllegalArgumentException

  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
  Returns:
    the integer attribute value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is not present or present but the value is not an integer

### getLong

    public java.lang.Long getLong(java.lang.Object key)
                           throws java.lang.IllegalArgumentException

  Returns a long value in the map, returning `null` if no value was found.

  Parameters:
    `key` - the key
  Returns:
    the long value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but not a long

### getLong

    public java.lang.Long getLong(java.lang.Object key,
                                  java.lang.Long defaultValue)
                           throws java.lang.IllegalArgumentException

  Returns a long value in the map, returning the defaultValue if no value was found.

  Parameters:
    `key` - the key
    `defaultValue` - the default
  Returns:
    the long attribute value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not a long

### getRequiredLong

    public java.lang.Long getRequiredLong(java.lang.Object key)
                                   throws java.lang.IllegalArgumentException

  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
  Returns:
    the long attribute value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is not present or present but the value is not a long

### getBoolean

    public java.lang.Boolean getBoolean(java.lang.Object key)
                                 throws java.lang.IllegalArgumentException

  Returns a boolean value in the map, returning `null` if no value was found.

  Parameters:
    `key` - the key
  Returns:
    the boolean value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not a boolean

### getBoolean

    public java.lang.Boolean getBoolean(java.lang.Object key,
                                        java.lang.Boolean defaultValue)
                                 throws java.lang.IllegalArgumentException

  Returns a boolean value in the map, returning the defaultValue if no value was found.

  Parameters:
    `key` - the key
    `defaultValue` - the default
  Returns:
    the boolean value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is present but the value is not a boolean

### getRequiredBoolean

    public java.lang.Boolean getRequiredBoolean(java.lang.Object key)
                                         throws java.lang.IllegalArgumentException

  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
  Returns:
    the boolean value
  Throws:
    `java.lang.IllegalArgumentException` - if the key is not present or present but the value is not a boolean

### assertContainsKey

    public void assertContainsKey(java.lang.Object key)
                           throws java.lang.IllegalArgumentException

  Asserts that the attribute is present in the attribute map.

  Parameters:
    `key` - the key
  Throws:
    `java.lang.IllegalArgumentException` - if the key is not present

### containsKey

    public boolean containsKey(java.lang.Object key,
                               java.lang.Class requiredType)
                        throws java.lang.IllegalArgumentException

  Indicates if the attribute is present in the attribute map and of the required type.

  Parameters:
    `key` - the attribute name
  Returns:
    true if present and of the required type, false if not present.
  Throws:
    `java.lang.IllegalArgumentException`

### assertKeyValueOfType

    public java.lang.Object assertKeyValueOfType(java.lang.Object key,
                                                 java.lang.Class requiredType)

  Assert that value of the map key, if non-null, is of the required type.

  Parameters:
    `key` - the attribute name
    `requiredType` - the required attribute value type
  Returns:
    the attribute value

### assertKeyValueInstanceOf

    public java.lang.Object assertKeyValueInstanceOf(java.lang.Object key,
                                                     java.lang.Object value,
                                                     java.lang.Class requiredType)

  Assert that the key value, if non null, is an instance of the required type.

  Parameters:
    `key` - the key
    `value` - the value
    `requiredType` - the required type
  Returns:
    the value

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Web Flow
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD