Class RequestFormParams
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<RequestFormParam>
,Collection<RequestFormParam>
,List<RequestFormParam>
,RandomAccess
The RequestFormParams
object is the API for accessing the HTTP request content as form data.
It can be accessed by passing it as a parameter on your REST Java method:
Example:
Note that this object does NOT take GET parameters into account and only returns values found in the content of the request.
Some important methods on this class are:
RequestFormParams
- Methods for retrieving form data parameters:
- Methods overridding form data parameters:
- Other methods:
See Also:
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(jakarta.servlet.http.Part part) Adds a parameter value.Adds a parameter value.add
(NameValuePair... parameters) Adds request parameter values.addDefault
(String name, String value) Adds a default entry to the form data parameters.addDefault
(List<? extends NameValuePair> pairs) Adds default entries to these parameters.addDefault
(NameValuePair... pairs) Adds default entries to these parameters.Converts this object to a query string.caseSensitive
(boolean value) Sets case sensitivity for names in this list.boolean
Returnstrue if the parameters with the specified names are present.boolean
containsAny
(String... names) Returnstrue if the parameter with any of the specified names are present.copy()
Makes a copy of these parameters.<T> Optional<T>
Returns the form data parameter as the specified bean type.Returns the last parameter with the specified name.Returns all the parameters with the specified name.Returns the first parameter with the specified name.Returns the last parameter with the specified name.getNames()
Returns all the unique header names in this list.Returns all headers in sorted order.parser
(HttpPartParserSession value) Sets the parser to use for part values.Remove parameters.Sets a parameter value.set
(NameValuePair... parameters) Sets request header values.Returns all headers with the specified name.Returns a copy of this object but only with the specified param names copied.toString()
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll
-
Constructor Details
-
RequestFormParams
Constructor.- Parameters:
req
- The request creating this bean.caseSensitive
- Whether case-sensitive name matching is enabled.- Throws:
Exception
- Any exception can be thrown.
-
-
Method Details
-
parser
Sets the parser to use for part values.- Parameters:
value
- The new value for this setting.- Returns:
- This object.
-
caseSensitive
Sets case sensitivity for names in this list.- Parameters:
value
- The new value for this setting.- Returns:
- This object (for method chaining).
-
addDefault
Adds default entries to these parameters.Similar to
set(String, Object)
but doesn't override existing values.- Parameters:
pairs
- The default entries.
Can benull .- Returns:
- This object.
-
addDefault
Adds default entries to these parameters.Similar to
set(String, Object)
but doesn't override existing values.- Parameters:
pairs
- The default entries.
Can benull .- Returns:
- This object.
-
addDefault
Adds a default entry to the form data parameters.- Parameters:
name
- The name.value
- The value.- Returns:
- This object.
-
add
Adds a parameter value.Parameter is added to the end.
Existing parameter with the same name are not changed.- Parameters:
name
- The parameter name. Must not benull .value
- The parameter value.- Returns:
- This object.
-
add
Adds request parameter values.Parameters are added to the end.
Existing parameters with the same name are not changed.- Parameters:
parameters
- The parameter objects. Must not benull .- Returns:
- This object.
-
add
Adds a parameter value.Parameter is added to the end.
Existing parameter with the same name are not changed.- Parameters:
part
- The parameter part. Must not benull .- Returns:
- This object.
-
set
Sets a parameter value.Parameter is added to the end.
Any previous parameters with the same name are removed.- Parameters:
name
- The parameter name. Must not benull .value
- The parameter value.
Converted to a string usingObject.toString()
.
Can benull .- Returns:
- This object.
-
set
Sets request header values.Parameters are added to the end of the headers.
Any previous parameters with the same name are removed.- Parameters:
parameters
- The parameters to set. Must not benull or containnull .- Returns:
- This object.
-
remove
Remove parameters.- Parameters:
name
- The parameter names. Must not benull .- Returns:
- This object.
-
subset
Returns a copy of this object but only with the specified param names copied.- Parameters:
names
- The list to include in the copy.- Returns:
- A new list object.
-
contains
Returnstrue if the parameters with the specified names are present.- Parameters:
name
- The parameter name. Must not benull .- Returns:
true if the parameters with the specified names are present.
-
containsAny
Returnstrue if the parameter with any of the specified names are present.- Parameters:
names
- The parameter names. Must not benull .- Returns:
true if the parameter with any of the specified names are present.
-
getAll
Returns all the parameters with the specified name.- Parameters:
name
- The parameter name.- Returns:
- The list of all parameters with the specified name, or an empty list if none are found.
-
stream
Returns all headers with the specified name.- Parameters:
name
- The header name.- Returns:
- The stream of all headers with matching names. Never
null .
-
getSorted
Returns all headers in sorted order.- Returns:
- The stream of all headers in sorted order.
-
getNames
Returns all the unique header names in this list.- Returns:
- The list of all unique header names in this list.
-
getFirst
Returns the first parameter with the specified name.Note that this method never returns
null and thatRequestHttpPart.isPresent()
can be used to test for the existence of the parameter.- Parameters:
name
- The parameter name.- Returns:
- The parameter. Never
null .
-
getLast
Returns the last parameter with the specified name.Note that this method never returns
null and thatRequestHttpPart.isPresent()
can be used to test for the existence of the parameter.- Parameters:
name
- The parameter name.- Returns:
- The parameter. Never
null .
-
get
Returns the last parameter with the specified name.This is equivalent to
getLast(String)
.- Parameters:
name
- The parameter name.- Returns:
- The parameter value, or
Optional.empty()
if it doesn't exist.
-
get
Returns the form data parameter as the specified bean type.Type must have a name specified via the
FormData
annotation and a public constructor that takes in eithervalue orname,value as strings.- Type Parameters:
T
- The bean type to create.- Parameters:
type
- The bean type to create.- Returns:
- The bean, never
null .
-
asQueryString
Converts this object to a query string.Returned query string does not start with
'?' .- Returns:
- A new query string, or an empty string if this object is empty.
-
copy
Makes a copy of these parameters.- Returns:
- A new parameters object.
-
toString
- Overrides:
toString
in classAbstractCollection<RequestFormParam>
-