org.nuiton.io.xpp3
Interface Xpp3Reader<O>

Type Parameters:
O - the type of object to be build by the reader.
All Known Implementing Classes:
AbstractXpp3Reader

public interface Xpp3Reader<O>

A simple contract to mark all xpp readers.

a such reader is associated to a getType().

The implementations of such readers must be register in a file

 META-INF/services.org.nuiton.io.xpp3.Xpp3Reader
 

to make possible auto-discovering of availables reader at runtime.

See Xpp3Helper.getReader(Class) and Xpp3Helper.getReaders().

Since:
1.0.3
Author:
tchemit

Method Summary
 String getArrayRootTagName()
           
 String getRootTagName()
           
 Class<O> getType()
           
 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.
 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.
 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.
 

Method Detail

getType

Class<O> getType()
Returns:
the type of main object to read

read

O read(Reader reader)
       throws IOException,
              org.codehaus.plexus.util.xml.pull.XmlPullParserException
Read a single instance of the typed object and return it.

Note : this is a convinient method to call read(Reader, boolean) in strict mode.

In the xml stream, the root tag must be the getRootTagName().

Example :

 <issue>:
    ...
 </issue>:
 

Parameters:
reader - the xml input reader
Returns:
Settings
Throws:
IOException - if any io pb
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if parsing error

read

O read(Reader reader,
       boolean strict)
       throws IOException,
              org.codehaus.plexus.util.xml.pull.XmlPullParserException
Read a single instance of the typed object and return it.

In the xml stream, the root tag must be the getRootTagName().

Example :

 <issue>:
    ...
 </issue>:
 

Parameters:
reader - the xml input reader
strict - flag to be strict while parsing
Returns:
the read object
Throws:
IOException - if any io pb
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if any parsing pb

readArray

O[] readArray(Reader reader)
              throws IOException,
                     org.codehaus.plexus.util.xml.pull.XmlPullParserException
Read some instances of the typed object and return it.

In the xml stream, the root tag must be the getArrayRootTagName().

Note : this is a convinient method to call : readArray(Reader, boolean) in stritc mode.

Example :

 <issues>:
   <issue>:
    ...
   </issue>:
 </issues>:
 

Parameters:
reader - the xml input reader
Returns:
the array of read objects.
Throws:
IOException - if any io pb
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if any parsing pb

readArray

O[] readArray(Reader reader,
              boolean strict)
              throws IOException,
                     org.codehaus.plexus.util.xml.pull.XmlPullParserException
Read some instances of the typed object and return it.

In the xml stream, the root tag must be the getArrayRootTagName().

Example :

 <issues>:
   <issue>:
    ...
   </issue>:
 </issues>:
 

Parameters:
reader - the xml input reader
strict - flag to be strict while parsing
Returns:
the array of read objects.
Throws:
IOException - if any io pb
org.codehaus.plexus.util.xml.pull.XmlPullParserException - if any parsing pb

getRootTagName

String getRootTagName()
Returns:
the name of the root tag of a object to read

setRootTagName

void setRootTagName(String rootTagName)
Set the name of the root tag of an object to read.

Parameters:
rootTagName - the name of the tag

getArrayRootTagName

String getArrayRootTagName()
Returns:
the name of the root tag of an array of objets to read

setParentRootTagName

void setParentRootTagName(String parentRootTagName)
Set the name of the root tag for an array of object to read.

Parameters:
parentRootTagName - the name of the tag

isAddDefaultEntities

boolean isAddDefaultEntities()
Returns:
true if parser will load the default entities, false otherwise.

setAddDefaultEntities

void setAddDefaultEntities(boolean addDefaultEntities)
Set the new value of the defaultEntities flag.

Parameters:
addDefaultEntities - the new value.


Copyright © 2009-2010 CodeLutin. All Rights Reserved.