org.vfny.geoserver.requests.readers
Class KvpRequestReader

java.lang.Object
  extended byorg.vfny.geoserver.requests.readers.KvpRequestReader
Direct Known Subclasses:
CapabilitiesKvpReader, CapabilitiesKvpReader, DeleteKvpReader, DescribeKvpReader, GetFeatureKvpReader, LockKvpReader, WmsKvpRequestReader

public abstract class KvpRequestReader
extends java.lang.Object

Base class for all KVP readers, with some generalized convenience methods.

If you pass this utility a KVP request (everything after the '?' in the GET request URI), it will translate this into a list of key-word value pairs.These pairs represent every element in the KVP GET request, legal or otherwise. This class may then be subclassed and used by request-specific classes. Because there is no error checking for the KVPs in this class, subclasses must check for validity of their KVPs before passing the their requests along, but - in return - this parent class is quite flexible. For example, native KVPs may be easily parsed in its subclasses, since they are simply read and stored (without analysis) in the constructer in this class. Note that all keys are translated to upper case to avoid case conflicts.


Field Summary
protected static java.lang.String INNER_DELIMETER
          Delimeter for inner value lists in the KVPs
protected  java.util.Map kvpPairs
          KVP pair listing; stores all data from the KVP request
protected static java.lang.String OUTER_DELIMETER
          Delimeter for outer value lists in the KVPs
 
Constructor Summary
KvpRequestReader(java.util.Map kvpPairs)
          Constructor with kvp request parameters.
 
Method Summary
abstract  Request getRequest(javax.servlet.http.HttpServletRequest request)
          returns the propper Request subclass for the set of parameters it was setted up and the kind of request it is specialized for
protected static java.util.List getTypesFromFids(java.lang.String rawFidList)
          Attempts to parse out the proper typeNames from the FeatureId filters.
protected  java.lang.String getValue(java.lang.String key)
          returns the value asociated with key on the set of key/value pairs of this request reader
protected  boolean keyExists(java.lang.String key)
          DOCUMENT ME!
static java.util.Map parseKvpSet(java.lang.String qString)
          creates a Map of key/value pairs from a HTTP style query String
protected static java.util.List readFilters(java.lang.String fid, java.lang.String filter, java.lang.String bbox)
          Reads in three strings, representing some sort of feature constraints, and translates them into filters.
protected static java.util.List readFlat(java.lang.String rawList, java.lang.String delimiter)
          Reads a tokenized string and turns it into a list.
protected static java.util.List readNested(java.lang.String rawList)
          Reads a nested tokenized string and turns it into a list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OUTER_DELIMETER

protected static final java.lang.String OUTER_DELIMETER
Delimeter for outer value lists in the KVPs

See Also:
Constant Field Values

INNER_DELIMETER

protected static final java.lang.String INNER_DELIMETER
Delimeter for inner value lists in the KVPs

See Also:
Constant Field Values

kvpPairs

protected java.util.Map kvpPairs
KVP pair listing; stores all data from the KVP request

Constructor Detail

KvpRequestReader

public KvpRequestReader(java.util.Map kvpPairs)
Constructor with kvp request parameters.

Parameters:
kvpPairs - map of key/value pairs
Method Detail

getValue

protected java.lang.String getValue(java.lang.String key)
returns the value asociated with key on the set of key/value pairs of this request reader

Parameters:
key - DOCUMENT ME!
Returns:
DOCUMENT ME!

keyExists

protected boolean keyExists(java.lang.String key)
DOCUMENT ME!

Parameters:
key - DOCUMENT ME!
Returns:
DOCUMENT ME!

getRequest

public abstract Request getRequest(javax.servlet.http.HttpServletRequest request)
                            throws ServiceException
returns the propper Request subclass for the set of parameters it was setted up and the kind of request it is specialized for

Returns:
DOCUMENT ME!
Throws:
ServiceException

getTypesFromFids

protected static java.util.List getTypesFromFids(java.lang.String rawFidList)
                                          throws WfsException
Attempts to parse out the proper typeNames from the FeatureId filters. It simply uses the value before the '.' character.

Parameters:
rawFidList - the strings after the FEATUREID url component. Should be found using kvpPairs.get("FEATUREID") in this class or one of its children
Returns:
A list of typenames, made from the featureId filters.
Throws:
WfsException - If the structure can not be read.

readFlat

protected static java.util.List readFlat(java.lang.String rawList,
                                         java.lang.String delimiter)
Reads a tokenized string and turns it into a list. In this method, the tokenizer is quite flexible. Note that if the list is unspecified (ie. is null) or is unconstrained (ie. is ''), then the method returns an empty list.

Parameters:
rawList - The tokenized string.
delimiter - The delimeter for the string tokens.
Returns:
A list of the tokenized string.

readNested

protected static java.util.List readNested(java.lang.String rawList)
                                    throws WfsException
Reads a nested tokenized string and turns it into a list. This method is much more specific to the KVP get request syntax than the more general readFlat method. In this case, the outer tokenizer '()' and inner tokenizer ',' are both from the specification. Returns a list of lists.

Parameters:
rawList - The tokenized string.
Returns:
A list of lists, containing outer and inner elements.
Throws:
WfsException - When the string structure cannot be read.

readFilters

protected static java.util.List readFilters(java.lang.String fid,
                                            java.lang.String filter,
                                            java.lang.String bbox)
                                     throws WfsException
Reads in three strings, representing some sort of feature constraints, and translates them into filters. If no filters exist, it returns an empty list.

Parameters:
fid - A group of feature IDs, as a String.
filter - A group of filters, as a String.
bbox - A group of boxes, as a String.
Returns:
A list filters.
Throws:
WfsException - When the string structure cannot be read.

parseKvpSet

public static java.util.Map parseKvpSet(java.lang.String qString)
creates a Map of key/value pairs from a HTTP style query String

Parameters:
qString - DOCUMENT ME!
Returns:
DOCUMENT ME!