Class Parameters
java.lang.Object
org.apache.tomcat.util.http.Parameters
Utility class for parsing and managing HTTP parameters.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddParameter(String key, String value) Add a parameter with the given key and value.Returns the character set used for decoding body parameters.getParameter(String name) Returns the first value of the parameter with the given name.Returns the names of all parameters.String[]getParameterValues(String name) Returns the values of the parameter with the given name.voidProcess the query string into parametersvoidprocessParameters(byte[] bytes, int start, int len) Process the given byte array as a set of URL-encoded parameters using the current character set.voidprocessParameters(MessageBytes data, Charset charset) Process the given MessageBytes as a set of URL-encoded parameters using the specified character set.voidrecycle()Reset this object so it can be reused for a new request.voidsetCharset(Charset charset) Set the character set used for decoding body parameters.voidsetLimit(int limit) Set the maximum number of parameters allowed.voidsetQuery(MessageBytes queryMB) Set the query string to be parsed into parameters.voidsetQueryStringCharset(Charset queryStringCharset) Set the character set used for decoding query string parameters.voidSet the URL decoder to use for decoding parameter names and values.intsize()Returns the number of parameters that have been parsed.toString()Debug purpose
-
Constructor Details
-
Parameters
public Parameters()Construct a newParametersinstance with default settings.
-
-
Method Details
-
setQuery
Set the query string to be parsed into parameters.- Parameters:
queryMB- The query string as a MessageBytes object
-
setLimit
public void setLimit(int limit) Set the maximum number of parameters allowed.- Parameters:
limit- The maximum number of parameters, or -1 for no limit
-
getCharset
Returns the character set used for decoding body parameters.- Returns:
- the character set
-
setCharset
Set the character set used for decoding body parameters.- Parameters:
charset- The character set, or null to use the default (ISO-8859-1)
-
setQueryStringCharset
Set the character set used for decoding query string parameters.- Parameters:
queryStringCharset- The character set, or null to use the default (UTF-8)
-
size
public int size()Returns the number of parameters that have been parsed.- Returns:
- the number of parameters
-
recycle
public void recycle()Reset this object so it can be reused for a new request. -
getParameterValues
-
getParameterNames
Returns the names of all parameters.- Returns:
- An enumeration of parameter names
-
getParameter
-
handleQueryParameters
public void handleQueryParameters()Process the query string into parameters -
addParameter
Add a parameter with the given key and value.- Parameters:
key- The parameter namevalue- The parameter value- Throws:
IllegalStateException- If the parameter count limit has been reached
-
setURLDecoder
Set the URL decoder to use for decoding parameter names and values.- Parameters:
u- The URL decoder
-
processParameters
public void processParameters(byte[] bytes, int start, int len) Process the given byte array as a set of URL-encoded parameters using the current character set.- Parameters:
bytes- The byte array containing the parametersstart- The start index in the byte arraylen- The length of the parameter data in the byte array
-
processParameters
Process the given MessageBytes as a set of URL-encoded parameters using the specified character set.- Parameters:
data- The MessageBytes containing the parameterscharset- The character set to use for decoding
-
toString
-