|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.threerings.servlet.util.Parameters
public class Parameters
Provides convenient access to and conversion of the parameters of an HttpServletRequest.
| Constructor Summary | |
|---|---|
Parameters(javax.servlet.ServletRequest req)
|
|
| Method Summary | ||
|---|---|---|
Collection<Tuple<String,String>> |
entries()
Returns all the names and values in the parameters. |
|
String |
get(String name)
Returns the value for the parameter on this request or null if it has no such parameter. |
|
|
get(String name,
Function<String,T> converter,
T def)
Returns the value for the parameter on this request as converted by converter
or defif it has no such parameter. |
|
String |
get(String name,
String def)
Returns the value for the parameter on this request or def if it has no such
parameter. |
|
|
getAll(String name,
Function<String,T> converter,
T... defaultValues)
Returns all the values for the given parameter on the request as converted by converter, or defaultValues if it has no such parameter. |
|
String[] |
getAll(String name,
String... defaultValues)
Returns all the values for the given parameter on the request, or defaultValues
if it has no such parameter. |
|
boolean |
has(String name)
Returns true if the request contains the given parameter. |
|
Set<String> |
names()
Returns an Iterable over all the parameter names for this request. |
|
String |
require(String name)
Returns the value for the parameter on this request or throws NullPointerException if it has no such parameter. |
|
|
require(String name,
Function<String,T> converter)
Returns the value for the parameter on this request as converted by converter
or throws NullPointerException if it has no such parameter. |
|
Collection<String[]> |
values()
Returns a Collection of all the parameter values for this request. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Parameters(javax.servlet.ServletRequest req)
| Method Detail |
|---|
public Set<String> names()
public Collection<String[]> values()
public Collection<Tuple<String,String>> entries()
Tuple.left and the
value is Tuple.right. If a name appears multiple times, it'll be in multiple
tuples.
public boolean has(String name)
public String get(String name)
public String get(String name,
String def)
def if it has no such
parameter. IllegalStateException is thrown if the request has multiple values for the
parameter.
public <T> T get(String name,
Function<String,T> converter,
T def)
converter
or defif it has no such parameter.
If converter can't handle the value and throws
ConversionFailedException, that will be propagated by this method with the
parameter name and value filled in. Any other exceptions thrown by converter
will be wrapped in ConversionFailedException and rethrown.
IllegalStateException is thrown if the request has multiple values for the parameter.
public String require(String name)
NullPointerException if it has no such parameter. IllegalStateException is
thrown if the request has multiple values for the parameter.
public <T> T require(String name,
Function<String,T> converter)
converter
or throws NullPointerException if it has no such parameter.
If converter can't handle the value and throws
ConversionFailedException, that will be propagated by this method with the
parameter name and value filled in. Any other exceptions thrown by converter
will be wrapped in ConversionFailedException and rethrown.
IllegalStateException is thrown if the request has multiple values for the parameter.
public String[] getAll(String name,
String... defaultValues)
defaultValues
if it has no such parameter.
public <T> Collection<T> getAll(String name,
Function<String,T> converter,
T... defaultValues)
converter, or defaultValues if it has no such parameter.
If converter can't handle the value and throws
ConversionFailedException, that will be propagated by this method with the
parameter name and value filled in. Any other exceptions thrown by converter
will be wrapped in ConversionFailedException and rethrown.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||