java.lang.Object
com.sun.xml.ws.streaming.DOMStreamReader
- All Implemented Interfaces:
NamespaceContext
,XMLStreamConstants
,XMLStreamReader
Create an
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.
- Author:
- [email protected], Kohsuke Kawaguchi
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final class
Namespace declarations on one element. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Node
Current DOM node being traversed.protected int
State of this reader.protected int
Depth of the current element.protected DOMStreamReader.Scope[]
DOMStreamReader.Scope
buffer.protected String
If the reader points atthe text node
, its whole value.Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
_next()
void
close()
int
getAttributeLocalName
(int index) Return an attribute's local name.getAttributeName
(int index) Return an attribute's qname.getAttributeNamespace
(int index) getAttributePrefix
(int index) getAttributeType
(int index) getAttributeValue
(int index) getAttributeValue
(String namespaceURI, String localName) int
Return an element's local name.getName()
Return an element's qname.int
getNamespacePrefix
(int index) getNamespaceURI
(int index) getNamespaceURI
(String prefix) This method is not particularly fast, but shouldn't be called very often.getPrefixes
(String nsUri) getProperty
(String str) getText()
char[]
int
getTextCharacters
(int sourceStart, char[] target, int targetStart, int targetLength) int
int
boolean
hasName()
boolean
hasNext()
boolean
hasText()
boolean
isAttributeSpecified
(int param) boolean
boolean
boolean
boolean
boolean
int
next()
int
nextTag()
void
void
setCurrentNode
(Node node) protected void
Called when the current node isElement
to look at attribute list (which contains both ns decl and attributes in DOM) and split them to attributes-proper and namespace decls.boolean
-
Field Details
-
_current
Current DOM node being traversed. -
wholeText
If the reader points atthe 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. -
scopes
DOMStreamReader.Scope
buffer. -
depth
protected int depthDepth of the current element. The first element gets depth==0. Also used as the index toscopes
. -
_state
protected int _stateState of this reader. Any of the valid states defined in StAX' XMLStreamConstants class.
-
-
Constructor Details
-
DOMStreamReader
public DOMStreamReader() -
DOMStreamReader
-
-
Method Details
-
setCurrentNode
-
close
- Specified by:
close
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
splitAttributes
protected void splitAttributes()Called when the current node isElement
to look at attribute list (which contains both ns decl and attributes in DOM) and split them to attributes-proper and namespace decls. -
getAttributeCount
public int getAttributeCount()- Specified by:
getAttributeCount
in interfaceXMLStreamReader
-
getAttributeLocalName
Return an attribute's local name. Handle the case of DOM level 1 nodes.- Specified by:
getAttributeLocalName
in interfaceXMLStreamReader
-
getAttributeName
Return an attribute's qname. Handle the case of DOM level 1 nodes.- Specified by:
getAttributeName
in interfaceXMLStreamReader
-
getAttributeNamespace
- Specified by:
getAttributeNamespace
in interfaceXMLStreamReader
-
getAttributePrefix
- Specified by:
getAttributePrefix
in interfaceXMLStreamReader
-
getAttributeType
- Specified by:
getAttributeType
in interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValue
in interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValue
in interfaceXMLStreamReader
-
getCharacterEncodingScheme
- Specified by:
getCharacterEncodingScheme
in interfaceXMLStreamReader
-
getElementText
- Specified by:
getElementText
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
getEncoding
- Specified by:
getEncoding
in interfaceXMLStreamReader
-
getEventType
public int getEventType()- Specified by:
getEventType
in interfaceXMLStreamReader
-
getLocalName
Return an element's local name. Handle the case of DOM level 1 nodes.- Specified by:
getLocalName
in interfaceXMLStreamReader
-
getLocation
- Specified by:
getLocation
in interfaceXMLStreamReader
-
getName
Return an element's qname. Handle the case of DOM level 1 nodes.- Specified by:
getName
in interfaceXMLStreamReader
-
getNamespaceContext
- Specified by:
getNamespaceContext
in interfaceXMLStreamReader
-
getNamespaceCount
public int getNamespaceCount()- Specified by:
getNamespaceCount
in interfaceXMLStreamReader
-
getNamespacePrefix
- Specified by:
getNamespacePrefix
in interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getNamespaceURI
This method is not particularly fast, but shouldn't be called very often. If we start to use it more, we should keep track of the NS declarations using a NamespaceContext implementation instead.- Specified by:
getNamespaceURI
in interfaceNamespaceContext
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefix
in interfaceNamespaceContext
-
getPrefixes
- Specified by:
getPrefixes
in interfaceNamespaceContext
-
getPIData
- Specified by:
getPIData
in interfaceXMLStreamReader
-
getPITarget
- Specified by:
getPITarget
in interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefix
in interfaceXMLStreamReader
-
getProperty
- Specified by:
getProperty
in interfaceXMLStreamReader
- Throws:
IllegalArgumentException
-
getText
- Specified by:
getText
in interfaceXMLStreamReader
-
getTextCharacters
public char[] getTextCharacters()- Specified by:
getTextCharacters
in interfaceXMLStreamReader
-
getTextCharacters
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int targetLength) throws XMLStreamException - Specified by:
getTextCharacters
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
getTextLength
public int getTextLength()- Specified by:
getTextLength
in interfaceXMLStreamReader
-
getTextStart
public int getTextStart()- Specified by:
getTextStart
in interfaceXMLStreamReader
-
getVersion
- Specified by:
getVersion
in interfaceXMLStreamReader
-
hasName
public boolean hasName()- Specified by:
hasName
in interfaceXMLStreamReader
-
hasNext
- Specified by:
hasNext
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
hasText
public boolean hasText()- Specified by:
hasText
in interfaceXMLStreamReader
-
isAttributeSpecified
public boolean isAttributeSpecified(int param) - Specified by:
isAttributeSpecified
in interfaceXMLStreamReader
-
isCharacters
public boolean isCharacters()- Specified by:
isCharacters
in interfaceXMLStreamReader
-
isEndElement
public boolean isEndElement()- Specified by:
isEndElement
in interfaceXMLStreamReader
-
isStandalone
public boolean isStandalone()- Specified by:
isStandalone
in interfaceXMLStreamReader
-
isStartElement
public boolean isStartElement()- Specified by:
isStartElement
in interfaceXMLStreamReader
-
isWhiteSpace
public boolean isWhiteSpace()- Specified by:
isWhiteSpace
in interfaceXMLStreamReader
-
next
- Specified by:
next
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
_next
- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTag
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
require
- Specified by:
require
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
standaloneSet
public boolean standaloneSet()- Specified by:
standaloneSet
in interfaceXMLStreamReader
-