public abstract class PortletRequestUtils
extends java.lang.Object
This approach is very useful for simple submissions, where binding request parameters to a command object would be overkill.
Modifier and Type | Class and Description |
---|---|
private static class |
PortletRequestUtils.BooleanParser |
private static class |
PortletRequestUtils.DoubleParser |
private static class |
PortletRequestUtils.FloatParser |
private static class |
PortletRequestUtils.IntParser |
private static class |
PortletRequestUtils.LongParser |
private static class |
PortletRequestUtils.ParameterParser<T> |
private static class |
PortletRequestUtils.StringParser |
Modifier and Type | Field and Description |
---|---|
private static PortletRequestUtils.BooleanParser |
BOOLEAN_PARSER |
private static PortletRequestUtils.DoubleParser |
DOUBLE_PARSER |
private static PortletRequestUtils.FloatParser |
FLOAT_PARSER |
private static PortletRequestUtils.IntParser |
INT_PARSER |
private static PortletRequestUtils.LongParser |
LONG_PARSER |
private static PortletRequestUtils.StringParser |
STRING_PARSER |
Constructor and Description |
---|
PortletRequestUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Boolean |
getBooleanParameter(PortletRequest request,
java.lang.String name)
Get a Boolean parameter, or
null if not present. |
static boolean |
getBooleanParameter(PortletRequest request,
java.lang.String name,
boolean defaultVal)
Get a boolean parameter, with a fallback value.
|
static boolean[] |
getBooleanParameters(PortletRequest request,
java.lang.String name)
Get an array of boolean parameters, return an empty array if not found.
|
static java.lang.Double |
getDoubleParameter(PortletRequest request,
java.lang.String name)
Get a Double parameter, or
null if not present. |
static double |
getDoubleParameter(PortletRequest request,
java.lang.String name,
double defaultVal)
Get a double parameter, with a fallback value.
|
static double[] |
getDoubleParameters(PortletRequest request,
java.lang.String name)
Get an array of double parameters, return an empty array if not found.
|
static java.lang.Float |
getFloatParameter(PortletRequest request,
java.lang.String name)
Get a Float parameter, or
null if not present. |
static float |
getFloatParameter(PortletRequest request,
java.lang.String name,
float defaultVal)
Get a float parameter, with a fallback value.
|
static float[] |
getFloatParameters(PortletRequest request,
java.lang.String name)
Get an array of float parameters, return an empty array if not found.
|
static java.lang.Integer |
getIntParameter(PortletRequest request,
java.lang.String name)
Get an Integer parameter, or
null if not present. |
static int |
getIntParameter(PortletRequest request,
java.lang.String name,
int defaultVal)
Get an int parameter, with a fallback value.
|
static int[] |
getIntParameters(PortletRequest request,
java.lang.String name)
Get an array of int parameters, return an empty array if not found.
|
static java.lang.Long |
getLongParameter(PortletRequest request,
java.lang.String name)
Get a Long parameter, or
null if not present. |
static long |
getLongParameter(PortletRequest request,
java.lang.String name,
long defaultVal)
Get a long parameter, with a fallback value.
|
static long[] |
getLongParameters(PortletRequest request,
java.lang.String name)
Get an array of long parameters, return an empty array if not found.
|
static boolean |
getRequiredBooleanParameter(PortletRequest request,
java.lang.String name)
Get a boolean parameter, throwing an exception if it isn't found
or isn't a boolean.
|
static boolean[] |
getRequiredBooleanParameters(PortletRequest request,
java.lang.String name)
Get an array of boolean parameters, throwing an exception if not found
or one isn't a boolean.
|
static double |
getRequiredDoubleParameter(PortletRequest request,
java.lang.String name)
Get a double parameter, throwing an exception if it isn't found or isn't a number.
|
static double[] |
getRequiredDoubleParameters(PortletRequest request,
java.lang.String name)
Get an array of double parameters, throwing an exception if not found or one is not a number.
|
static float |
getRequiredFloatParameter(PortletRequest request,
java.lang.String name)
Get a float parameter, throwing an exception if it isn't found or isn't a number.
|
static float[] |
getRequiredFloatParameters(PortletRequest request,
java.lang.String name)
Get an array of float parameters, throwing an exception if not found or one is not a number.
|
static int |
getRequiredIntParameter(PortletRequest request,
java.lang.String name)
Get an int parameter, throwing an exception if it isn't found or isn't a number.
|
static int[] |
getRequiredIntParameters(PortletRequest request,
java.lang.String name)
Get an array of int parameters, throwing an exception if not found or one is not a number..
|
static long |
getRequiredLongParameter(PortletRequest request,
java.lang.String name)
Get a long parameter, throwing an exception if it isn't found or isn't a number.
|
static long[] |
getRequiredLongParameters(PortletRequest request,
java.lang.String name)
Get an array of long parameters, throwing an exception if not found or one is not a number.
|
static java.lang.String |
getRequiredStringParameter(PortletRequest request,
java.lang.String name)
Get a String parameter, throwing an exception if it isn't found or is empty.
|
static java.lang.String[] |
getRequiredStringParameters(PortletRequest request,
java.lang.String name)
Get an array of String parameters, throwing an exception if not found or one is empty.
|
static java.lang.String |
getStringParameter(PortletRequest request,
java.lang.String name)
Get a String parameter, or
null if not present. |
static java.lang.String |
getStringParameter(PortletRequest request,
java.lang.String name,
java.lang.String defaultVal)
Get a String parameter, with a fallback value.
|
static java.lang.String[] |
getStringParameters(PortletRequest request,
java.lang.String name)
Get an array of String parameters, return an empty array if not found.
|
private static final PortletRequestUtils.IntParser INT_PARSER
private static final PortletRequestUtils.LongParser LONG_PARSER
private static final PortletRequestUtils.FloatParser FLOAT_PARSER
private static final PortletRequestUtils.DoubleParser DOUBLE_PARSER
private static final PortletRequestUtils.BooleanParser BOOLEAN_PARSER
private static final PortletRequestUtils.StringParser STRING_PARSER
public static java.lang.Integer getIntParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
null
if not present.
Throws an exception if it the parameter value isn't a number.request
- current portlet requestname
- the name of the parameternull
if not presentPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static int getIntParameter(PortletRequest request, java.lang.String name, int defaultVal)
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static int[] getIntParameters(PortletRequest request, java.lang.String name)
request
- current portlet requestname
- the name of the parameter with multiple possible valuespublic static int getRequiredIntParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
request
- current portlet requestname
- the name of the parameterPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static int[] getRequiredIntParameters(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
request
- current portlet requestname
- the name of the parameter with multiple possible valuesPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static java.lang.Long getLongParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
null
if not present.
Throws an exception if it the parameter value isn't a number.request
- current portlet requestname
- the name of the parameternull
if not presentPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static long getLongParameter(PortletRequest request, java.lang.String name, long defaultVal)
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static long[] getLongParameters(PortletRequest request, java.lang.String name)
request
- current portlet requestname
- the name of the parameter with multiple possible valuespublic static long getRequiredLongParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
request
- current portlet requestname
- the name of the parameterPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static long[] getRequiredLongParameters(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
request
- current portlet requestname
- the name of the parameter with multiple possible valuesPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static java.lang.Float getFloatParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
null
if not present.
Throws an exception if it the parameter value isn't a number.request
- current portlet requestname
- the name of the parameternull
if not presentPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static float getFloatParameter(PortletRequest request, java.lang.String name, float defaultVal)
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static float[] getFloatParameters(PortletRequest request, java.lang.String name)
request
- current portlet requestname
- the name of the parameter with multiple possible valuespublic static float getRequiredFloatParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
request
- current portlet requestname
- the name of the parameterPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static float[] getRequiredFloatParameters(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
request
- current portlet requestname
- the name of the parameter with multiple possible valuesPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static java.lang.Double getDoubleParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
null
if not present.
Throws an exception if it the parameter value isn't a number.request
- current portlet requestname
- the name of the parameternull
if not presentPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static double getDoubleParameter(PortletRequest request, java.lang.String name, double defaultVal)
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static double[] getDoubleParameters(PortletRequest request, java.lang.String name)
request
- current portlet requestname
- the name of the parameter with multiple possible valuespublic static double getRequiredDoubleParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
request
- current portlet requestname
- the name of the parameterPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static double[] getRequiredDoubleParameters(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
request
- current portlet requestname
- the name of the parameter with multiple possible valuesPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static java.lang.Boolean getBooleanParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
null
if not present.
Throws an exception if it the parameter value isn't a boolean.
Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).
request
- current portlet requestname
- the name of the parameternull
if not presentPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static boolean getBooleanParameter(PortletRequest request, java.lang.String name, boolean defaultVal)
Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static boolean[] getBooleanParameters(PortletRequest request, java.lang.String name)
Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).
request
- current portlet requestname
- the name of the parameter with multiple possible valuespublic static boolean getRequiredBooleanParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).
request
- current portlet requestname
- the name of the parameterPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static boolean[] getRequiredBooleanParameters(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).
request
- current portlet requestname
- the name of the parameterPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static java.lang.String getStringParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
null
if not present.
Throws an exception if it the parameter value is empty.request
- current portlet requestname
- the name of the parameternull
if not presentPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static java.lang.String getStringParameter(PortletRequest request, java.lang.String name, java.lang.String defaultVal)
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static java.lang.String[] getStringParameters(PortletRequest request, java.lang.String name)
request
- current portlet requestname
- the name of the parameter with multiple possible valuespublic static java.lang.String getRequiredStringParameter(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
request
- current portlet requestname
- the name of the parameterPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caughtpublic static java.lang.String[] getRequiredStringParameters(PortletRequest request, java.lang.String name) throws PortletRequestBindingException
request
- current portlet requestname
- the name of the parameterPortletRequestBindingException
- a subclass of PortletException,
so it doesn't need to be caught