Package com.yahoo.text
Class SimpleMapParser
java.lang.Object
com.yahoo.text.SimpleMapParser
- Direct Known Subclasses:
MapParser
Superclasses of parsers of a map represented textually as
{key1:value1,"anystringkey":value2,'anystringkey2':value3 ...}
.
This parser must be extended to specify how to handle the key/value pairs.
Example: To create a Double map parser:
public static final class DoubleMapParser extends MapParser<Double> { private Map<String, Double> map; ... @Override protected Double handleKeyValue(String key, String value) { map.put(key, Double.parseDouble(value)); } }
Map parsers are NOT multithread safe, but are cheap to construct.
- Author:
- bratseth
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
consumeValue
(String key) protected int
protected int
protected abstract void
handleKeyValue
(String key, String value) void
Parses a map on the form{key1:value1,key2:value2 ...}
string()
Returns the string being parsed along with its current position
-
Constructor Details
-
SimpleMapParser
public SimpleMapParser()
-
-
Method Details
-
parse
Parses a map on the form{key1:value1,key2:value2 ...}
- Parameters:
string
- the textual representation of the map
-
findEndOfKey
protected int findEndOfKey() -
findEndOfValue
protected int findEndOfValue() -
consumeValue
-
string
Returns the string being parsed along with its current position -
handleKeyValue
-