de.matthiasmann.twl.utils
Class ParameterStringParser

java.lang.Object
  extended by de.matthiasmann.twl.utils.ParameterStringParser

public class ParameterStringParser
extends java.lang.Object

A utility class to parse parameter lists in string form like the query part of an Url or CSS styles.


Constructor Summary
ParameterStringParser(java.lang.String str, char parameterSeparator, char keyValueSeparator)
          Creates a new parser object.
 
Method Summary
 java.lang.String getKey()
          Returns the current key
 java.lang.String getValue()
          Returns the current value
 boolean isTrim()
           
 boolean next()
          Extract the next key-value pair
 void setTrim(boolean trim)
          Enables trimming of white spaces on key and values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterStringParser

public ParameterStringParser(java.lang.String str,
                             char parameterSeparator,
                             char keyValueSeparator)
Creates a new parser object.

Parameters:
str - the String to parse
parameterSeparator - the character which separates key-value pairs from each other
keyValueSeparator - the character which separates key and value from each other
Method Detail

isTrim

public boolean isTrim()

setTrim

public void setTrim(boolean trim)
Enables trimming of white spaces on key and values

Parameters:
trim - true if white spaces should be trimmed
See Also:
Character.isWhitespace(char)

next

public boolean next()
Extract the next key-value pair

Returns:
true if a pair was extracted false if the end of the string was reached.

getKey

public java.lang.String getKey()
Returns the current key

Returns:
the current key
See Also:
next()

getValue

public java.lang.String getValue()
Returns the current value

Returns:
the current value
See Also:
next()