com.thoughtworks.xstream.io.xml
Class AbstractDocumentReader

java.lang.Object
  extended by com.thoughtworks.xstream.io.xml.AbstractXmlReader
      extended by com.thoughtworks.xstream.io.xml.AbstractDocumentReader
All Implemented Interfaces:
HierarchicalStreamReader
Direct Known Subclasses:
Dom4JReader, DomReader, JDomReader, XomReader, XppDomReader

public abstract class AbstractDocumentReader
extends AbstractXmlReader


Constructor Summary
protected AbstractDocumentReader(java.lang.Object rootElement)
           
protected AbstractDocumentReader(java.lang.Object rootElement, XmlFriendlyReplacer replacer)
           
 
Method Summary
 void appendErrors(ErrorWriter errorWriter)
          If any errors are detected, allow the reader to add any additional information that can aid debugging (such as line numbers, XPath expressions, etc).
 void close()
          Close the reader, if necessary.
 java.util.Iterator getAttributeNames()
          Names of attributes (as Strings).
protected abstract  java.lang.Object getChild(int index)
           
protected abstract  int getChildCount()
           
 java.lang.Object getCurrent()
           
protected abstract  java.lang.Object getParent()
           
 boolean hasMoreChildren()
          Does the node have any more children remaining that have not yet been read?
 void moveDown()
           
 void moveUp()
           
 java.lang.Object peekUnderlyingNode()
          Deprecated. As of 1.2, use getCurrent()
protected abstract  void reassignCurrentElement(java.lang.Object current)
           
 HierarchicalStreamReader underlyingReader()
          Return the underlying HierarchicalStreamReader implementation.
 
Methods inherited from class com.thoughtworks.xstream.io.xml.AbstractXmlReader
unescapeXmlName
 
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
getAttribute, getAttribute, getAttributeCount, getAttributeName, getNodeName, getValue
 

Constructor Detail

AbstractDocumentReader

protected AbstractDocumentReader(java.lang.Object rootElement)

AbstractDocumentReader

protected AbstractDocumentReader(java.lang.Object rootElement,
                                 XmlFriendlyReplacer replacer)
Since:
1.2
Method Detail

reassignCurrentElement

protected abstract void reassignCurrentElement(java.lang.Object current)

getParent

protected abstract java.lang.Object getParent()

getChild

protected abstract java.lang.Object getChild(int index)

getChildCount

protected abstract int getChildCount()

hasMoreChildren

public boolean hasMoreChildren()
Description copied from interface: HierarchicalStreamReader
Does the node have any more children remaining that have not yet been read?


moveUp

public void moveUp()

moveDown

public void moveDown()

getAttributeNames

public java.util.Iterator getAttributeNames()
Description copied from interface: HierarchicalStreamReader
Names of attributes (as Strings).


appendErrors

public void appendErrors(ErrorWriter errorWriter)
Description copied from interface: HierarchicalStreamReader
If any errors are detected, allow the reader to add any additional information that can aid debugging (such as line numbers, XPath expressions, etc).


peekUnderlyingNode

public java.lang.Object peekUnderlyingNode()
Deprecated. As of 1.2, use getCurrent()


getCurrent

public java.lang.Object getCurrent()

close

public void close()
Description copied from interface: HierarchicalStreamReader
Close the reader, if necessary.


underlyingReader

public HierarchicalStreamReader underlyingReader()
Description copied from interface: HierarchicalStreamReader
Return the underlying HierarchicalStreamReader implementation.

If a Converter needs to access methods of a specific HierarchicalStreamReader implementation that are not defined in the HierarchicalStreamReader interface, it should call this method before casting. This is because the reader passed to the Converter is often wrapped/decorated by another implementation to provide additional functionality (such as XPath tracking).

For example:

MySpecificReader mySpecificReader = (MySpecificReader)reader; // INCORRECT!
 mySpecificReader.doSomethingSpecific();
MySpecificReader mySpecificReader = (MySpecificReader)reader.underlyingReader();  // CORRECT!
 mySpecificReader.doSomethingSpecific();

Implementations of HierarchicalStreamReader should return 'this', unless they are a decorator, in which case they should delegate to whatever they are wrapping.



Joe Walnes, http://xstream.codehaus.org/