public class RequestFormData extends LinkedHashMap<String,String[]>
Similar in functionality to the ServletRequest.getParameter(String)
except only looks in the body of the request, not parameters from
the URL query string.
This can be useful in cases where you're using GET parameters on FORM POSTs, and you don't want the body of the request to be read.
Use of this object is incompatible with using any other methods that access the body of the request (since this object will
consume the body).
Some examples:
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
RequestFormData() |
Modifier and Type | Method and Description |
---|---|
RequestFormData |
addDefault(Map<String,Object> defaultEntries)
Adds default entries to these form-data parameters.
|
RequestFormData |
addDefault(String name,
Object value)
Adds a default entries to these form-data parameters.
|
<T> T |
get(HttpPartParser parser,
String name,
Class<T> type)
Same as
get(String, Object, Class) but allows you to override the part parser. |
<T> T |
get(HttpPartParser parser,
String name,
T def,
Class<T> type)
Same as
get(String, Object, Class) but allows you to override the part parser. |
<T> T |
get(HttpPartParser parser,
String name,
Type type,
Type... args)
Same as
get(String, Type, Type...) but allows you to override the part parser. |
<T> T |
get(String name,
Class<T> type)
Returns the specified form-data parameter value converted to a POJO using the
HttpPartParser registered with the resource. |
<T> T |
get(String name,
T def,
Class<T> type)
Same as
get(String, Class) except returns a default value if not specified. |
<T> T |
get(String name,
Type type,
Type... args)
Returns the specified form-data parameter value converted to a POJO using the
HttpPartParser registered with the resource. |
<T> T |
getAll(HttpPartParser parser,
String name,
Class<T> type)
Same as
getAll(String, Class) but allows you to override the part parser. |
<T> T |
getAll(HttpPartParser parser,
String name,
Type type,
Type... args)
Same as
getAll(String, Type, Type...) but allows you to override the part parser. |
<T> T |
getAll(String name,
Class<T> type)
Same as
get(String, Class) except for use on multi-part parameters
(e.g. |
<T> T |
getAll(String name,
Type type,
Type... args)
Same as
get(String, Type, Type...) except for use on multi-part parameters
(e.g. |
boolean |
getBoolean(String name)
Same as
getString(String) but converts the value to a boolean. |
boolean |
getBoolean(String name,
boolean def)
Same as
getString(String,String) but converts the value to a boolean. |
int |
getInt(String name)
Same as
getString(String) but converts the value to an integer. |
int |
getInt(String name,
int def)
Same as
getString(String,String) but converts the value to an integer. |
String |
getString(String name)
Returns a form-data parameter value.
|
String |
getString(String name,
String def)
Same as
getString(String) except returns a default value if |
void |
put(String name,
Object value)
Sets a request form-data parameter value.
|
String |
toString() |
String |
toString(boolean sorted)
Converts the form-data parameters to a readable string.
|
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
equals, hashCode
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
public RequestFormData()
public RequestFormData addDefault(Map<String,Object> defaultEntries)
This includes the default form-data parameters defined on the resource and method levels.
defaultEntries
- The default entries.
public RequestFormData addDefault(String name, Object value)
Similar to put(String, Object)
but doesn't override existing values.
name
- The form-data parameter name.value
- The form-data parameter value.
toString()
.
public void put(String name, Object value)
name
- The parameter name.value
- The parameter value.public String getString(String name)
Parameter lookup is case-insensitive (consistent with WAS, but differs from Tomcat).
get(name, String.class)
which will convert the value from UON
notation:
name
- The form-data parameter name.public String getString(String name, String def)
getString(String)
except returns a default value if name
- The form-data parameter name.def
- The default value.public int getInt(String name)
getString(String)
but converts the value to an integer.name
- The form-data parameter name.0
if parameter does not exist or is public int getInt(String name, int def)
getString(String,String)
but converts the value to an integer.name
- The form-data parameter name.def
- The default value.public boolean getBoolean(String name)
getString(String)
but converts the value to a boolean.name
- The form-data parameter name.public boolean getBoolean(String name, boolean def)
getString(String,String)
but converts the value to a boolean.name
- The form-data parameter name.def
- The default value.public <T> T get(String name, Class<T> type) throws ParseException
HttpPartParser
registered with the resource.
T
- The class type to convert the parameter value to.name
- The parameter name.type
- The class type to convert the parameter value to.ParseException
public <T> T get(HttpPartParser parser, String name, Class<T> type) throws ParseException
get(String, Object, Class)
but allows you to override the part parser.T
- The class type to convert the parameter value to.parser
- The parser to use for parsing the string value.
name
- The parameter name.type
- The class type to convert the parameter value to.ParseException
public <T> T get(String name, T def, Class<T> type) throws ParseException
get(String, Class)
except returns a default value if not specified.T
- The class type to convert the parameter value to.name
- The parameter name.def
- The default value if the parameter was not specified or is type
- The class type to convert the parameter value to.ParseException
public <T> T get(HttpPartParser parser, String name, T def, Class<T> type) throws ParseException
get(String, Object, Class)
but allows you to override the part parser.T
- The class type to convert the parameter value to.parser
- The parser to use for parsing the string value.
name
- The parameter name.def
- The default value if the parameter was not specified or is type
- The class type to convert the parameter value to.ParseException
public <T> T getAll(String name, Class<T> type) throws ParseException
get(String, Class)
except for use on multi-part parameters
(e.g. This method must only be called when parsing into classes of type Collection or array.
name
- The parameter name.type
- The class type to convert the parameter value to.ParseException
public <T> T getAll(HttpPartParser parser, String name, Class<T> type) throws ParseException
getAll(String, Class)
but allows you to override the part parser.
This method must only be called when parsing into classes of type Collection or array.
parser
- The parser to use for parsing the string value.
name
- The parameter name.type
- The class type to convert the parameter value to.ParseException
public <T> T get(String name, Type type, Type... args) throws ParseException
HttpPartParser
registered with the resource.
Similar to get(String,Class)
but allows for complex collections of POJOs to be created.
Collections
must be followed by zero or one parameter representing the value type.
Maps
must be followed by zero or two parameters representing the key and value types.
name
- The parameter name.type
- The type of object to create.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
args
- The type arguments of the class if it's a collection or map.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
ParseException
public <T> T get(HttpPartParser parser, String name, Type type, Type... args) throws ParseException
get(String, Type, Type...)
but allows you to override the part parser.parser
- The parser to use for parsing the string value.
name
- The parameter name.type
- The type of object to create.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
args
- The type arguments of the class if it's a collection or map.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
ParseException
public <T> T getAll(String name, Type type, Type... args) throws ParseException
get(String, Type, Type...)
except for use on multi-part parameters
(e.g. This method must only be called when parsing into classes of type Collection or array.
name
- The parameter name.type
- The type of object to create.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
args
- The type arguments of the class if it's a collection or map.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
ParseException
public <T> T getAll(HttpPartParser parser, String name, Type type, Type... args) throws ParseException
getAll(String, Type, Type...)
but allows you to override the part parser.parser
- The parser to use for parsing the string value.
name
- The parameter name.type
- The type of object to create.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
args
- The type arguments of the class if it's a collection or map.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
ParseException
public String toString(boolean sorted)
sorted
- Sort the form-data parameters by name.Copyright © 2018 Apache. All rights reserved.