|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.japaki.text.AbstractParser<T>
net.sf.japaki.text.ChoiceParser<T>
public class ChoiceParser<T>
A choice parser selects the right parser out of a list of underlying parser depending on the input text for parsing or based on the source object for formatting.
| Constructor Summary | |
|---|---|
protected |
ChoiceParser(List<Parser<? super T>> parsers)
Creates a new choice parser based on the specified parsers. |
| Method Summary | ||
|---|---|---|
static
|
newParser(List<Parser<? super T>> parsers)
Creates a new choice parser based on the specified parsers. |
|
protected void |
parseIt(ParseReader in,
T target)
Tries to parse the input text with one of the base parsers. |
|
String |
treeView()
Returns a tree view of this parser. |
|
protected void |
writeIt(ParseWriter out,
T source)
Tries to parse the source object with one of the base parsers. |
|
| 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 ChoiceParser(List<Parser<? super T>> parsers)
parsers - base parsers
NullPointerException - if parsers or one of its elements
is null| Method Detail |
|---|
public static <T> Parser<T> newParser(List<Parser<? super T>> parsers)
parsers - base parsers
NullPointerException - if parsers is null
protected void parseIt(ParseReader in,
T target)
throws IOException,
ParseException
parseIt in class AbstractParser<T>in - the position where to start parsingtarget - place where the parsed object is stored.
NullPointerException - if in or target
or one of its (sub-) properties is null
and the parser cannot handle it
ParseException - if no parser matches.
IOException - if an I/O error occurs
protected void writeIt(ParseWriter out,
T source)
throws IOException,
FormatException
writeIt in class AbstractParser<T>out - the stream and position where to put the formatted text.source - source object
FormatException - if no parser matches.
The cause is a MultiCauseException containg the fail reason
of each option parser.
NullPointerException - if out is null
IOException - if an I/O error occurspublic String treeView()
Parser
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||