Package org.apache.tomcat.util.http
Class Parameters
- java.lang.Object
-
- org.apache.tomcat.util.http.Parameters
-
public final class Parameters extends java.lang.ObjectUtility class for parsing and managing HTTP parameters.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classParameters.FailReason
-
Constructor Summary
Constructors Constructor Description Parameters()Construct a newParametersinstance with default settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddParameter(java.lang.String key, java.lang.String value)Add a parameter with the given key and value.java.nio.charset.CharsetgetCharset()Returns the character set used for decoding body parameters.java.lang.StringgetParameter(java.lang.String name)Returns the first value of the parameter with the given name.java.util.Enumeration<java.lang.String>getParameterNames()Returns the names of all parameters.java.lang.String[]getParameterValues(java.lang.String name)Returns the values of the parameter with the given name.Parameters.FailReasongetParseFailedReason()voidhandleQueryParameters()Process the query string into parametersbooleanisParseFailed()voidprocessParameters(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, java.nio.charset.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(java.nio.charset.Charset charset)Set the character set used for decoding body parameters.voidsetLimit(int limit)Set the maximum number of parameters allowed.voidsetParseFailedReason(Parameters.FailReason failReason)voidsetQuery(MessageBytes queryMB)Set the query string to be parsed into parameters.voidsetQueryStringCharset(java.nio.charset.Charset queryStringCharset)Set the character set used for decoding query string parameters.voidsetURLDecoder(UDecoder u)Set the URL decoder to use for decoding parameter names and values.intsize()Returns the number of parameters that have been parsed.java.lang.StringtoString()Debug purpose
-
-
-
Method Detail
-
setQuery
public void setQuery(MessageBytes queryMB)
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
public java.nio.charset.Charset getCharset()
Returns the character set used for decoding body parameters.- Returns:
- the character set
-
setCharset
public void setCharset(java.nio.charset.Charset charset)
Set the character set used for decoding body parameters.- Parameters:
charset- The character set, or null to use the default (ISO-8859-1)
-
setQueryStringCharset
public void setQueryStringCharset(java.nio.charset.Charset queryStringCharset)
Set the character set used for decoding query string parameters.- Parameters:
queryStringCharset- The character set, or null to use the default (UTF-8)
-
isParseFailed
public boolean isParseFailed()
-
getParseFailedReason
public Parameters.FailReason getParseFailedReason()
-
setParseFailedReason
public void setParseFailedReason(Parameters.FailReason failReason)
-
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
public java.lang.String[] getParameterValues(java.lang.String name)
Returns the values of the parameter with the given name.- Parameters:
name- The name of the parameter- Returns:
- The values of the parameter, or null if the parameter does not exist
-
getParameterNames
public java.util.Enumeration<java.lang.String> getParameterNames()
Returns the names of all parameters.- Returns:
- An enumeration of parameter names
-
getParameter
public java.lang.String getParameter(java.lang.String name)
Returns the first value of the parameter with the given name.- Parameters:
name- The name of the parameter- Returns:
- The first value of the parameter, or null if the parameter does not exist
-
handleQueryParameters
public void handleQueryParameters()
Process the query string into parameters
-
addParameter
public void addParameter(java.lang.String key, java.lang.String value) throws java.lang.IllegalStateExceptionAdd a parameter with the given key and value.- Parameters:
key- The parameter namevalue- The parameter value- Throws:
java.lang.IllegalStateException- If the parameter count limit has been reached
-
setURLDecoder
public void setURLDecoder(UDecoder u)
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
public void processParameters(MessageBytes data, java.nio.charset.Charset charset)
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
public java.lang.String toString()
Debug purpose- Overrides:
toStringin classjava.lang.Object
-
-