com.novell.sentinel.uri
Class GenericURI.FormQuery

java.lang.Object
  extended by com.novell.sentinel.uri.GenericURI.Query
      extended by com.novell.sentinel.uri.GenericURI.FormQuery
Enclosing class:
GenericURI

public static class GenericURI.FormQuery
extends GenericURI.Query

A class used to parse, store, and output information from the query component of a URI that is interpreted as of the media type "application/x-www-form-urlencoded".


Field Summary
static PercentCodex FORM_QUERY_CODEX
          An encoder that encodes a query item (a name or a value in the "application/x-www-form-urlencoded" format).
 
Fields inherited from class com.novell.sentinel.uri.GenericURI.Query
QUERY_CODEX
 
Constructor Summary
GenericURI.FormQuery()
          Construct an empty instance.
GenericURI.FormQuery(GenericURI.FormQuery src)
          Construct a deep copy of the passed instance.
GenericURI.FormQuery(String queryString)
          Construct an instance based on the passed raw string.
 
Method Summary
protected static String decode(String string)
          Decode a name or value from an encoded, raw string.
protected static CharSequence encode(String string)
          Encode a name or value.
 boolean isEmpty()
          Return true if there is no data associated with this instance.
 Map<String,List<String>> items()
          Return the name/value pairs in this instance.
protected  void parse(String queryString)
           
 void setItem(String key, Collection<String> values)
          Set a query item to the passed value(s).
 void setItem(String key, Iterable<String> values)
          Set a query item to the passed value(s).
 void setItem(String key, String... values)
          Set a query item to the passed value(s).
 String toString()
           
 
Methods inherited from class com.novell.sentinel.uri.GenericURI.Query
getQuery, getRaw, set, setQuery, setRaw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FORM_QUERY_CODEX

public static final PercentCodex FORM_QUERY_CODEX
An encoder that encodes a query item (a name or a value in the "application/x-www-form-urlencoded" format). The reserved characters (those that are percent encoded in a constructed URI string) are: '"', '!', '$', '&', ''', '(', ')', '*', '+', ':', '@', '[', ']'.

Note that this encoder should not be used for query strings that are not in "application/x-www-form-urlencoded" format.

Constructor Detail

GenericURI.FormQuery

public GenericURI.FormQuery()
Construct an empty instance.


GenericURI.FormQuery

public GenericURI.FormQuery(String queryString)
Construct an instance based on the passed raw string. The passed string will be parsed as "application/x-www-form-urlencoded" format.

Parameters:
queryString - The raw string.

GenericURI.FormQuery

public GenericURI.FormQuery(GenericURI.FormQuery src)
Construct a deep copy of the passed instance.

Parameters:
src - The instance to be copied.
Method Detail

isEmpty

public boolean isEmpty()
Description copied from class: GenericURI.Query
Return true if there is no data associated with this instance.

Overrides:
isEmpty in class GenericURI.Query
Returns:
true if the query is empty.

items

public Map<String,List<String>> items()
Return the name/value pairs in this instance. Entries in the returned list may be null, indicating the name appeared in the query string without a value (possibly more than once).

Returns:
A Map of the name/value pairs.

setItem

public void setItem(String key,
                    String... values)
Set a query item to the passed value(s).

Parameters:
key - The name of the query item.
values - The value(s) to set.

setItem

public void setItem(String key,
                    Collection<String> values)
Set a query item to the passed value(s).

Parameters:
key - The name of the query item.
values - The value(s) to set.

setItem

public void setItem(String key,
                    Iterable<String> values)
Set a query item to the passed value(s).

Parameters:
key - The name of the query item.
values - The value(s) to set.

toString

public String toString()
Overrides:
toString in class Object

encode

protected static CharSequence encode(String string)
Encode a name or value. This encodes spaces as '+' and otherwise uses QUERY_CODEX to percent-encode the remainder.

Parameters:
string - The literal string to encode.
Returns:
The encoded string.

decode

protected static String decode(String string)
Decode a name or value from an encoded, raw string. This replaces '+' characters with spaces and then calls PercentCodex.decode(String).

Parameters:
string - The raw string.
Returns:
The literal, decoded string.

parse

protected void parse(String queryString)
Overrides:
parse in class GenericURI.Query