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.
Namespace declarations on one element. |
| Modifier and Type | Field and Description |
|---|---|
| protected Node | _current
Current DOM node being traversed. |
| private final FinalArrayList | _currentAttributes
List of attributes extracted from |
| private NamedNodeMap | _namedNodeMap
Named mapping for attributes and NS decls for the current node. |
| private Node | _start
Starting node of the subtree being traversed. |
| protected int | _state
State of this reader. |
| protected int | depth
Depth of the current element. |
| protected DOMStreamReader. | |
| protected String | wholeText
If the reader points at |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected int | |
| private DOMStreamReader. | |
| public void | close()
Implements javax. Frees any resources associated with this Reader. |
| private void | |
| private Node | |
| private static String | |
| public int | getAttributeCount()
Implements javax. Returns the count of attributes on this START_ELEMENT, this method is only valid on a START_ELEMENT or ATTRIBUTE. |
| public String | getAttributeLocalName(int index)
Implements javax. Return an attribute's local name.Handle the case of DOM level 1 nodes. |
| public QName | getAttributeName(int index)
Implements javax. Return an attribute's qname. |
| public String | getAttributeNamespace(int index)
Implements javax. Returns the namespace of the attribute at the provided index |
| public String | getAttributePrefix(int index)
Implements javax. Returns the prefix of this attribute at the provided index |
| public String | getAttributeType(int index)
Implements javax. Returns the XML type of the attribute at the provided index |
| public String | getAttributeValue(int index)
Implements javax. Returns the value of the attribute at the index |
| public String | getAttributeValue(String namespaceURI, String localName)
Implements javax. Returns the normalized attribute value of the attribute with the namespace and localName If the namespaceURI is null the namespace is not checked for equality |
| public String | getCharacterEncodingScheme()
Implements javax. Returns the character encoding declared on the xml declaration Returns null if none was declared |
| private DOMStreamReader. | getCheckedScope()
Verifies the current state to see if we can return the scope, and do so if appropriate. |
| public String | getElementText()
Implements javax. Reads the content of a text-only element, an exception is thrown if this is not a text-only element. |
| public String | getEncoding()
Implements javax. Return input encoding if known or null if unknown. |
| public int | getEventType()
Implements javax. Returns an integer code that indicates the type of the event the cursor is pointing to. |
| public String | getLocalName()
Implements javax. Return an element's local name.Handle the case of DOM level 1 nodes. |
| public Location | getLocation()
Implements javax. Return the current location of the processor. |
| public QName | |
| public NamespaceContext | getNamespaceContext()
Implements javax. Returns a read only namespace context for the current position. |
| public int | getNamespaceCount()
Implements javax. Returns the count of namespaces declared on this START_ELEMENT or END_ELEMENT, this method is only valid on a START_ELEMENT, END_ELEMENT or NAMESPACE. |
| public String | getNamespacePrefix(int index)
Implements javax. Returns the prefix for the namespace declared at the index. |
| public String | getNamespaceURI(int index)
Implements javax. Returns the uri for the namespace declared at the index. |
| public String | getNamespaceURI()
Implements javax. If the current event is a START_ELEMENT or END_ELEMENT this method returns the URI of the prefix or the default namespace. |
| public String | getNamespaceURI(String prefix)
Implements javax. 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. |
| public String | getPIData()
Implements javax. Get the data section of a processing instruction |
| public String | getPITarget()
Implements javax. Get the target of a processing instruction |
| public String | getPrefix(String nsUri)
Implements javax. Get prefix bound to Namespace URI in the current scope. |
| public String | getPrefix()
Implements javax. Returns the prefix of the current event or null if the event does not have a prefix |
| public Iterator | getPrefixes(String nsUri)
Implements javax. Get all prefixes bound to a Namespace URI in the current scope. |
| private static String | getPrefixForAttr(Attr attr, String nsUri)
If the given attribute is a namespace declaration for the given namespace URI, return its prefix. |
| public Object | getProperty(String str)
Implements javax. Get the value of a feature/property from the underlying implementation |
| public String | getText()
Implements javax. Returns the current value of the parse event as a string, this returns the string value of a CHARACTERS event, returns the value of a COMMENT, the replacement value for an ENTITY_REFERENCE, the string value of a CDATA section, the string value for a SPACE event, or the String value of the internal subset of the DTD. |
| public char[] | getTextCharacters()
Implements javax. Returns an array which contains the characters from this event. |
| public int | getTextCharacters(int sourceStart, char[] target, int targetStart, int targetLength)
Implements javax. Gets the text associated with a CHARACTERS, SPACE or CDATA event. |
| public int | getTextLength()
Implements javax. Returns the length of the sequence of characters for this Text event within the text character array. |
| public int | getTextStart()
Implements javax. Returns the offset into the text character array where the first character (of this text event) is stored. |
| public String | getVersion()
Implements javax. Get the xml version declared on the xml declaration Returns null if none was declared |
| public boolean | hasName()
Implements javax. returns a boolean indicating whether the current event has a name (is a START_ELEMENT or END_ELEMENT). |
| public boolean | hasNext()
Implements javax. Returns true if there are more parsing events and false if there are no more events. |
| public boolean | hasText()
Implements javax. Return a boolean indicating whether the current event has text. |
| public boolean | isAttributeSpecified(int param)
Implements javax. Returns a boolean which indicates if this attribute was created by default |
| public boolean | isCharacters()
Implements javax. Returns true if the cursor points to a character data event |
| public boolean | isEndElement()
Implements javax. Returns true if the cursor points to an end tag (otherwise false) |
| public boolean | isStandalone()
Implements javax. Get the standalone declaration from the xml declaration |
| public boolean | isStartElement()
Implements javax. Returns true if the cursor points to a start tag (otherwise false) |
| public boolean | isWhiteSpace()
Implements javax. Returns true if the cursor points to a character data event that consists of all whitespace |
| private static int | |
| public int | next()
Implements javax. Get next parsing event - a processor may return all contiguous character data in a single chunk, or it may split it into several chunks. |
| public int | nextTag()
Implements javax. Skips any white space (isWhiteSpace() returns true), COMMENT, or PROCESSING_INSTRUCTION, until a START_ELEMENT or END_ELEMENT is reached. |
| public void | require(int type, String namespaceURI, String localName)
Implements javax. Test if the current event is of the given type and if the namespace and name match the current namespace and name of the current event. |
| public void | |
| protected void | splitAttributes()
Called when the current node is |
| public boolean | standaloneSet()
Implements javax. Checks if standalone was set in the document |