Class Parameters

java.lang.Object
org.apache.tomcat.util.http.Parameters

public final class Parameters extends Object
Utility class for parsing and managing HTTP parameters.
  • Constructor Details

    • Parameters

      public Parameters()
      Construct a new Parameters instance with default settings.
  • Method Details

    • 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 Charset getCharset()
      Returns the character set used for decoding body parameters.
      Returns:
      the character set
    • setCharset

      public void setCharset(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(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 String[] getParameterValues(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 Enumeration<String> getParameterNames()
      Returns the names of all parameters.
      Returns:
      An enumeration of parameter names
    • getParameter

      public String getParameter(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(String key, String value) throws IllegalStateException
      Add a parameter with the given key and value.
      Parameters:
      key - The parameter name
      value - The parameter value
      Throws:
      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 parameters
      start - The start index in the byte array
      len - The length of the parameter data in the byte array
    • processParameters

      public void processParameters(MessageBytes data, Charset charset)
      Process the given MessageBytes as a set of URL-encoded parameters using the specified character set.
      Parameters:
      data - The MessageBytes containing the parameters
      charset - The character set to use for decoding
    • toString

      public String toString()
      Debug purpose
      Overrides:
      toString in class Object