org.jwall.web.audit.util
Class ParserUtils

java.lang.Object
  extended by org.jwall.web.audit.util.ParserUtils

public class ParserUtils
extends java.lang.Object

This class provides a set of static methods that are useful for parsing strings, messages et. al. It also encapsulates handling/parsing of mime-messages.

Author:
Christian Bockermann <chris@jwall.org>

Constructor Summary
ParserUtils()
           
 
Method Summary
static java.lang.String extractFormData(java.lang.String contentType, java.lang.String content)
          This method extracts multipart/form-data from a http-request-body.
static java.lang.String normalizePath(java.lang.String path)
          This method does a simple path-normalization.
static java.util.Hashtable<java.lang.String,java.lang.String> parseQueryString(java.lang.String qs)
          Parses the QueryString and returns a hash of (param,value)-pairs.
static java.lang.String[] splitQuotedString(java.lang.String input)
          Splits a string which might contain quoted substrings.
static java.lang.String[] splitQuotedString(java.lang.String input, java.lang.String quoteChar)
          This method splits a possible quoted String into tokens, respecting the quotations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserUtils

public ParserUtils()
Method Detail

splitQuotedString

public static java.lang.String[] splitQuotedString(java.lang.String input)
Splits a string which might contain quoted substrings. This is a simple wrapper around splitQuotedString(input, ").

Parameters:
input - The string to split
Returns:
An array of tokens of type string.

splitQuotedString

public static java.lang.String[] splitQuotedString(java.lang.String input,
                                                   java.lang.String quoteChar)
This method splits a possible quoted String into tokens, respecting the quotations. The returned array of strings does not contain the limiting quotations.

Parameters:
input - A string, possibly containing quotes.
Returns:
An array of strings which are tokens from the splitted input-string.

parseQueryString

public static java.util.Hashtable<java.lang.String,java.lang.String> parseQueryString(java.lang.String qs)
Parses the QueryString and returns a hash of (param,value)-pairs. The parameters-pairs are split using &, parameters and values will be split using =. A possible trailing string starting with # will be ignored.

Parameters:
qs - The query-string that will be parsed.

extractFormData

public static java.lang.String extractFormData(java.lang.String contentType,
                                               java.lang.String content)
                                        throws java.lang.Exception
This method extracts multipart/form-data from a http-request-body.

Parameters:
contentType - The content-type.
content - The content that is to be decoded.
Returns:
A string containing the form-data or an empty string with no request-body is available.
Throws:
java.lang.Exception

normalizePath

public static java.lang.String normalizePath(java.lang.String path)
This method does a simple path-normalization. Currently it simply replaces "//" by "/".

Parameters:
path -
Returns:
The normalized path.