|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.japaki.text.AbstractParser<B>
net.sf.japaki.text.LeafParser<B>
public class LeafParser<B>
A parser based on a Format
.
Constructor Summary | |
---|---|
protected |
LeafParser(Format format,
Property<B,?> property,
String errorMessage,
String name)
Creates a new leaf parser from the specified parameters. |
Method Summary | ||
---|---|---|
static Parser<Object> |
newConstantParser(String value)
Creates a parser that always returns a predefined value. |
|
static
|
newMessageParser(List<Property<? super B,?>> properties,
String pattern,
String name)
Creates a parser based on a MessageFormat . |
|
static
|
newParser(Format format,
Property<B,?> property,
String errorMessage,
String name)
Creates a new leaf parser from the specified parameters. |
|
static
|
newStringParser(Property<B,String> property,
String delimiter,
String name)
Creates a new delimiter based parser. |
|
protected void |
parseIt(ParseReader in,
B target)
Parses text starting at the specified position. |
|
String |
treeView()
Returns a tree view of this parser. |
|
protected void |
writeIt(ParseWriter out,
B source)
Formats the source object and writes it into the output stream |
Methods inherited from class net.sf.japaki.text.AbstractParser |
---|
getLogger, handleException, parse, toString, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected LeafParser(Format format, Property<B,?> property, String errorMessage, String name)
format
- base formatproperty
- the rule how to retrieve and store the value for
parsing and formatting, respectively.errorMessage
- message set in the exception if parsing failsname
- name of this parser for logging purposes
NullPointerException
- if any parameter is null
Method Detail |
---|
public static <B> Parser<B> newParser(Format format, Property<B,?> property, String errorMessage, String name)
format
- base formatproperty
- the rule how to retrieve and store the value for
parsing and formatting, respectively.errorMessage
- message set in the exception if parsing failsname
- name of this parser for logging purposes
NullPointerException
- if any parameter is null
public static Parser<Object> newConstantParser(String value)
value
- constant to be used
NullPointerException
- if value
is null
public static <B> Parser<B> newStringParser(Property<B,String> property, String delimiter, String name)
property
- the rule how to retrieve and store the value for
parsing and formatting, respectively.delimiter
- the string where parsing stopsname
- name of this parser for logging purposes
NullPointerException
- if any parameter is null
public static <B> Parser<B> newMessageParser(List<Property<? super B,?>> properties, String pattern, String name)
MessageFormat
.
properties
- the rules how to retrieve and store the values for
parsing and formatting, respectively.pattern
- the pattern of the message formatname
- name of this parser for logging purposes
IllegalArgumentException
- if the pattern is invalid
NullPointerException
- if properties
or name
is
null
protected void parseIt(ParseReader in, B target) throws IOException, ParseException
AbstractParser
parseIt
in class AbstractParser<B>
in
- the position where to start parsingtarget
- place where the parsed object is stored.
NullPointerException
- if in
or target
is null
BeanStoreException
- if the parsed value could not be stored
IOException
- if an I/O error occurs
ParseException
- if the beginning of the string in in
cannot be parsedprotected void writeIt(ParseWriter out, B source) throws IOException, FormatException
AbstractParser
writeIt
in class AbstractParser<B>
out
- the stream and position where to put the formatted text.source
- source object
NullPointerException
- if out
is null
IOException
- if an I/O error occurs
FormatException
- if the source object can not be formatted with
this parser.public String treeView()
Parser
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |