Package com.thoughtworks.xstream.io.xml
Class DomReader
- java.lang.Object
-
- com.thoughtworks.xstream.io.AbstractReader
-
- com.thoughtworks.xstream.io.xml.AbstractXmlReader
-
- com.thoughtworks.xstream.io.xml.AbstractDocumentReader
-
- com.thoughtworks.xstream.io.xml.DomReader
-
- All Implemented Interfaces:
ErrorReporter
,ExtendedHierarchicalStreamReader
,HierarchicalStreamReader
,DocumentReader
public class DomReader extends AbstractDocumentReader
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List
childElements
private org.w3c.dom.Element
currentElement
private java.lang.StringBuffer
textBuffer
-
Constructor Summary
Constructors Constructor Description DomReader(org.w3c.dom.Document document)
DomReader(org.w3c.dom.Document document, NameCoder nameCoder)
DomReader(org.w3c.dom.Document document, XmlFriendlyReplacer replacer)
Deprecated.As of 1.4, useDomReader(Document, NameCoder)
instead.DomReader(org.w3c.dom.Element rootElement)
DomReader(org.w3c.dom.Element rootElement, NameCoder nameCoder)
DomReader(org.w3c.dom.Element rootElement, XmlFriendlyReplacer replacer)
Deprecated.As of 1.4, useDomReader(Element, NameCoder)
instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAttribute(int index)
Get the value of an attribute of the current node, by index.java.lang.String
getAttribute(java.lang.String name)
Get the value of an attribute of the current node.int
getAttributeCount()
Number of attributes in current node.java.lang.String
getAttributeName(int index)
Name of attribute in current node.protected java.lang.Object
getChild(int index)
protected int
getChildCount()
java.lang.String
getNodeName()
Get the name of the current node.protected java.lang.Object
getParent()
java.lang.String
getValue()
Get the value (text content) of the current node.java.lang.String
peekNextChild()
Peek the name of the next child.protected void
reassignCurrentElement(java.lang.Object current)
-
Methods inherited from class com.thoughtworks.xstream.io.xml.AbstractDocumentReader
appendErrors, close, getAttributeNames, getCurrent, hasMoreChildren, moveDown, moveUp
-
Methods inherited from class com.thoughtworks.xstream.io.xml.AbstractXmlReader
escapeXmlName, unescapeXmlName
-
Methods inherited from class com.thoughtworks.xstream.io.AbstractReader
decodeAttribute, decodeNode, encodeAttribute, encodeNode, underlyingReader
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.thoughtworks.xstream.io.HierarchicalStreamReader
underlyingReader
-
-
-
-
Constructor Detail
-
DomReader
public DomReader(org.w3c.dom.Element rootElement)
-
DomReader
public DomReader(org.w3c.dom.Document document)
-
DomReader
public DomReader(org.w3c.dom.Element rootElement, NameCoder nameCoder)
- Since:
- 1.4
-
DomReader
public DomReader(org.w3c.dom.Document document, NameCoder nameCoder)
- Since:
- 1.4
-
DomReader
public DomReader(org.w3c.dom.Element rootElement, XmlFriendlyReplacer replacer)
Deprecated.As of 1.4, useDomReader(Element, NameCoder)
instead.- Since:
- 1.2
-
DomReader
public DomReader(org.w3c.dom.Document document, XmlFriendlyReplacer replacer)
Deprecated.As of 1.4, useDomReader(Document, NameCoder)
instead.- Since:
- 1.2
-
-
Method Detail
-
getNodeName
public java.lang.String getNodeName()
Description copied from interface:HierarchicalStreamReader
Get the name of the current node.
-
getValue
public java.lang.String getValue()
Description copied from interface:HierarchicalStreamReader
Get the value (text content) of the current node.
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
Description copied from interface:HierarchicalStreamReader
Get the value of an attribute of the current node.If no such attribute exists, the method returns null.
-
getAttribute
public java.lang.String getAttribute(int index)
Description copied from interface:HierarchicalStreamReader
Get the value of an attribute of the current node, by index.Note, the behavior of this method is dependent on the underlying parser when calling it with a non-existing index. Typically some kind of RuntimeException is thrown.
-
getAttributeCount
public int getAttributeCount()
Description copied from interface:HierarchicalStreamReader
Number of attributes in current node.
-
getAttributeName
public java.lang.String getAttributeName(int index)
Description copied from interface:HierarchicalStreamReader
Name of attribute in current node.Note, the behavior of this method is dependent on the underlying parser when calling it with a non-existing index. Typically some kind of RuntimeException is thrown.
-
getParent
protected java.lang.Object getParent()
- Specified by:
getParent
in classAbstractDocumentReader
-
getChild
protected java.lang.Object getChild(int index)
- Specified by:
getChild
in classAbstractDocumentReader
-
getChildCount
protected int getChildCount()
- Specified by:
getChildCount
in classAbstractDocumentReader
-
reassignCurrentElement
protected void reassignCurrentElement(java.lang.Object current)
- Specified by:
reassignCurrentElement
in classAbstractDocumentReader
-
peekNextChild
public java.lang.String peekNextChild()
Description copied from interface:ExtendedHierarchicalStreamReader
Peek the name of the next child. In situation whereHierarchicalStreamReader.hasMoreChildren()
returns true, peek the tag name of the child.- Specified by:
peekNextChild
in interfaceExtendedHierarchicalStreamReader
- Overrides:
peekNextChild
in classAbstractReader
-
-