Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.knowgate.misc
Class CGIParser

    java.lang.Object
      com.knowgate.misc.CGIParser

    public class CGIParser

extends java.lang.Object

Parses query string data from a CGI request into name value pairs.

More information about this class is available from ostermiller.org.

Since:
  ostermillerutils 1.00.00

Constructor Summary
`CGIParser(java.io.InputStream in)` Deprecated. This method does not decode URLEncoded values properly. Please use a method that specifies a character set.
`CGIParser(java.io.InputStream in, java.lang.String charset)` Extract the name, value pairs from the given input stream and make them available for retrieval.
`CGIParser(java.io.Reader in)` Deprecated. This method does not decode URLEncoded values properly. Please use a method that specifies a character set.
`CGIParser(java.io.Reader in, java.lang.String charset)` Extract the name, value pairs from the given reader and make them available for retrieval.
`CGIParser(java.lang.String s)` Deprecated. This method does not decode URLEncoded values properly. Please use a method that specifies a character set.
`CGIParser(java.lang.String s, java.lang.String charset)` Extract the name, value pairs from the given string and make them available for retrieval.

Method Summary
`void` | `addParameter(java.lang.String name, java.lang.String value)` Set a name value pair as used in a URL.
`void` | `addParameter(java.lang.String name, java.lang.String[] values)` Set a name value pair as used in a URL.
`java.lang.String` | `getParameter(java.lang.String name)` Returns the value of a request parameter as a String, or null if the parameter does not exist.
`java.lang.String[]` | `getParameterNameList()` Returns the names of the parameters contained in this request.
`java.util.Enumeration<java.lang.String>` | `getParameterNames()` Returns an Enumeration of String objects containing the names of the parameters contained in this request.
`NameValuePair[]` | `getParameters()` Get the all the parameters in the order in which they were added.
`java.lang.String` | `getParameterValue(java.lang.String name)` Returns a String with the first value of the given parameter or null if the parameter does not exist.
`java.lang.String[]` | `getParameterValues(java.lang.String name)` Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
`void` | `setParameter(java.lang.String name, java.lang.String value)` Set a name value pair as used in a URL.
`void` | `setParameter(java.lang.String name, java.lang.String[] values)` Set a name value pair as used in a URL.
`java.lang.String` | `toString()` Returns the name value pairs properly escaped and written in URL format with UTF-8 URL encoding.
`java.lang.String` | `toString(java.lang.String enc)` Returns the name value pairs properly escaped and written in URL format.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### CGIParser

    @Deprecated
    public CGIParser(java.io.InputStream in)
              throws java.io.IOException

  Deprecated. This method does not decode URLEncoded values properly. Please use a method that specifies a character set.

  Extract the name, value pairs from the given input stream and make them available for retrieval.

  The stream is read until the stream contains no more bytes.

  Byte to character conversion on the stream is done according the platforms default character encoding.

  Parameters:
    `in` - Stream containing CGI Encoded name value pairs.
  Throws:
    `java.io.IOException` - If an input error occurs
  Since:
    ostermillerutils 1.00.00

### CGIParser

    public CGIParser(java.io.InputStream in,
                     java.lang.String charset)
              throws java.io.IOException,
                     java.io.UnsupportedEncodingException

  Extract the name, value pairs from the given input stream and make them available for retrieval.

  The stream is read until the stream contains no more bytes.

  The character set is used both when converting the byte stream to a character stream and when decoding URL decoded parameters.

  Parameters:
    `in` - Stream containing CGI Encoded name value pairs.
    `charset` - Character encoding to use when converting bytes to characters
  Throws:
    `java.io.IOException` - If an input error occurs
    `java.io.UnsupportedEncodingException` - If the character set provided is not recognized
  Since:
    ostermillerutils 1.03.00

### CGIParser

    @Deprecated
    public CGIParser(java.io.Reader in)
              throws java.io.IOException

  Deprecated. This method does not decode URLEncoded values properly. Please use a method that specifies a character set.

  Extract the name, value pairs from the given reader and make them available for retrieval.

  The reader is read until the stream contains no more characters.

  Parameters:
    `in` - Reader containing CGI Encoded name value pairs.
  Throws:
    `java.io.IOException` - If an input error occurs
  Since:
    ostermillerutils 1.00.00

### CGIParser

    public CGIParser(java.io.Reader in,
                     java.lang.String charset)
              throws java.io.IOException,
                     java.io.UnsupportedEncodingException

  Extract the name, value pairs from the given reader and make them available for retrieval.

  The reader is read until the stream contains no more characters.

  Parameters:
    `in` - Reader containing CGI Encoded name value pairs.
    `charset` - Character encoding to use when converting bytes to characters
  Throws:
    `java.io.IOException` - If an input error occurs
    `java.io.UnsupportedEncodingException` - If the character set provided is not recognized
  Since:
    ostermillerutils 1.03.00

### CGIParser

    @Deprecated
    public CGIParser(java.lang.String s)

  Deprecated. This method does not decode URLEncoded values properly. Please use a method that specifies a character set.

  Extract the name, value pairs from the given string and make them available for retrieval.

  Parameters:
    `s` - CGI Encoded name value pairs.
  Since:
    ostermillerutils 1.00.00

### CGIParser

    public CGIParser(java.lang.String s,
                     java.lang.String charset)
              throws java.io.UnsupportedEncodingException

  Extract the name, value pairs from the given string and make them available for retrieval.

  Parameters:
    `s` - CGI Encoded name value pairs.
    `charset` - Character encoding to use when converting bytes to characters
  Throws:
    `java.io.UnsupportedEncodingException` - If the character set provided is not recognized
  Since:
    ostermillerutils 1.03.00

Method Detail

### getParameterValue

    public java.lang.String getParameterValue(java.lang.String name)

  Returns a String with the first value of the given parameter or null if the parameter does not exist.

  Parameters:
    `name` - a String containing the name of the parameter whose value is requested
  Returns:
    an array of String objects containing the parameter's values
  Since:
    ostermillerutils 1.00.00

### getParameterValues

    public java.lang.String[] getParameterValues(java.lang.String name)

  Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist. If the parameter has a single value, the array has a length of 1.

  Parameters:
    `name` - a String containing the name of the parameter whose value is requested
  Returns:
    an array of String objects containing the parameter's values
  Since:
    ostermillerutils 1.00.00

### setParameter

    public void setParameter(java.lang.String name,
                             java.lang.String value)

  Set a name value pair as used in a URL. This method will replace any previously defined values with the single value specified. If the value is null, the name is removed.

  Parameters:
    `name` - a String specifying the name of the parameter.
    `value` - a String specifying the value of the single parameter, or null to remove.
  Since:
    ostermillerutils 1.02.15

### setParameter

    public void setParameter(java.lang.String name,
                             java.lang.String[] values)

  Set a name value pair as used in a URL. This method will replace any previously defined values with the single value specified. If values is null or empty, the name is removed.

  Parameters:
    `name` - a String specifying the name of the parameter.
    `values` - a String array specifying the values for the parameter, or null to remove.
  Throws:
    `java.lang.NullPointerException` - if any of the values is null.
  Since:
    ostermillerutils 1.02.15

### addParameter

    public void addParameter(java.lang.String name,
                             java.lang.String value)

  Set a name value pair as used in a URL. This method will add to any previously defined values the values specified. If value is null, this method has no effect.

  Parameters:
    `name` - a String specifying the name of the parameter.
    `value` - a String specifying the value of the single parameter, or null to remove.
  Since:
    ostermillerutils 1.02.15

### addParameter

    public void addParameter(java.lang.String name,
                             java.lang.String[] values)

  Set a name value pair as used in a URL. This method will add to any previously defined values the values specified. If values is null, this method has no effect.

  Parameters:
    `name` - a String specifying the name of the parameter.
    `values` - a String array specifying the values of the parameter, or null to remove.
  Throws:
    `java.lang.NullPointerException` - if any of the values is null.
  Since:
    ostermillerutils 1.02.15

### getParameter

    public java.lang.String getParameter(java.lang.String name)

  Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request.

  You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String).

  If you use this method with a multiple valued parameter, the value returned is equal to the first value in the array returned by getParameterValues.

  Parameters:
    `name` - a String specifying the name of the parameter
  Returns:
    a String representing the single value of the parameter
  Since:
    ostermillerutils 1.00.00

### getParameterNames

    public java.util.Enumeration<java.lang.String> getParameterNames()

  Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Enumeration.

  Returns:
    an Enumeration of String objects, each String containing the name of a request parameter; or an empty Enumeration if the request has no parameters
  Since:
    ostermillerutils 1.00.00

### getParameterNameList

    public java.lang.String[] getParameterNameList()

  Returns the names of the parameters contained in this request. If the request has no parameters, the method returns an empty String array. Each name will appear only once, even if it was contained in the request multiple times. The order of the names may not match the order from the request.

  Returns:
    An array of Strings, each of which is the name of a request parameter; or an array of length zero if the request has no parameters
  Since:
    ostermillerutils 1.03.00

### getParameters

    public NameValuePair[] getParameters()

  Get the all the parameters in the order in which they were added.

  Returns:
    array of all name value pairs.

### toString

    public java.lang.String toString(java.lang.String enc)
                              throws java.io.UnsupportedEncodingException

  Returns the name value pairs properly escaped and written in URL format.

  Parameters:
    `enc` - Character encoding to use when escaping characters.
  Returns:
    URLEncoded name value pairs.
  Throws:
    `java.io.UnsupportedEncodingException` - If the named encoding is not supported.
  Since:
    ostermillerutils 1.00.00

### toString

    public java.lang.String toString()

  Returns the name value pairs properly escaped and written in URL format with UTF-8 URL encoding.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    URLEncoded name value pairs.
  Since:
    ostermillerutils 1.03.00

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD