Package org.javarosa.xml
Class ElementParser<T>
java.lang.Object
org.javarosa.xml.ElementParser<T>
- Direct Known Subclasses:
TreeElementParser
public abstract class ElementParser<T> extends Object
Element Parser is the core parsing element for XML files. Implementations can be made for data types, encapsulating all of the parsing rules for that type's XML definition.
An Element parser should have a defined scope of a single tag and its descendants in the document. The ElementParser should receive the parser pointing to that opening tag, and return it on the closing tag
A number of helper methods are provided in the parser which are intended to standardize the techniques used for validation and pull-parsing through the XML Document.
- Author:
- ctsims
-
Field Summary
Fields Modifier and Type Field Description protected org.kxml2.io.KXmlParserparser -
Method Summary
Modifier and Type Method Description static org.kxml2.io.KXmlParserinstantiateParser(InputStream stream)Prepares a parser that will be used by the element parser, configuring relevant parameters and setting it to the appropriate point in the document.abstract Tparse()Parses the XML document at the current level, returning the datatype described by the document.
-
Field Details
-
parser
protected final org.kxml2.io.KXmlParser parser
-
-
Method Details
-
instantiateParser
Prepares a parser that will be used by the element parser, configuring relevant parameters and setting it to the appropriate point in the document.- Parameters:
stream- A stream which is reading the XML content of the document.- Throws:
IOException- If the stream cannot be read for any reason other than invalid XML Structures.
-
parse
public abstract T parse() throws InvalidStructureException, IOException, org.xmlpull.v1.XmlPullParserException, UnfullfilledRequirementsExceptionParses the XML document at the current level, returning the datatype described by the document.- Returns:
- The datatype which is described by the appropriate XML definition.
- Throws:
InvalidStructureException- If the XML does not contain properly structured XMLIOException- If there is a problem retrieving the documentorg.xmlpull.v1.XmlPullParserException- If the document does not contain well- formed XML.UnfullfilledRequirementsException
-