|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.io.xpp3.AbstractXpp3Reader<O>
O - the type of object to be build by the readerpublic abstract class AbstractXpp3Reader<O>
An abstract xpp3Reader based on PropertyMapper to set properties of
the objects to build.
initMappers() to
see authorized mapping from tag to pojo properties.
The logic of setting properties from xml (tag and attributes) is done in
read(String, Class, org.codehaus.plexus.util.xml.pull.XmlPullParser, boolean) readArray(String, String, Class, org.codehaus.plexus.util.xml.pull.XmlPullParser, boolean)
PropertyMapper,
Xpp3Reader| Field Summary | |
|---|---|
protected boolean |
addDefaultEntities
If set the parser will be loaded with all single characters from the XHTML specification. |
protected Map<String,PropertyMapper> |
allMappers
the univers of mappers availables, initialized in initMappers(). |
protected String |
arrayRootTagName
the root tag of an array of objets to retreave from xml streams. |
protected String |
rootTagName
the root tag of an object to retreave from xml streams. |
protected Class<O> |
type
the type of the object to produce from the xml streams. |
| Constructor Summary | |
|---|---|
protected |
AbstractXpp3Reader(Class<O> type,
String rootTagName)
|
protected |
AbstractXpp3Reader(Class<O> type,
String arrayRootTagName,
String rootTagName)
|
| Method Summary | ||
|---|---|---|
protected void |
checkEndOfXml(org.codehaus.plexus.util.xml.pull.XmlPullParser parser)
Checks that a given parser is at the end of the xml document. |
|
protected void |
checkNotEndOfXml(org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
String tagName)
Checks that a given parser is not at the end of the xml document. |
|
String |
getArrayRootTagName()
|
|
Map<String,PropertyMapper> |
getMappers(Class<?> srcType)
Obtain all mappers for a given type. |
|
String |
getRootTagName()
|
|
Class<O> |
getType()
|
|
protected int |
gotoNextOpenTag(String tagName,
org.codehaus.plexus.util.xml.pull.XmlPullParser parser)
|
|
protected abstract void |
initMappers()
|
|
boolean |
isAddDefaultEntities()
|
|
O |
read(Reader reader)
Read a single instance of the typed object and return it. |
|
O |
read(Reader reader,
boolean strict)
Read a single instance of the typed object and return it. |
|
protected
|
read(String rootTagName,
Class<T> type,
org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
boolean strict)
Parse the xml stream from the given parser and a build the associated object. |
|
O[] |
readArray(Reader reader)
Read some instances of the typed object and return it. |
|
O[] |
readArray(Reader reader,
boolean strict)
Read some instances of the typed object and return it. |
|
protected
|
readArray(String parentRootTagName,
String rootTagName,
Class<T> type,
org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
boolean strict)
Parse the xml stream from the given parser and a build an array of associated object. |
|
void |
setAddDefaultEntities(boolean addDefaultEntities)
Set the new value of the defaultEntities flag. |
|
void |
setParentRootTagName(String parentRootTagName)
Set the name of the root tag for an array of object to read. |
|
void |
setRootTagName(String rootTagName)
Set the name of the root tag of an object to read. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean addDefaultEntities
protected final Class<O> type
protected String rootTagName
protected String arrayRootTagName
protected Map<String,PropertyMapper> allMappers
initMappers().
Each mapper of the dictionary is associated to the fully qualified name
of the target class # the tag name or attribute name.
Example :
org.nuiton.util.MyPojo#my-tag org.nuiton.util.MyPojo#my-attribute
| Constructor Detail |
|---|
protected AbstractXpp3Reader(Class<O> type,
String rootTagName)
protected AbstractXpp3Reader(Class<O> type,
String arrayRootTagName,
String rootTagName)
| Method Detail |
|---|
protected abstract void initMappers()
throws IntrospectionException
IntrospectionExceptionpublic Class<O> getType()
getType in interface Xpp3Reader<O>public String getRootTagName()
getRootTagName in interface Xpp3Reader<O>public void setRootTagName(String rootTagName)
Xpp3Reader
setRootTagName in interface Xpp3Reader<O>rootTagName - the name of the tagpublic String getArrayRootTagName()
getArrayRootTagName in interface Xpp3Reader<O>public void setParentRootTagName(String parentRootTagName)
Xpp3Reader
setParentRootTagName in interface Xpp3Reader<O>parentRootTagName - the name of the tagpublic boolean isAddDefaultEntities()
isAddDefaultEntities in interface Xpp3Reader<O>true if parser will load the default entities,
false otherwise.public void setAddDefaultEntities(boolean addDefaultEntities)
Xpp3ReaderdefaultEntities flag.
setAddDefaultEntities in interface Xpp3Reader<O>addDefaultEntities - the new value.
public O read(Reader reader)
throws IOException,
org.codehaus.plexus.util.xml.pull.XmlPullParserException
Xpp3ReaderXpp3Reader.read(java.io.Reader, boolean) in strict mode.
In the xml stream, the root tag must be the Xpp3Reader.getRootTagName().
Example :
<issue>:
...
</issue>:
read in interface Xpp3Reader<O>reader - the xml input reader
IOException - if any io pb
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if parsing error
public O read(Reader reader,
boolean strict)
throws IOException,
org.codehaus.plexus.util.xml.pull.XmlPullParserException
Xpp3ReaderXpp3Reader.getRootTagName().
Example :
<issue>:
...
</issue>:
read in interface Xpp3Reader<O>reader - the xml input readerstrict - flag to be strict while parsing
IOException - if any io pb
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if any parsing pb
public O[] readArray(Reader reader)
throws IOException,
org.codehaus.plexus.util.xml.pull.XmlPullParserException
Xpp3ReaderXpp3Reader.getArrayRootTagName().
Note : this is a convinient method to call :
Xpp3Reader.readArray(java.io.Reader, boolean) in stritc mode.
Example :
<issues>:
<issue>:
...
</issue>:
</issues>:
readArray in interface Xpp3Reader<O>reader - the xml input reader
IOException - if any io pb
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if any parsing pb
public O[] readArray(Reader reader,
boolean strict)
throws IOException,
org.codehaus.plexus.util.xml.pull.XmlPullParserException
Xpp3ReaderXpp3Reader.getArrayRootTagName().
Example :
<issues>:
<issue>:
...
</issue>:
</issues>:
readArray in interface Xpp3Reader<O>reader - the xml input readerstrict - flag to be strict while parsing
IOException - if any io pb
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if any parsing pbpublic Map<String,PropertyMapper> getMappers(Class<?> srcType)
my-tag my-attribute
srcType - the target type of the searched mappers
protected <T> T read(String rootTagName,
Class<T> type,
org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
boolean strict)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
IOException
getRootTagName()
Example :
... <my-pojo> <my-property>myValue</my-property> </my-pojo>
T - the type of object to buildrootTagName - the name of the root tag matching the object to buildtype - the type of object to buildparser - the xpp3 parserstrict - flag to indicate if should fail if a unknown tag (or attribute ?) is scanned
IOException - if any io pb
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if any parsing pb
protected <T> T[] readArray(String parentRootTagName,
String rootTagName,
Class<T> type,
org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
boolean strict)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
IOException
parentRootTagName and sub nodes with names rootTagName.
Example :
...
<my-pojos>
<my-pojo>
<my-property>myValue</my-property>
</my-pojo>
<my-pojo>
<my-property>myValue2</my-property>
</my-pojo>
</my-pojos>
T - the type of objects to buildparentRootTagName - the tag's name of the array containerrootTagName - the tag's name of each object to buildtype - the type of objects to buildparser - the xpp3 parserstrict - flag to indicate if should fail if a unknown tag (or attribute ?) is scanned
IOException - if any io pb
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if any parsing pb
protected int gotoNextOpenTag(String tagName,
org.codehaus.plexus.util.xml.pull.XmlPullParser parser)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserException
IOException
protected void checkNotEndOfXml(org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
String tagName)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
parser - the parser to checktagName - the endign tag's name
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if the parser is at the end of the xml stream, instead of the tagName ending tag
protected void checkEndOfXml(org.codehaus.plexus.util.xml.pull.XmlPullParser parser)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
parser - the parser to check
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if the parser is not at the end of the xml stream.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||