org.objectweb.dsrg.sofa.deployment.zeroconf
Class ListParser<T>

java.lang.Object
  extended by org.objectweb.dsrg.sofa.deployment.zeroconf.ListParser<T>
All Implemented Interfaces:
ValueParser<java.util.List<T>>

public class ListParser<T>
extends java.lang.Object
implements ValueParser<java.util.List<T>>

ValueParser that parses a string into an array of strings and applies another ValueParser on each string.

Format of the input string
The input string is a white-space delimited list of strings.
If you need to input white-space inside the string, you can

Text enclosed within parentheses is called a group. If you need to insert right parenthesis (')') inside a group, precede it with a backslash - '\)'. If you need to insert left parenthesis ('(') outside any group, precede it with a backslash - '\('.
If you need to insert backslash, use a double backslash - '\\'.

Example:
aaa bb\ bb ( c c ) dd)\(dd (e( \)e)
is a list of five strings: "aaa", "bb bb", " c c ", "dd)(dd", "e( )e".

Note that if the values for this ValueParser are to be specified in a configuration file, after applying these encoding rules you need to do any escaping of special characters required by Properties, see Properties.load(java.io.Reader).


Field Summary
static java.lang.String DELIMITERS
          String containing all delimiter characters.
static char ESC_CHAR
          Escape character.
static char GRP_END
          End-of-the-group character.
static char GRP_START
          Start-of-the-group character.
 
Constructor Summary
ListParser(ValueParser<T> itemParser)
           
 
Method Summary
 java.util.List<T> parse(java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELIMITERS

public static final java.lang.String DELIMITERS
String containing all delimiter characters.

See Also:
Constant Field Values

ESC_CHAR

public static final char ESC_CHAR
Escape character.

See Also:
Constant Field Values

GRP_START

public static final char GRP_START
Start-of-the-group character.

See Also:
Constant Field Values

GRP_END

public static final char GRP_END
End-of-the-group character.

See Also:
Constant Field Values
Constructor Detail

ListParser

public ListParser(ValueParser<T> itemParser)
Method Detail

parse

public java.util.List<T> parse(java.lang.String str)
                        throws ParseException
Specified by:
parse in interface ValueParser<java.util.List<T>>
Parameters:
str - String to be parsed.
Returns:
parsed object.
Throws:
ParseException - if s is malformed.