|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jvnet.staxex.util.DOMStreamReader
public class DOMStreamReader
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.
| Nested Class Summary | |
|---|---|
protected static class |
DOMStreamReader.Scope
Namespace declarations on one element. |
| Field Summary | |
|---|---|
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. |
| 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 | |
|---|---|
DOMStreamReader()
|
|
DOMStreamReader(Node node)
|
|
| Method Summary | |
|---|---|
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()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
public DOMStreamReader()
public DOMStreamReader(Node node)
| Method Detail |
|---|
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 XMLStreamReader
public String getAttributeValue(String namespaceURI,
String localName)
getAttributeValue in interface XMLStreamReaderpublic String getCharacterEncodingScheme()
getCharacterEncodingScheme in interface XMLStreamReader
public 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 XMLStreamReader
public Object getProperty(String str)
throws IllegalArgumentException
getProperty in interface XMLStreamReaderIllegalArgumentExceptionpublic String getText()
getText in interface XMLStreamReaderpublic char[] getTextCharacters()
getTextCharacters in interface XMLStreamReader
public 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 XMLStreamReader
public 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 XMLStreamReader
public int next()
throws XMLStreamException
next in interface XMLStreamReaderXMLStreamException
protected int _next()
throws XMLStreamException
XMLStreamException
public int nextTag()
throws XMLStreamException
nextTag in interface XMLStreamReaderXMLStreamException
public void require(int type,
String namespaceURI,
String localName)
throws XMLStreamException
require in interface XMLStreamReaderXMLStreamExceptionpublic boolean standaloneSet()
standaloneSet in interface XMLStreamReader
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||