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
XMLStreamException
protected 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 readXMLStreamException
IOException
protected void readStartDocument(String version, String encodingScheme, Boolean standalone) throws XMLStreamException
version
- XML versionencodingScheme
- encoding scheme (may be null
)standalone
- standalone flag (may be null
)XMLStreamException
protected 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 infoXMLStreamException
protected 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 valueXMLStreamException
protected void readNsDecl(String prefix, String namespaceURI) throws XMLStreamException
prefix
- namespace prefix (must not be null
)namespaceURI
- namespace URI (must not be null
)XMLStreamException
protected 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, SPACE
XMLStreamException
protected void readPI(String target, String data) throws XMLStreamException
target
- PI targetdata
- PI data (may be null
)XMLStreamException
protected void readEndElementTag() throws XMLStreamException
XMLStreamException
protected void readEndDocument() throws XMLStreamException
XMLStreamException
public void require(int eventType, String namespaceURI, String localName) throws XMLStreamException
require
in interface XMLStreamReader
XMLStreamException
public String getElementText() throws XMLStreamException
getElementText
in interface XMLStreamReader
XMLStreamException
public boolean hasNext() throws XMLStreamException
hasNext
in interface XMLStreamReader
XMLStreamException
public int next() throws XMLStreamException
next
in interface XMLStreamReader
XMLStreamException
public int nextTag() throws XMLStreamException
nextTag
in interface XMLStreamReader
XMLStreamException
public void close() throws XMLStreamException
close
in interface XMLStreamReader
XMLStreamException
public boolean isStartElement()
isStartElement
in interface XMLStreamReader
public boolean isEndElement()
isEndElement
in interface XMLStreamReader
public boolean isCharacters()
isCharacters
in interface XMLStreamReader
public boolean isWhiteSpace()
isWhiteSpace
in interface XMLStreamReader
public int getAttributeCount()
getAttributeCount
in interface XMLStreamReader
public QName getAttributeName(int index)
getAttributeName
in interface XMLStreamReader
public String getAttributeLocalName(int index)
getAttributeLocalName
in interface XMLStreamReader
public String getAttributeValue(int index)
getAttributeValue
in interface XMLStreamReader
public String getAttributePrefix(int index)
getAttributePrefix
in interface XMLStreamReader
public String getAttributeNamespace(int index)
getAttributeNamespace
in interface XMLStreamReader
public String getAttributeType(int index)
getAttributeType
in interface XMLStreamReader
public boolean isAttributeSpecified(int index)
isAttributeSpecified
in interface XMLStreamReader
public String getAttributeValue(String namespaceURI, String localName)
getAttributeValue
in interface XMLStreamReader
public String getNamespaceURI(String prefix)
getNamespaceURI
in interface XMLStreamReader
public int getNamespaceCount()
getNamespaceCount
in interface XMLStreamReader
public String getNamespacePrefix(int index)
getNamespacePrefix
in interface XMLStreamReader
public String getNamespaceURI(int index)
getNamespaceURI
in interface XMLStreamReader
public NamespaceContext getNamespaceContext()
getNamespaceContext
in interface XMLStreamReader
public int getEventType()
getEventType
in interface XMLStreamReader
protected String getEventName()
protected final Object getEventData()
public Location getLocation()
getLocation
in interface XMLStreamReader
public boolean hasText()
hasText
in interface XMLStreamReader
public String getText()
getText
in interface XMLStreamReader
public char[] getTextCharacters()
getTextCharacters
in interface XMLStreamReader
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException
getTextCharacters
in interface XMLStreamReader
XMLStreamException
public int getTextStart()
getTextStart
in interface XMLStreamReader
public int getTextLength()
getTextLength
in interface XMLStreamReader
public boolean hasName()
hasName
in interface XMLStreamReader
public QName getName()
getName
in interface XMLStreamReader
public String getLocalName()
getLocalName
in interface XMLStreamReader
public String getNamespaceURI()
getNamespaceURI
in interface XMLStreamReader
public String getPrefix()
getPrefix
in interface XMLStreamReader
public String getVersion()
getVersion
in interface XMLStreamReader
public String getEncoding()
getEncoding
in interface XMLStreamReader
public boolean isStandalone()
isStandalone
in interface XMLStreamReader
public boolean standaloneSet()
standaloneSet
in interface XMLStreamReader
public String getCharacterEncodingScheme()
getCharacterEncodingScheme
in interface XMLStreamReader
public String getPITarget()
getPITarget
in interface XMLStreamReader
public String getPIData()
getPIData
in interface XMLStreamReader
public Object getProperty(String name) throws IllegalArgumentException
getProperty
in interface XMLStreamReader
IllegalArgumentException
Copyright © 2005–2017 Apache Software Foundation. All rights reserved.