Class XMLParserImpl
- All Implemented Interfaces:
XMLParser
XMLParser
using Java StAX API.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private int
private final XMLStreamReader
private static final XMLInputFactory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
advance()
private XMLException
private void
expectToken
(int token, String description) boolean
Determines whether at the current parser position there is an XML element opening tag.boolean
hasStartElement
(String tag) Determines whether at the current parser position there is an XML element opening tag with specified tag name.private boolean
hasToken
(int token) private void
Populate parser lookahead state, i.e.(package private) <Type,
Bean>
TypeparseDocument
(Entity<Type, Bean> rootEntity) (package private) void
void
parseEndElement
(String tag) Reads XML element closing tag with specified tag name.<Type,
Bean>
voidparseEntity
(Entity<Type, Bean> entity, Bean bean) Deserializes givenEntity
from XML form.(package private) void
Reads XML element opening tag.void
parseStartElement
(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:XMLParser
Reads 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:
parseText
in interfaceXMLParser
- Returns:
- text content that was read
- Throws:
XMLException
- in case exception occurs during XML deserialization
-
hasStartElement
Description copied from interface:XMLParser
Determines 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:
hasStartElement
in 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:XMLParser
Determines 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:
hasStartElement
in 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:XMLParser
Reads XML element opening tag.Comments and whitespace text preceding the XML tag are skipped.
XMLException
is thrown if at the current position there is no XML element (but, for example, text data or element closing tag).- Specified by:
parseStartElement
in interfaceXMLParser
- Returns:
- XML element tag name
- Throws:
XMLException
- in case exception occurs during XML deserialization
-
parseStartElement
Description copied from interface:XMLParser
Reads XML element opening tag with specified tag name.Comments and whitespace text preceding the XML tag are skipped.
XMLException
is 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:
parseStartElement
in interfaceXMLParser
- Parameters:
tag
- XML element tag name- Throws:
XMLException
- in case exception occurs during XML deserialization
-
expectToken
- Throws:
XMLException
-
parseEndElement
Description copied from interface:XMLParser
Reads XML element closing tag with specified tag name.Comments and whitespace text preceding the XML tag are skipped.
XMLException
is 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:
parseEndElement
in 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:XMLParser
Deserializes givenEntity
from XML form.- Specified by:
parseEntity
in 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
-