public class CGIParser
extends java.lang.Object
More information about this class is available from ostermiller.org.
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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[] |
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.
|
@Deprecated public CGIParser(java.io.InputStream in) throws java.io.IOException
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.
in
- Stream containing CGI Encoded name value pairs.java.io.IOException
- If an input error occurspublic CGIParser(java.io.InputStream in, java.lang.String charset) throws java.io.IOException, java.io.UnsupportedEncodingException
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.
in
- Stream containing CGI Encoded name value pairs.charset
- Character encoding to use when converting bytes to charactersjava.io.IOException
- If an input error occursjava.io.UnsupportedEncodingException
- If the character set provided is not recognized@Deprecated public CGIParser(java.io.Reader in) throws java.io.IOException
The reader is read until the stream contains no more characters.
in
- Reader containing CGI Encoded name value pairs.java.io.IOException
- If an input error occurspublic CGIParser(java.io.Reader in, java.lang.String charset) throws java.io.IOException, java.io.UnsupportedEncodingException
The reader is read until the stream contains no more characters.
in
- Reader containing CGI Encoded name value pairs.charset
- Character encoding to use when converting bytes to charactersjava.io.IOException
- If an input error occursjava.io.UnsupportedEncodingException
- If the character set provided is not recognized@Deprecated public CGIParser(java.lang.String s)
s
- CGI Encoded name value pairs.public CGIParser(java.lang.String s, java.lang.String charset) throws java.io.UnsupportedEncodingException
s
- CGI Encoded name value pairs.charset
- Character encoding to use when converting bytes to charactersjava.io.UnsupportedEncodingException
- If the character set provided is not recognizedpublic java.lang.String[] getParameterValues(java.lang.String name)
If the parameter has a single value, the array has a length of 1.
name
- a String containing the name of the parameter whose value is requestedpublic void setParameter(java.lang.String name, java.lang.String value)
name
- a String specifying the name of the parameter.value
- a String specifying the value of the single parameter, or null to remove.public void setParameter(java.lang.String name, java.lang.String[] values)
name
- a String specifying the name of the parameter.values
- a String array specifying the values for the parameter, or null to remove.java.lang.NullPointerException
- if any of the values is null.public void addParameter(java.lang.String name, java.lang.String value)
name
- a String specifying the name of the parameter.value
- a String specifying the value of the single parameter, or null to remove.public void addParameter(java.lang.String name, java.lang.String[] values)
name
- a String specifying the name of the parameter.values
- a String array specifying the values of the parameter, or null to remove.java.lang.NullPointerException
- if any of the values is null.public java.lang.String getParameter(java.lang.String name)
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.
name
- a String specifying the name of the parameterpublic java.util.Enumeration<java.lang.String> getParameterNames()
public java.lang.String[] getParameterNameList()
public NameValuePair[] getParameters()
public java.lang.String toString(java.lang.String enc) throws java.io.UnsupportedEncodingException
enc
- Character encoding to use when escaping characters.java.io.UnsupportedEncodingException
- If the named encoding is not supported.public java.lang.String toString()
toString
in class java.lang.Object
Copyright (c) 2001-2020 by Stephen Ostermiller