public abstract class AbstractXMLStreamReader<T> extends Object implements XMLStreamReader
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT| Constructor and Description |
|---|
AbstractXMLStreamReader(T rootInfo)
Create new reader instance.
|
AbstractXMLStreamReader(T rootInfo,
Location locationProvider)
Create new reader instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected abstract boolean |
consume()
Main method to be implemented by subclasses.
|
int |
getAttributeCount() |
String |
getAttributeLocalName(int index) |
QName |
getAttributeName(int index) |
String |
getAttributeNamespace(int index) |
String |
getAttributePrefix(int index) |
String |
getAttributeType(int index) |
String |
getAttributeValue(int index) |
String |
getAttributeValue(String namespaceURI,
String localName) |
String |
getCharacterEncodingScheme() |
String |
getElementText() |
String |
getEncoding() |
protected Object |
getEventData() |
protected String |
getEventName() |
int |
getEventType() |
String |
getLocalName() |
Location |
getLocation() |
QName |
getName() |
NamespaceContext |
getNamespaceContext() |
int |
getNamespaceCount() |
String |
getNamespacePrefix(int index) |
String |
getNamespaceURI() |
String |
getNamespaceURI(int index) |
String |
getNamespaceURI(String prefix) |
String |
getPIData() |
String |
getPITarget() |
String |
getPrefix() |
Object |
getProperty(String name) |
protected XMLStreamReaderScope<T> |
getScope() |
String |
getText() |
char[] |
getTextCharacters() |
int |
getTextCharacters(int sourceStart,
char[] target,
int targetStart,
int length) |
int |
getTextLength() |
int |
getTextStart() |
String |
getVersion() |
boolean |
hasName() |
boolean |
hasNext() |
boolean |
hasText() |
protected void |
initialize()
Consume initial event.
|
boolean |
isAttributeSpecified(int index) |
boolean |
isCharacters() |
boolean |
isEndElement() |
boolean |
isStandalone() |
protected boolean |
isStartDocumentRead() |
boolean |
isStartElement() |
boolean |
isWhiteSpace() |
int |
next() |
int |
nextTag() |
protected void |
readAttr(String prefix,
String localName,
String namespaceURI,
String value)
Read attribute.
|
protected void |
readData(String text,
Object data,
int type)
Read characters/comment/dtd/entity data.
|
protected void |
readEndDocument()
Read end document.
|
protected void |
readEndElementTag()
Read end element.
|
protected void |
readNsDecl(String prefix,
String namespaceURI)
Read namespace declaration.
|
protected void |
readPI(String target,
String data)
Read processing instruction.
|
protected void |
readStartDocument(String version,
String encodingScheme,
Boolean standalone)
Read start document
|
protected void |
readStartElementTag(String prefix,
String localName,
String namespaceURI,
T scopeInfo)
Read start element.
|
void |
require(int eventType,
String namespaceURI,
String localName) |
boolean |
standaloneSet() |
String |
toString() |
public AbstractXMLStreamReader(T rootInfo)
rootInfo - root scope informationprotected XMLStreamReaderScope<T> getScope()
protected boolean isStartDocumentRead()
true if START_DOCUMENT event has been readprotected void initialize()
throws XMLStreamException
XMLStreamExceptionprotected abstract boolean consume()
throws XMLStreamException,
IOException
readXXX() methods.
When encountering an element start event, all attributes and namespace delarations
must be consumed too, otherwise these won't be available during start element.true if there's more to readXMLStreamExceptionIOExceptionprotected void readStartDocument(String version, String encodingScheme, Boolean standalone) throws XMLStreamException
version - XML versionencodingScheme - encoding scheme (may be null)standalone - standalone flag (may be null)XMLStreamExceptionprotected void readStartElementTag(String prefix, String localName, String namespaceURI, T scopeInfo) throws XMLStreamException
scopeInfo is
stored in the new scope and will be available via getScope().getInfo().prefix - element prefix (use null if unknown)localName - local namenamespaceURI - (use null if unknown)scopeInfo - new scope infoXMLStreamExceptionprotected void readAttr(String prefix, String localName, String namespaceURI, String value) throws XMLStreamException
prefix - attribute prefix (use null if unknown)localName - local namenamespaceURI - (use null if unknown)value - attribute valueXMLStreamExceptionprotected void readNsDecl(String prefix, String namespaceURI) throws XMLStreamException
prefix - namespace prefix (must not be null)namespaceURI - namespace URI (must not be null)XMLStreamExceptionprotected void readData(String text, Object data, int type) throws XMLStreamException
text - textdata - additional data exposed by getEventData() (e.g. type conversion)type - one of CHARACTERS, COMMENT, CDATA, DTD, ENTITY_REFERENCE, SPACEXMLStreamExceptionprotected void readPI(String target, String data) throws XMLStreamException
target - PI targetdata - PI data (may be null)XMLStreamExceptionprotected void readEndElementTag()
throws XMLStreamException
XMLStreamExceptionprotected void readEndDocument()
throws XMLStreamException
XMLStreamExceptionpublic void require(int eventType,
String namespaceURI,
String localName)
throws XMLStreamException
require in interface XMLStreamReaderXMLStreamExceptionpublic String getElementText() throws XMLStreamException
getElementText in interface XMLStreamReaderXMLStreamExceptionpublic boolean hasNext()
throws XMLStreamException
hasNext in interface XMLStreamReaderXMLStreamExceptionpublic int next()
throws XMLStreamException
next in interface XMLStreamReaderXMLStreamExceptionpublic int nextTag()
throws XMLStreamException
nextTag in interface XMLStreamReaderXMLStreamExceptionpublic void close()
throws XMLStreamException
close in interface XMLStreamReaderXMLStreamExceptionpublic boolean isStartElement()
isStartElement in interface XMLStreamReaderpublic boolean isEndElement()
isEndElement in interface XMLStreamReaderpublic boolean isCharacters()
isCharacters in interface XMLStreamReaderpublic boolean isWhiteSpace()
isWhiteSpace in interface XMLStreamReaderpublic int getAttributeCount()
getAttributeCount in interface XMLStreamReaderpublic QName getAttributeName(int index)
getAttributeName in interface XMLStreamReaderpublic String getAttributeLocalName(int index)
getAttributeLocalName in interface XMLStreamReaderpublic String getAttributeValue(int index)
getAttributeValue in interface XMLStreamReaderpublic String getAttributePrefix(int index)
getAttributePrefix in interface XMLStreamReaderpublic String getAttributeNamespace(int index)
getAttributeNamespace in interface XMLStreamReaderpublic String getAttributeType(int index)
getAttributeType in interface XMLStreamReaderpublic boolean isAttributeSpecified(int index)
isAttributeSpecified in interface XMLStreamReaderpublic String getAttributeValue(String namespaceURI, String localName)
getAttributeValue in interface XMLStreamReaderpublic String getNamespaceURI(String prefix)
getNamespaceURI in interface XMLStreamReaderpublic int getNamespaceCount()
getNamespaceCount in interface XMLStreamReaderpublic String getNamespacePrefix(int index)
getNamespacePrefix in interface XMLStreamReaderpublic String getNamespaceURI(int index)
getNamespaceURI in interface XMLStreamReaderpublic NamespaceContext getNamespaceContext()
getNamespaceContext in interface XMLStreamReaderpublic int getEventType()
getEventType in interface XMLStreamReaderprotected String getEventName()
protected final Object getEventData()
public Location getLocation()
getLocation in interface XMLStreamReaderpublic boolean hasText()
hasText in interface XMLStreamReaderpublic String getText()
getText in interface XMLStreamReaderpublic char[] getTextCharacters()
getTextCharacters in interface XMLStreamReaderpublic int getTextCharacters(int sourceStart,
char[] target,
int targetStart,
int length)
throws XMLStreamException
getTextCharacters in interface XMLStreamReaderXMLStreamExceptionpublic int getTextStart()
getTextStart in interface XMLStreamReaderpublic int getTextLength()
getTextLength in interface XMLStreamReaderpublic boolean hasName()
hasName in interface XMLStreamReaderpublic QName getName()
getName in interface XMLStreamReaderpublic String getLocalName()
getLocalName in interface XMLStreamReaderpublic String getNamespaceURI()
getNamespaceURI in interface XMLStreamReaderpublic String getPrefix()
getPrefix in interface XMLStreamReaderpublic String getVersion()
getVersion in interface XMLStreamReaderpublic String getEncoding()
getEncoding in interface XMLStreamReaderpublic boolean isStandalone()
isStandalone in interface XMLStreamReaderpublic boolean standaloneSet()
standaloneSet in interface XMLStreamReaderpublic String getCharacterEncodingScheme()
getCharacterEncodingScheme in interface XMLStreamReaderpublic String getPITarget()
getPITarget in interface XMLStreamReaderpublic String getPIData()
getPIData in interface XMLStreamReaderpublic Object getProperty(String name) throws IllegalArgumentException
getProperty in interface XMLStreamReaderIllegalArgumentExceptionCopyright © 2005–2019 Apache Software Foundation. All rights reserved.