Class XMLParserImpl
- All Implemented Interfaces:
XMLParser
XMLParser using Java StAX API.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate intprivate final XMLStreamReaderprivate static final XMLInputFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadvance()private XMLExceptionprivate voidexpectToken(int token, String description) booleanDetermines whether at the current parser position there is an XML element opening tag.booleanhasStartElement(String tag) Determines whether at the current parser position there is an XML element opening tag with specified tag name.private booleanhasToken(int token) private voidPopulate parser lookahead state, i.e.(package private) <Type,Bean>
TypeparseDocument(Entity<Type, Bean> rootEntity) (package private) voidvoidparseEndElement(String tag) Reads XML element closing tag with specified tag name.<Type,Bean>
voidparseEntity(Entity<Type, Bean> entity, Bean bean) Deserializes givenEntityfrom XML form.(package private) voidReads XML element opening tag.voidparseStartElement(String tag) Reads XML element opening tag with specified tag name.Reads XML text content.private <Type,Bean, Value>
boolean
-
Field Details
-
XML_INPUT_FACTORY
-
cursor
-
currText
-
currToken
private int currToken
-
-
Constructor Details
-
XMLParserImpl
- Throws:
XMLException
-
-
Method Details
-
error
- Throws:
XMLException
-
lookahead
Populate parser lookahead state, i.e. update currText and currToken to reflect current cursor state. Needs to be called upon cursor initialization and every time the cursor is advanced.- Throws:
XMLStreamException
-
hasToken
- Throws:
XMLException
-
advance
- Throws:
XMLStreamException
-
parseText
Description copied from interface:XMLParserReads XML text content.If there is no XML text content at given parser position, then empty String is returned.
Comments within the text are skipped.
- Specified by:
parseTextin interfaceXMLParser- Returns:
- text content that was read
- Throws:
XMLException- in case exception occurs during XML deserialization
-
hasStartElement
Description copied from interface:XMLParserDetermines whether at the current parser position there is an XML element opening tag.Comments and whitespace text preceding the XML tag are skipped.
- Specified by:
hasStartElementin interfaceXMLParser- Returns:
- true iff at the current parser position there is an XML element
- Throws:
XMLException- in case exception occurs during XML deserialization
-
hasStartElement
Description copied from interface:XMLParserDetermines whether at the current parser position there is an XML element opening tag with specified tag name.Comments and whitespace text preceding the XML tag are skipped.
- Specified by:
hasStartElementin interfaceXMLParser- Parameters:
tag- XML element tag name- Returns:
- true iff at the current parser position there is an XML element with specified tag name
- Throws:
XMLException- in case exception occurs during XML deserialization
-
parseStartElement
Description copied from interface:XMLParserReads XML element opening tag.Comments and whitespace text preceding the XML tag are skipped.
XMLExceptionis thrown if at the current position there is no XML element (but, for example, text data or element closing tag).- Specified by:
parseStartElementin interfaceXMLParser- Returns:
- XML element tag name
- Throws:
XMLException- in case exception occurs during XML deserialization
-
parseStartElement
Description copied from interface:XMLParserReads XML element opening tag with specified tag name.Comments and whitespace text preceding the XML tag are skipped.
XMLExceptionis thrown if at the current position there is no XML element opening tag with specified tag (but, for example, text data, element closing tag or element opening tag with a different tag name).- Specified by:
parseStartElementin interfaceXMLParser- Parameters:
tag- XML element tag name- Throws:
XMLException- in case exception occurs during XML deserialization
-
expectToken
- Throws:
XMLException
-
parseEndElement
Description copied from interface:XMLParserReads XML element closing tag with specified tag name.Comments and whitespace text preceding the XML tag are skipped.
XMLExceptionis thrown if at the current position there is no XML element closing tag with specified tag (but, for example, text data, element opening tag or XML element closing tag with a different tag name).- Specified by:
parseEndElementin interfaceXMLParser- Parameters:
tag- XML element tag name- Throws:
XMLException- in case exception occurs during XML deserialization
-
parseStartDocument
- Throws:
XMLException
-
parseEndDocument
- Throws:
XMLException
-
tryParse
private <Type,Bean, boolean tryParseValue> (Property<Type, Bean, throws XMLExceptionValue> property, Bean bean) - Throws:
XMLException
-
parseEntity
Description copied from interface:XMLParserDeserializes givenEntityfrom XML form.- Specified by:
parseEntityin interfaceXMLParser- Type Parameters:
Type- data type of entityBean- type of bean associated with the entity- Parameters:
entity- the entity type to deserializebean- the entity bean to deserialize data into- Throws:
XMLException- in case exception occurs during XML deserialization
-
parseDocument
- Throws:
XMLException
-