org.jwall.web.audit.util
Class ParserUtils

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

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

Constructor Detail

ParserUtils

public ParserUtils()
Method Detail

splitQuotedString

public static String[] splitQuotedString(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 String[] splitQuotedString(String input,
                                         String pattern)

splitQuotedString

public static String[] splitQuotedString(String input,
                                         String quoteChar,
                                         String pattern)
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 Hashtable<String,String> parseQueryString(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 String extractFormData(String contentType,
                                     String content)
                              throws 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:
Exception

normalizePath

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

Parameters:
path - The path that is to be normalized.
Returns:
The normalized path.


Copyright © 2012 jwall.org. All Rights Reserved.