public class DOMStreamReader extends Object implements XMLStreamReader, NamespaceContext
XMLStreamReader
on top of a DOM tree.
Since various libraries as well as users often create "incorrect" DOM node, this class spends a lot of efforts making sure that broken DOM trees are nevertheless interpreted correctly.
For example, if a DOM level
1 tree is passed, each method will attempt to return the correct value
by using Node.getNodeName()
.
Similarly, if DOM is missing explicit namespace declarations, this class attempts to emulate necessary declarations.
Modifier and Type | Class and Description |
---|---|
protected static class |
DOMStreamReader.Scope
Namespace declarations on one element.
|
Modifier and Type | Field and Description |
---|---|
protected Node |
_current
Current DOM node being traversed.
|
protected int |
_state
State of this reader.
|
protected int |
depth
Depth of the current element.
|
protected DOMStreamReader.Scope[] |
scopes
DOMStreamReader.Scope buffer. |
protected String |
wholeText
If the reader points at
the text node ,
its whole value. |
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 |
---|
DOMStreamReader() |
DOMStreamReader(Node node) |
Modifier and Type | Method and Description |
---|---|
protected int |
_next() |
void |
close() |
int |
getAttributeCount() |
String |
getAttributeLocalName(int index)
Return an attribute's local name.
|
QName |
getAttributeName(int index)
Return an attribute's qname.
|
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() |
int |
getEventType() |
String |
getLocalName()
Return an element's local name.
|
Location |
getLocation() |
QName |
getName()
Return an element's qname.
|
NamespaceContext |
getNamespaceContext() |
int |
getNamespaceCount() |
String |
getNamespacePrefix(int index) |
String |
getNamespaceURI() |
String |
getNamespaceURI(int index) |
String |
getNamespaceURI(String prefix)
This method is not particularly fast, but shouldn't be called very
often.
|
String |
getPIData() |
String |
getPITarget() |
String |
getPrefix() |
String |
getPrefix(String nsUri) |
Iterator |
getPrefixes(String nsUri) |
Object |
getProperty(String str) |
String |
getText() |
char[] |
getTextCharacters() |
int |
getTextCharacters(int sourceStart,
char[] target,
int targetStart,
int targetLength) |
int |
getTextLength() |
int |
getTextStart() |
String |
getVersion() |
boolean |
hasName() |
boolean |
hasNext() |
boolean |
hasText() |
boolean |
isAttributeSpecified(int param) |
boolean |
isCharacters() |
boolean |
isEndElement() |
boolean |
isStandalone() |
boolean |
isStartElement() |
boolean |
isWhiteSpace() |
int |
next() |
int |
nextTag() |
void |
require(int type,
String namespaceURI,
String localName) |
void |
setCurrentNode(Node node) |
protected void |
splitAttributes()
Called when the current node is
Element to look at attribute list
(which contains both ns decl and attributes in DOM) and split them
to attributes-proper and namespace decls. |
boolean |
standaloneSet() |
protected Node _current
protected String wholeText
the text node
,
its whole value.
This is simply a cache of Text.getWholeText()
of _current
,
but when a large binary data sent as base64 text, this could get very much
non-trivial.
protected DOMStreamReader.Scope[] scopes
DOMStreamReader.Scope
buffer.protected int depth
scopes
.protected int _state
public DOMStreamReader()
public DOMStreamReader(Node node)
public void setCurrentNode(Node node)
public void close() throws XMLStreamException
close
in interface XMLStreamReader
XMLStreamException
protected void splitAttributes()
Element
to look at attribute list
(which contains both ns decl and attributes in DOM) and split them
to attributes-proper and namespace decls.public int getAttributeCount()
getAttributeCount
in interface XMLStreamReader
public String getAttributeLocalName(int index)
getAttributeLocalName
in interface XMLStreamReader
public QName getAttributeName(int index)
getAttributeName
in interface XMLStreamReader
public String getAttributeNamespace(int index)
getAttributeNamespace
in interface XMLStreamReader
public String getAttributePrefix(int index)
getAttributePrefix
in interface XMLStreamReader
public String getAttributeType(int index)
getAttributeType
in interface XMLStreamReader
public String getAttributeValue(int index)
getAttributeValue
in interface XMLStreamReader
public String getAttributeValue(String namespaceURI, String localName)
getAttributeValue
in interface XMLStreamReader
public String getCharacterEncodingScheme()
getCharacterEncodingScheme
in interface XMLStreamReader
public String getElementText() throws XMLStreamException
getElementText
in interface XMLStreamReader
XMLStreamException
public String getEncoding()
getEncoding
in interface XMLStreamReader
public int getEventType()
getEventType
in interface XMLStreamReader
public String getLocalName()
getLocalName
in interface XMLStreamReader
public Location getLocation()
getLocation
in interface XMLStreamReader
public QName getName()
getName
in interface XMLStreamReader
public NamespaceContext getNamespaceContext()
getNamespaceContext
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 String getNamespaceURI()
getNamespaceURI
in interface XMLStreamReader
public String getNamespaceURI(String prefix)
getNamespaceURI
in interface NamespaceContext
getNamespaceURI
in interface XMLStreamReader
public String getPrefix(String nsUri)
getPrefix
in interface NamespaceContext
public Iterator getPrefixes(String nsUri)
getPrefixes
in interface NamespaceContext
public String getPIData()
getPIData
in interface XMLStreamReader
public String getPITarget()
getPITarget
in interface XMLStreamReader
public String getPrefix()
getPrefix
in interface XMLStreamReader
public Object getProperty(String str) throws IllegalArgumentException
getProperty
in interface XMLStreamReader
IllegalArgumentException
public String getText()
getText
in interface XMLStreamReader
public char[] getTextCharacters()
getTextCharacters
in interface XMLStreamReader
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int targetLength) throws XMLStreamException
getTextCharacters
in interface XMLStreamReader
XMLStreamException
public int getTextLength()
getTextLength
in interface XMLStreamReader
public int getTextStart()
getTextStart
in interface XMLStreamReader
public String getVersion()
getVersion
in interface XMLStreamReader
public boolean hasName()
hasName
in interface XMLStreamReader
public boolean hasNext() throws XMLStreamException
hasNext
in interface XMLStreamReader
XMLStreamException
public boolean hasText()
hasText
in interface XMLStreamReader
public boolean isAttributeSpecified(int param)
isAttributeSpecified
in interface XMLStreamReader
public boolean isCharacters()
isCharacters
in interface XMLStreamReader
public boolean isEndElement()
isEndElement
in interface XMLStreamReader
public boolean isStandalone()
isStandalone
in interface XMLStreamReader
public boolean isStartElement()
isStartElement
in interface XMLStreamReader
public boolean isWhiteSpace()
isWhiteSpace
in interface XMLStreamReader
public int next() throws XMLStreamException
next
in interface XMLStreamReader
XMLStreamException
protected int _next() throws XMLStreamException
XMLStreamException
public int nextTag() throws XMLStreamException
nextTag
in interface XMLStreamReader
XMLStreamException
public void require(int type, String namespaceURI, String localName) throws XMLStreamException
require
in interface XMLStreamReader
XMLStreamException
public boolean standaloneSet()
standaloneSet
in interface XMLStreamReader
Copyright © 2021 JBoss by Red Hat. All rights reserved.