|
|||||||||
| 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.PropertyParser<B,V>
public class PropertyParser<B,V>
Parses a Property of a generic bean.
A factory can be defined to cover the case if either the property or
its value is null.
The behaviour is as follows:
property property.
getValue()factory parse result write result not nullnot nullnot null⇒ value is used value is used not nullnot nullnull⇒ value is used value is used not nullnullnot null⇒ factory is used to create value FormatException (from base parser) not nullnullnull⇒ NullPointerException FormatException (from base parser) nullN/A not null⇒ factory is used to create value factory is used to create value nullN/A null⇒ prohibited by factory methods
| Constructor Summary | |
|---|---|
protected |
PropertyParser(Parser<? super V> parser,
Property<B,V> property,
Factory<? extends V> factory)
Creates a new property parser based on the specified parameters. |
| Method Summary | ||
|---|---|---|
static
|
newParser(Parser<? super V> parser,
Property<B,V> property,
Factory<? extends V> factory)
Creates a new factory parser based on the specified parameters. |
|
protected void |
parseIt(ParseReader in,
B target)
Parses the next item from the input stream and stores the value in the corresponding property of the target bean. |
|
String |
treeView()
Returns a tree view of this parser. |
|
protected void |
writeIt(ParseWriter out,
B source)
Reads the property value from the specified bean and formats it with the underlying 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 PropertyParser(Parser<? super V> parser,
Property<B,V> property,
Factory<? extends V> factory)
property is null, the factory is used to
create the output value for writing.
parser - base parserproperty - specifies what element to read or write to in the
source or target bean, respectivelyfactory - used to create a new bean if it does not exist yet
NullPointerException - if parser
or both property and factory
are null| Method Detail |
|---|
public static <B,V> Parser<B> newParser(Parser<? super V> parser,
Property<B,V> property,
Factory<? extends V> factory)
property is null, the factory is used to
create the output value for writing.
parser - base parserproperty - specifies what element to read or write to in the
source or target bean, respectivelyfactory - used to create a new bean if it does not exist yet
NullPointerException - if parser
or both property and factory
are null
protected void parseIt(ParseReader in,
B target)
throws IOException,
ParseException
parseIt in class AbstractParser<B>target - target beanin - the position where to start parsing
NullPointerException - if the underlying factory and the
property's value are both 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 parsed
protected void writeIt(ParseWriter out,
B source)
throws IOException,
FormatException
null,
the factory is used to create a value.
writeIt in class AbstractParser<B>source - source beanout - the stream and position where to put the formatted text.
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 | ||||||||