Class LocalParameterMap

java.lang.Object
org.springframework.webflow.core.collection.LocalParameterMap
All Implemented Interfaces:
Serializable, org.springframework.binding.collection.MapAdaptable<String,Object>, ParameterMap
Direct Known Subclasses:
MockParameterMap

public class LocalParameterMap extends Object implements ParameterMap, Serializable
An immutable parameter map storing String-keyed, String-valued parameters in a backing Map implementation. This base provides convenient operations for accessing parameters in a typed-manner.
Author:
Keith Donald
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new parameter map from the provided map.
    LocalParameterMap(Map<String,Object> parameters, org.springframework.binding.convert.ConversionService conversionService)
    Creates a new parameter map from the provided map.
  • Method Summary

    Modifier and Type
    Method
    Description
    Adapts this parameter map to an AttributeMap.
     
    boolean
    contains(String parameterName)
    Does the parameter with the provided name exist in this map?
    boolean
     
    get(String parameterName)
    Get a parameter value, returning null if no value is found.
    <T> T
    get(String parameterName, Class<T> targetType)
    Get a parameter value, converting it from String to the target type.
    <T> T
    get(String parameterName, Class<T> targetType, T defaultValue)
    Get a parameter value, converting it from String to the target type or returning the defaultValue if not found.
    get(String parameterName, String defaultValue)
    Get a parameter value, returning the defaultValue if no value is found.
    getArray(String parameterName)
    Get a multi-valued parameter value, returning null if no value is found.
    <T> T[]
    getArray(String parameterName, Class<T> targetElementType)
    Get a multi-valued parameter value, converting each value to the target type or returning null if no value is found.
    getBoolean(String parameterName)
    Returns a boolean parameter value in the map, returning null if no value was found.
    getBoolean(String parameterName, Boolean defaultValue)
    Returns a boolean parameter value in the map, returning the defaultValue if no value was found.
    getInteger(String parameterName)
    Returns an integer parameter value in the map, returning null if no value was found.
    getInteger(String parameterName, Integer defaultValue)
    Returns an integer parameter value in the map, returning the defaultValue if no value was found.
    getLong(String parameterName)
    Returns a long parameter value in the map, returning null if no value was found.
    getLong(String parameterName, Long defaultValue)
    Returns a long parameter value in the map, returning the defaultValue if no value was found.
    protected Map<String,Object>
    Returns the wrapped, modifiable map implementation.
    org.springframework.web.multipart.MultipartFile
    getMultipartFile(String parameterName)
    Get a multi-part file parameter value, returning null if no value is found.
    <T extends Number>
    T
    getNumber(String parameterName, Class<T> targetType)
    Returns a number parameter value in the map that is of the specified type, returning null if no value was found.
    <T extends Number>
    T
    getNumber(String parameterName, Class<T> targetType, T defaultValue)
    Returns a number parameter value in the map of the specified type, returning the defaultValue if no value was found.
    getRequired(String parameterName)
    Get the value of a required parameter.
    <T> T
    getRequired(String parameterName, Class<T> targetType)
    Get the value of a required parameter and convert it to the target type.
    getRequiredArray(String parameterName)
    Get a required multi-valued parameter value.
    <T> T[]
    getRequiredArray(String parameterName, Class<T> targetElementType)
    Get a required multi-valued parameter value, converting each value to the target type.
    getRequiredBoolean(String parameterName)
    Returns a boolean parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
    getRequiredInteger(String parameterName)
    Returns an integer parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
    getRequiredLong(String parameterName)
    Returns a long parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
    org.springframework.web.multipart.MultipartFile
    Get the value of a required multipart file parameter.
    <T extends Number>
    T
    getRequiredNumber(String parameterName, Class<T> targetType)
    Returns a number parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
    int
     
    protected void
    Initializes this parameter map.
    boolean
    Is this parameter map empty, with a size of 0?
    int
    Returns the number of parameters in this map.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LocalParameterMap

      public LocalParameterMap(Map<String,Object> parameters)
      Creates a new parameter map from the provided map.

      It is expected that the contents of the backing map adhere to the parameter map contract; that is, map entries have string keys, string values, and remain unmodifiable.

      Parameters:
      parameters - the contents of this parameter map
    • LocalParameterMap

      public LocalParameterMap(Map<String,Object> parameters, org.springframework.binding.convert.ConversionService conversionService)
      Creates a new parameter map from the provided map.

      It is expected that the contents of the backing map adhere to the parameter map contract; that is, map entries have string keys, string values, and remain unmodifiable.

      Parameters:
      parameters - the contents of this parameter map
      conversionService - a helper for performing type conversion of map entry values
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • asMap

      public Map<String,Object> asMap()
      Specified by:
      asMap in interface org.springframework.binding.collection.MapAdaptable<String,Object>
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: ParameterMap
      Is this parameter map empty, with a size of 0?
      Specified by:
      isEmpty in interface ParameterMap
      Returns:
      true if empty, false if not
    • size

      public int size()
      Description copied from interface: ParameterMap
      Returns the number of parameters in this map.
      Specified by:
      size in interface ParameterMap
      Returns:
      the parameter count
    • contains

      public boolean contains(String parameterName)
      Description copied from interface: ParameterMap
      Does the parameter with the provided name exist in this map?
      Specified by:
      contains in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      true if so, false otherwise
    • get

      public String get(String parameterName)
      Description copied from interface: ParameterMap
      Get a parameter value, returning null if no value is found.
      Specified by:
      get in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      the parameter value
    • get

      public String get(String parameterName, String defaultValue)
      Description copied from interface: ParameterMap
      Get a parameter value, returning the defaultValue if no value is found.
      Specified by:
      get in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      defaultValue - the default
      Returns:
      the parameter value
    • getArray

      public String[] getArray(String parameterName)
      Description copied from interface: ParameterMap
      Get a multi-valued parameter value, returning null if no value is found. If the parameter is single valued an array with a single element is returned.
      Specified by:
      getArray in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      the parameter value array
    • getArray

      public <T> T[] getArray(String parameterName, Class<T> targetElementType) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Get a multi-valued parameter value, converting each value to the target type or returning null if no value is found.
      Specified by:
      getArray in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      targetElementType - the target type of the array's elements
      Returns:
      the converterd parameter value array
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • get

      public <T> T get(String parameterName, Class<T> targetType) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Get a parameter value, converting it from String to the target type.
      Specified by:
      get in interface ParameterMap
      Parameters:
      parameterName - the name of the parameter
      targetType - the target type of the parameter value
      Returns:
      the converted parameter value, or null if not found
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • get

      public <T> T get(String parameterName, Class<T> targetType, T defaultValue) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Get a parameter value, converting it from String to the target type or returning the defaultValue if not found.
      Specified by:
      get in interface ParameterMap
      Parameters:
      parameterName - name of the parameter to get
      targetType - the target type of the parameter value
      defaultValue - the default value
      Returns:
      the converted parameter value, or the default if not found
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when a value could not be converted
    • getRequired

      public String getRequired(String parameterName) throws IllegalArgumentException
      Description copied from interface: ParameterMap
      Get the value of a required parameter.
      Specified by:
      getRequired in interface ParameterMap
      Parameters:
      parameterName - the name of the parameter
      Returns:
      the parameter value
      Throws:
      IllegalArgumentException - when the parameter is not found
    • getRequiredArray

      public String[] getRequiredArray(String parameterName) throws IllegalArgumentException
      Description copied from interface: ParameterMap
      Get a required multi-valued parameter value.
      Specified by:
      getRequiredArray in interface ParameterMap
      Parameters:
      parameterName - the name of the parameter
      Returns:
      the parameter value
      Throws:
      IllegalArgumentException - when the parameter is not found
    • getRequiredArray

      public <T> T[] getRequiredArray(String parameterName, Class<T> targetElementType) throws IllegalArgumentException, org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Get a required multi-valued parameter value, converting each value to the target type.
      Specified by:
      getRequiredArray in interface ParameterMap
      Parameters:
      parameterName - the name of the parameter
      Returns:
      the parameter value
      Throws:
      IllegalArgumentException - when the parameter is not found
      org.springframework.binding.convert.ConversionExecutionException - when a value could not be converted
    • getRequired

      public <T> T getRequired(String parameterName, Class<T> targetType) throws IllegalArgumentException, org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Get the value of a required parameter and convert it to the target type.
      Specified by:
      getRequired in interface ParameterMap
      Parameters:
      parameterName - the name of the parameter
      targetType - the target type of the parameter value
      Returns:
      the converted parameter value
      Throws:
      IllegalArgumentException - when the parameter is not found
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getNumber

      public <T extends Number> T getNumber(String parameterName, Class<T> targetType) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns a number parameter value in the map that is of the specified type, returning null if no value was found.
      Specified by:
      getNumber in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      targetType - the target number type
      Returns:
      the number parameter value
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getNumber

      public <T extends Number> T getNumber(String parameterName, Class<T> targetType, T defaultValue) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns a number parameter value in the map of the specified type, returning the defaultValue if no value was found.
      Specified by:
      getNumber in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      defaultValue - the default
      Returns:
      the number parameter value
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getRequiredNumber

      public <T extends Number> T getRequiredNumber(String parameterName, Class<T> targetType) throws IllegalArgumentException, org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns a number parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
      Specified by:
      getRequiredNumber in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      the number parameter value
      Throws:
      IllegalArgumentException - if the parameter is not present
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getInteger

      public Integer getInteger(String parameterName) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns an integer parameter value in the map, returning null if no value was found.
      Specified by:
      getInteger in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      the integer parameter value
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getInteger

      public Integer getInteger(String parameterName, Integer defaultValue) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns an integer parameter value in the map, returning the defaultValue if no value was found.
      Specified by:
      getInteger in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      defaultValue - the default
      Returns:
      the integer parameter value
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getRequiredInteger

      public Integer getRequiredInteger(String parameterName) throws IllegalArgumentException, org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns an integer parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
      Specified by:
      getRequiredInteger in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      the integer parameter value
      Throws:
      IllegalArgumentException - if the parameter is not present
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getLong

      public Long getLong(String parameterName) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns a long parameter value in the map, returning null if no value was found.
      Specified by:
      getLong in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      the long parameter value
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getLong

      public Long getLong(String parameterName, Long defaultValue) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns a long parameter value in the map, returning the defaultValue if no value was found.
      Specified by:
      getLong in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      defaultValue - the default
      Returns:
      the long parameter value
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getRequiredLong

      public Long getRequiredLong(String parameterName) throws IllegalArgumentException, org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns a long parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
      Specified by:
      getRequiredLong in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      the long parameter value
      Throws:
      IllegalArgumentException - if the parameter is not present
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getBoolean

      public Boolean getBoolean(String parameterName) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns a boolean parameter value in the map, returning null if no value was found.
      Specified by:
      getBoolean in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      the long parameter value
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getBoolean

      public Boolean getBoolean(String parameterName, Boolean defaultValue) throws org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns a boolean parameter value in the map, returning the defaultValue if no value was found.
      Specified by:
      getBoolean in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      defaultValue - the default
      Returns:
      the boolean parameter value
      Throws:
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getRequiredBoolean

      public Boolean getRequiredBoolean(String parameterName) throws IllegalArgumentException, org.springframework.binding.convert.ConversionExecutionException
      Description copied from interface: ParameterMap
      Returns a boolean parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
      Specified by:
      getRequiredBoolean in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      the boolean parameter value
      Throws:
      IllegalArgumentException - if the parameter is not present
      org.springframework.binding.convert.ConversionExecutionException - when the value could not be converted
    • getMultipartFile

      public org.springframework.web.multipart.MultipartFile getMultipartFile(String parameterName)
      Description copied from interface: ParameterMap
      Get a multi-part file parameter value, returning null if no value is found.
      Specified by:
      getMultipartFile in interface ParameterMap
      Parameters:
      parameterName - the parameter name
      Returns:
      the multipart file
    • getRequiredMultipartFile

      public org.springframework.web.multipart.MultipartFile getRequiredMultipartFile(String parameterName) throws IllegalArgumentException
      Description copied from interface: ParameterMap
      Get the value of a required multipart file parameter.
      Specified by:
      getRequiredMultipartFile in interface ParameterMap
      Parameters:
      parameterName - the name of the parameter
      Returns:
      the parameter value
      Throws:
      IllegalArgumentException - when the parameter is not found
    • asAttributeMap

      public AttributeMap<Object> asAttributeMap()
      Description copied from interface: ParameterMap
      Adapts this parameter map to an AttributeMap.
      Specified by:
      asAttributeMap in interface ParameterMap
      Returns:
      the underlying map as a unmodifiable attribute map
    • initParameters

      protected void initParameters(Map<String,Object> parameters)
      Initializes this parameter map.
      Parameters:
      parameters - the parameters
    • getMapInternal

      protected Map<String,Object> getMapInternal()
      Returns the wrapped, modifiable map implementation.
    • toString

      public String toString()
      Overrides:
      toString in class Object