NamespaceContext, XMLStreamConstants, XMLStreamReaderpublic 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 | Description |
|---|---|---|
protected static class |
DOMStreamReader.Scope |
Namespace declarations on one element.
|
| Modifier and Type | Field | 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 | Description |
|---|---|
DOMStreamReader() |
|
DOMStreamReader(Node node) |
| Modifier and Type | Method | 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 XMLStreamReaderXMLStreamExceptionprotected 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 XMLStreamReaderpublic String getAttributeLocalName(int index)
getAttributeLocalName in interface XMLStreamReaderpublic QName getAttributeName(int index)
getAttributeName in interface XMLStreamReaderpublic String getAttributeNamespace(int index)
getAttributeNamespace in interface XMLStreamReaderpublic String getAttributePrefix(int index)
getAttributePrefix in interface XMLStreamReaderpublic String getAttributeType(int index)
getAttributeType in interface XMLStreamReaderpublic String getAttributeValue(int index)
getAttributeValue in interface XMLStreamReaderpublic String getAttributeValue(String namespaceURI, String localName)
getAttributeValue in interface XMLStreamReaderpublic String getCharacterEncodingScheme()
getCharacterEncodingScheme in interface XMLStreamReaderpublic String getElementText() throws XMLStreamException
getElementText in interface XMLStreamReaderXMLStreamExceptionpublic String getEncoding()
getEncoding in interface XMLStreamReaderpublic int getEventType()
getEventType in interface XMLStreamReaderpublic String getLocalName()
getLocalName in interface XMLStreamReaderpublic Location getLocation()
getLocation in interface XMLStreamReaderpublic QName getName()
getName in interface XMLStreamReaderpublic NamespaceContext getNamespaceContext()
getNamespaceContext 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 String getNamespaceURI()
getNamespaceURI in interface XMLStreamReaderpublic String getNamespaceURI(String prefix)
getNamespaceURI in interface NamespaceContextgetNamespaceURI in interface XMLStreamReaderpublic String getPrefix(String nsUri)
getPrefix in interface NamespaceContextpublic Iterator getPrefixes(String nsUri)
getPrefixes in interface NamespaceContextpublic String getPIData()
getPIData in interface XMLStreamReaderpublic String getPITarget()
getPITarget in interface XMLStreamReaderpublic String getPrefix()
getPrefix in interface XMLStreamReaderpublic Object getProperty(String str) throws IllegalArgumentException
getProperty in interface XMLStreamReaderIllegalArgumentExceptionpublic String getText()
getText in interface XMLStreamReaderpublic char[] getTextCharacters()
getTextCharacters in interface XMLStreamReaderpublic int getTextCharacters(int sourceStart,
char[] target,
int targetStart,
int targetLength)
throws XMLStreamException
getTextCharacters in interface XMLStreamReaderXMLStreamExceptionpublic int getTextLength()
getTextLength in interface XMLStreamReaderpublic int getTextStart()
getTextStart in interface XMLStreamReaderpublic String getVersion()
getVersion in interface XMLStreamReaderpublic boolean hasName()
hasName in interface XMLStreamReaderpublic boolean hasNext()
throws XMLStreamException
hasNext in interface XMLStreamReaderXMLStreamExceptionpublic boolean hasText()
hasText in interface XMLStreamReaderpublic boolean isAttributeSpecified(int param)
isAttributeSpecified in interface XMLStreamReaderpublic boolean isCharacters()
isCharacters in interface XMLStreamReaderpublic boolean isEndElement()
isEndElement in interface XMLStreamReaderpublic boolean isStandalone()
isStandalone in interface XMLStreamReaderpublic boolean isStartElement()
isStartElement in interface XMLStreamReaderpublic boolean isWhiteSpace()
isWhiteSpace in interface XMLStreamReaderpublic int next()
throws XMLStreamException
next in interface XMLStreamReaderXMLStreamExceptionprotected int _next()
throws XMLStreamException
XMLStreamExceptionpublic int nextTag()
throws XMLStreamException
nextTag in interface XMLStreamReaderXMLStreamExceptionpublic void require(int type,
String namespaceURI,
String localName)
throws XMLStreamException
require in interface XMLStreamReaderXMLStreamExceptionpublic boolean standaloneSet()
standaloneSet in interface XMLStreamReaderCopyright © 2006-2018. All Rights Reserved.