public class LocalParameterMap extends java.lang.Object implements ParameterMap, java.io.Serializable
Map implementation.
This base provides convenient operations for accessing parameters in a typed-manner.| Constructor and Description |
|---|
LocalParameterMap(java.util.Map parameters)
Creates a new parameter map from the provided map.
|
LocalParameterMap(java.util.Map parameters,
org.springframework.binding.convert.ConversionService conversionService)
Creates a new parameter map from the provided map.
|
| Modifier and Type | Method and Description |
|---|---|
AttributeMap |
asAttributeMap()
Adapts this parameter map to an
AttributeMap. |
java.util.Map |
asMap() |
boolean |
contains(java.lang.String parameterName)
Does the parameter with the provided name exist in this map?
|
boolean |
equals(java.lang.Object o) |
java.lang.String |
get(java.lang.String parameterName)
Get a parameter value, returning
null if no value is found. |
java.lang.Object |
get(java.lang.String parameterName,
java.lang.Class targetType)
Get a parameter value, converting it from
String to the target type. |
java.lang.Object |
get(java.lang.String parameterName,
java.lang.Class targetType,
java.lang.Object defaultValue)
Get a parameter value, converting it from
String to the target type or returning the defaultValue
if not found. |
java.lang.String |
get(java.lang.String parameterName,
java.lang.String defaultValue)
Get a parameter value, returning the defaultValue if no value is found.
|
java.lang.String[] |
getArray(java.lang.String parameterName)
Get a multi-valued parameter value, returning
null if no value is found. |
java.lang.Object[] |
getArray(java.lang.String parameterName,
java.lang.Class targetElementType)
Get a multi-valued parameter value, converting each value to the target type or returning
null if
no value is found. |
java.lang.Boolean |
getBoolean(java.lang.String parameterName)
Returns a boolean parameter value in the map, returning
null if no value was found. |
java.lang.Boolean |
getBoolean(java.lang.String parameterName,
java.lang.Boolean defaultValue)
Returns a boolean parameter value in the map, returning the defaultValue if no value was found.
|
java.lang.Integer |
getInteger(java.lang.String parameterName)
Returns an integer parameter value in the map, returning
null if no value was found. |
java.lang.Integer |
getInteger(java.lang.String parameterName,
java.lang.Integer defaultValue)
Returns an integer parameter value in the map, returning the defaultValue if no value was found.
|
java.lang.Long |
getLong(java.lang.String parameterName)
Returns a long parameter value in the map, returning
null if no value was found. |
java.lang.Long |
getLong(java.lang.String parameterName,
java.lang.Long defaultValue)
Returns a long parameter value in the map, returning the defaultValue if no value was found.
|
protected java.util.Map |
getMapInternal()
Returns the wrapped, modifiable map implementation.
|
org.springframework.web.multipart.MultipartFile |
getMultipartFile(java.lang.String parameterName)
Get a multi-part file parameter value, returning
null if no value is found. |
java.lang.Number |
getNumber(java.lang.String parameterName,
java.lang.Class targetType)
Returns a number parameter value in the map that is of the specified type, returning
null if no
value was found. |
java.lang.Number |
getNumber(java.lang.String parameterName,
java.lang.Class targetType,
java.lang.Number defaultValue)
Returns a number parameter value in the map of the specified type, returning the defaultValue if no value was
found.
|
java.lang.String |
getRequired(java.lang.String parameterName)
Get the value of a required parameter.
|
java.lang.Object |
getRequired(java.lang.String parameterName,
java.lang.Class targetType)
Get the value of a required parameter and convert it to the target type.
|
java.lang.String[] |
getRequiredArray(java.lang.String parameterName)
Get a required multi-valued parameter value.
|
java.lang.Object[] |
getRequiredArray(java.lang.String parameterName,
java.lang.Class targetElementType)
Get a required multi-valued parameter value, converting each value to the target type.
|
java.lang.Boolean |
getRequiredBoolean(java.lang.String parameterName)
Returns a boolean parameter value in the map, throwing an exception if the parameter is not present or could not
be converted.
|
java.lang.Integer |
getRequiredInteger(java.lang.String parameterName)
Returns an integer parameter value in the map, throwing an exception if the parameter is not present or could not
be converted.
|
java.lang.Long |
getRequiredLong(java.lang.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 |
getRequiredMultipartFile(java.lang.String parameterName)
Get the value of a required multipart file parameter.
|
java.lang.Number |
getRequiredNumber(java.lang.String parameterName,
java.lang.Class targetType)
Returns a number parameter value in the map, throwing an exception if the parameter is not present or could not
be converted.
|
int |
hashCode() |
protected void |
initParameters(java.util.Map parameters)
Initializes this parameter map.
|
boolean |
isEmpty()
Is this parameter map empty, with a size of 0?
|
int |
size()
Returns the number of parameters in this map.
|
java.lang.String |
toString() |
public LocalParameterMap(java.util.Map parameters)
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 - the contents of this parameter mappublic LocalParameterMap(java.util.Map parameters,
org.springframework.binding.convert.ConversionService conversionService)
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 - the contents of this parameter mapconversionService - a helper for performing type conversion of map entry valuespublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.util.Map asMap()
asMap in interface org.springframework.binding.collection.MapAdaptablepublic boolean isEmpty()
ParameterMapisEmpty in interface ParameterMappublic int size()
ParameterMapsize in interface ParameterMappublic boolean contains(java.lang.String parameterName)
ParameterMapcontains in interface ParameterMapparameterName - the parameter namepublic java.lang.String get(java.lang.String parameterName)
ParameterMapnull if no value is found.get in interface ParameterMapparameterName - the parameter namepublic java.lang.String get(java.lang.String parameterName,
java.lang.String defaultValue)
ParameterMapget in interface ParameterMapparameterName - the parameter namedefaultValue - the defaultpublic java.lang.String[] getArray(java.lang.String parameterName)
ParameterMapnull if no value is found. If the parameter is
single valued an array with a single element is returned.getArray in interface ParameterMapparameterName - the parameter namepublic java.lang.Object[] getArray(java.lang.String parameterName,
java.lang.Class targetElementType)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapnull if
no value is found.getArray in interface ParameterMapparameterName - the parameter nametargetElementType - the target type of the array's elementsorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Object get(java.lang.String parameterName,
java.lang.Class targetType)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapString to the target type.get in interface ParameterMapparameterName - the name of the parametertargetType - the target type of the parameter valueorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Object get(java.lang.String parameterName,
java.lang.Class targetType,
java.lang.Object defaultValue)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapString to the target type or returning the defaultValue
if not found.get in interface ParameterMapparameterName - name of the parameter to gettargetType - the target type of the parameter valuedefaultValue - the default valueorg.springframework.binding.convert.ConversionExecutionException - when a value could not be convertedpublic java.lang.String getRequired(java.lang.String parameterName)
throws java.lang.IllegalArgumentException
ParameterMapgetRequired in interface ParameterMapparameterName - the name of the parameterjava.lang.IllegalArgumentException - when the parameter is not foundpublic java.lang.String[] getRequiredArray(java.lang.String parameterName)
throws java.lang.IllegalArgumentException
ParameterMapgetRequiredArray in interface ParameterMapparameterName - the name of the parameterjava.lang.IllegalArgumentException - when the parameter is not foundpublic java.lang.Object[] getRequiredArray(java.lang.String parameterName,
java.lang.Class targetElementType)
throws java.lang.IllegalArgumentException,
org.springframework.binding.convert.ConversionExecutionException
ParameterMapgetRequiredArray in interface ParameterMapparameterName - the name of the parameterjava.lang.IllegalArgumentException - when the parameter is not foundorg.springframework.binding.convert.ConversionExecutionException - when a value could not be convertedpublic java.lang.Object getRequired(java.lang.String parameterName,
java.lang.Class targetType)
throws java.lang.IllegalArgumentException,
org.springframework.binding.convert.ConversionExecutionException
ParameterMapgetRequired in interface ParameterMapparameterName - the name of the parametertargetType - the target type of the parameter valuejava.lang.IllegalArgumentException - when the parameter is not foundorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Number getNumber(java.lang.String parameterName,
java.lang.Class targetType)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapnull if no
value was found.getNumber in interface ParameterMapparameterName - the parameter nametargetType - the target number typeorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Number getNumber(java.lang.String parameterName,
java.lang.Class targetType,
java.lang.Number defaultValue)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapgetNumber in interface ParameterMapparameterName - the parameter namedefaultValue - the defaultorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Number getRequiredNumber(java.lang.String parameterName,
java.lang.Class targetType)
throws java.lang.IllegalArgumentException,
org.springframework.binding.convert.ConversionExecutionException
ParameterMapgetRequiredNumber in interface ParameterMapparameterName - the parameter namejava.lang.IllegalArgumentException - if the parameter is not presentorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Integer getInteger(java.lang.String parameterName)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapnull if no value was found.getInteger in interface ParameterMapparameterName - the parameter nameorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Integer getInteger(java.lang.String parameterName,
java.lang.Integer defaultValue)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapgetInteger in interface ParameterMapparameterName - the parameter namedefaultValue - the defaultorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Integer getRequiredInteger(java.lang.String parameterName)
throws java.lang.IllegalArgumentException,
org.springframework.binding.convert.ConversionExecutionException
ParameterMapgetRequiredInteger in interface ParameterMapparameterName - the parameter namejava.lang.IllegalArgumentException - if the parameter is not presentorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Long getLong(java.lang.String parameterName)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapnull if no value was found.getLong in interface ParameterMapparameterName - the parameter nameorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Long getLong(java.lang.String parameterName,
java.lang.Long defaultValue)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapgetLong in interface ParameterMapparameterName - the parameter namedefaultValue - the defaultorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Long getRequiredLong(java.lang.String parameterName)
throws java.lang.IllegalArgumentException,
org.springframework.binding.convert.ConversionExecutionException
ParameterMapgetRequiredLong in interface ParameterMapparameterName - the parameter namejava.lang.IllegalArgumentException - if the parameter is not presentorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Boolean getBoolean(java.lang.String parameterName)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapnull if no value was found.getBoolean in interface ParameterMapparameterName - the parameter nameorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Boolean getBoolean(java.lang.String parameterName,
java.lang.Boolean defaultValue)
throws org.springframework.binding.convert.ConversionExecutionException
ParameterMapgetBoolean in interface ParameterMapparameterName - the parameter namedefaultValue - the defaultorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic java.lang.Boolean getRequiredBoolean(java.lang.String parameterName)
throws java.lang.IllegalArgumentException,
org.springframework.binding.convert.ConversionExecutionException
ParameterMapgetRequiredBoolean in interface ParameterMapparameterName - the parameter namejava.lang.IllegalArgumentException - if the parameter is not presentorg.springframework.binding.convert.ConversionExecutionException - when the value could not be convertedpublic org.springframework.web.multipart.MultipartFile getMultipartFile(java.lang.String parameterName)
ParameterMapnull if no value is found.getMultipartFile in interface ParameterMapparameterName - the parameter namepublic org.springframework.web.multipart.MultipartFile getRequiredMultipartFile(java.lang.String parameterName)
throws java.lang.IllegalArgumentException
ParameterMapgetRequiredMultipartFile in interface ParameterMapparameterName - the name of the parameterjava.lang.IllegalArgumentException - when the parameter is not foundpublic AttributeMap asAttributeMap()
ParameterMapAttributeMap.asAttributeMap in interface ParameterMapprotected void initParameters(java.util.Map parameters)
parameters - the parametersprotected java.util.Map getMapInternal()
public java.lang.String toString()
toString in class java.lang.Object