| java.lang.Object com.Ostermiller.util.CGIParser
CGIParser | public class CGIParser (Code) | | Parses query string data from a CGI request into name value pairs.
More information about this class is available from ostermiller.org.
author: Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities since: ostermillerutils 1.00.00 |
Constructor Summary | |
public | CGIParser(InputStream in) Extract the name, value pairs from the given input stream and
make them available for retrieval. | public | CGIParser(InputStream in, String charset) Extract the name, value pairs from the given input stream and
make them available for retrieval. | public | CGIParser(Reader in) Extract the name, value pairs from the given reader and
make them available for retrieval. | public | CGIParser(Reader in, String charset) Extract the name, value pairs from the given reader and
make them available for retrieval. | public | CGIParser(String s) Extract the name, value pairs from the given string and
make them available for retrieval. | public | CGIParser(String s, String charset) Extract the name, value pairs from the given string and
make them available for retrieval. |
Method Summary | |
public void | addParameter(String name, String value) Set a name value pair as used in a URL.
This method will add to any previously defined values the values
specified. | public void | addParameter(String name, String[] values) Set a name value pair as used in a URL.
This method will add to any previously defined values the values
specified. | public String | getParameter(String name) Returns the value of a request parameter as a String, or null if the parameter does
not exist. | public String[] | getParameterNameList() Returns the names of the
parameters contained in this request. | public Enumeration<String> | getParameterNames() Returns an Enumeration of String objects containing the names of the
parameters contained in this request. | public String[] | getParameterValues(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. | public NameValuePair[] | getParameters() Get the all the parameters in the order in which they were added. | public void | setParameter(String name, 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. | public void | setParameter(String name, 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. | public String | toString(String enc) Returns the name value pairs properly escaped and written in URL format.
Parameters: enc - Character encoding to use when escaping characters. | public String | toString() Returns the name value pairs properly escaped and written in URL format
with UTF-8 URL encoding. |
CGIParser | public CGIParser(InputStream in) throws IOException(Code) | | 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: IOException - If an input error occurs since: ostermillerutils 1.00.00 |
CGIParser | public CGIParser(InputStream in, String charset) throws IOException, UnsupportedEncodingException(Code) | | 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. Parameters: charset - Character encoding to use when converting bytes to characters throws: IOException - If an input error occurs throws: UnsupportedEncodingException - If the character set provided is not recognized since: ostermillerutils 1.03.00 |
CGIParser | public CGIParser(Reader in) throws IOException(Code) | | 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: IOException - If an input error occurs since: ostermillerutils 1.00.00 |
CGIParser | public CGIParser(Reader in, String charset) throws IOException, UnsupportedEncodingException(Code) | | 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. Parameters: charset - Character encoding to use when converting bytes to characters throws: IOException - If an input error occurs throws: UnsupportedEncodingException - If the character set provided is not recognized since: ostermillerutils 1.03.00 |
CGIParser | public CGIParser(String s)(Code) | | 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(String s, String charset) throws UnsupportedEncodingException(Code) | | Extract the name, value pairs from the given string and
make them available for retrieval.
Parameters: s - CGI Encoded name value pairs. Parameters: charset - Character encoding to use when converting bytes to characters throws: UnsupportedEncodingException - If the character set provided is not recognized since: ostermillerutils 1.03.00 |
addParameter | public void addParameter(String name, String value)(Code) | | 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. Parameters: value - a String specifying the value of the single parameter, or null to remove. since: ostermillerutils 1.02.15 |
addParameter | public void addParameter(String name, String[] values)(Code) | | 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. Parameters: values - a String array specifying the values of the parameter, or null to remove. throws: NullPointerException - if any of the values is null. since: ostermillerutils 1.02.15 |
getParameter | public String getParameter(String name)(Code) | | 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 a String representing the single value of the parameter since: ostermillerutils 1.00.00 |
getParameterNameList | public String[] getParameterNameList()(Code) | | 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.
An array of Strings, each of which is the nameof a request parameter; or an array of length zero if the request hasno parameters since: ostermillerutils 1.03.00 |
getParameterNames | public Enumeration<String> getParameterNames()(Code) | | 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.
an Enumeration of String objects, each String containing the nameof a request parameter; or an empty Enumeration if the request hasno parameters since: ostermillerutils 1.00.00 |
getParameterValues | public String[] getParameterValues(String name)(Code) | | 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 an array of String objects containing the parameter's values since: ostermillerutils 1.00.00 |
getParameters | public NameValuePair[] getParameters()(Code) | | Get the all the parameters in the order in which they were added.
array of all name value pairs. |
setParameter | public void setParameter(String name, String value)(Code) | | 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. Parameters: value - a String specifying the value of the single parameter, or null to remove. since: ostermillerutils 1.02.15 |
setParameter | public void setParameter(String name, String[] values)(Code) | | 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. Parameters: values - a String array specifying the values for the parameter, or null to remove. throws: NullPointerException - if any of the values is null. since: ostermillerutils 1.02.15 |
toString | public String toString()(Code) | | Returns the name value pairs properly escaped and written in URL format
with UTF-8 URL encoding.
URLEncoded name value pairs. since: ostermillerutils 1.03.00 |
|
|