|
|||||||||
| 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.OptionalParser<T>
public class OptionalParser<T>
Wrapper around a parser to make it optional.
| Constructor Summary | |
|---|---|
protected |
OptionalParser(Parser<T> parser)
Creates a new optional parser based on the specified parser. |
| Method Summary | ||
|---|---|---|
static
|
newParser(Parser<T> parser)
Creates a new optional parser based on the specified parser. |
|
static
|
newParser(Parser<T> parser,
Factory<? extends T> factory)
Creates a new optional parser based on a peek parser with the specified parser. |
|
protected void |
parseIt(ParseReader in,
T target)
Tries to parse the input text with the base parser. |
|
String |
treeView()
Returns a tree view of this parser. |
|
protected void |
writeIt(ParseWriter out,
T source)
Tries to write the source object with the base parser. |
|
| 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 OptionalParser(Parser<T> parser)
parser - base parser
NullPointerException - if parser is null| Method Detail |
|---|
public static <T> Parser<T> newParser(Parser<T> parser)
parser - base parser
NullPointerException - if parser is null
public static <T> Parser<T> newParser(Parser<T> parser,
Factory<? extends T> factory)
parser - base parser
NullPointerException - if parser or factory is
null
protected void parseIt(ParseReader in,
T target)
throws IOException
ParseException
is thrown, nothing happens.
All other exceptions are passed to the caller.
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
BeanStoreException - if the parsed value could not be stored
IOException - if an I/O error occurs
protected void writeIt(ParseWriter out,
T source)
throws IOException
FormatException
is thrown, nothing happens.
All other exceptions are passed to the caller.
writeIt in class AbstractParser<T>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 occurspublic String treeView()
Parser
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||