Top Methods
com.thoughtworks.xstream.io

public Interface HierarchicalStreamReader

extends ErrorReporter
Known Direct Subinterfaces
com.thoughtworks.xstream.io.xml.DocumentReader, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
Imports
com.thoughtworks.xstream.converters.ErrorReporter, .ErrorWriter, java.util.Iterator

Author
Joe Walnes

Method Summary

Modifier and TypeMethod and Description
public void
appendErrors(ErrorWriter
the error writer
errorWriter
)

Redeclares com.thoughtworks.xstream.converters.ErrorReporter.appendErrors.

If any errors are detected, allow the reader to add any additional information that can aid debugging (such as line numbers, XPath expressions, etc).
public void
close()

Close the reader, if necessary.

public String
getAttribute(String name)

Get the value of an attribute of the current node.

public String
getAttribute(int index)

Get the value of an attribute of the current node, by index.

public int
getAttributeCount()

Number of attributes in current node.

public String
getAttributeName(int index)

Name of attribute in current node.

public Iterator<E>
getAttributeNames()

Iterator with the names of the attributes.

public String
getNodeName()

Get the name of the current node.

public String
getValue()

Get the value (text content) of the current node.

public boolean
hasMoreChildren()

Does the node have any more children remaining that have not yet been read?

public void
moveDown()

Select the current child as current node.

public void
moveUp()

Select the parent node as current node.

public HierarchicalStreamReader
underlyingReader()

Return the underlying HierarchicalStreamReader implementation.

Method Detail

appendErrorsback to summary
public void appendErrors(ErrorWriter errorWriter)

Redeclares com.thoughtworks.xstream.converters.ErrorReporter.appendErrors.

If any errors are detected, allow the reader to add any additional information that can aid debugging (such as line numbers, XPath expressions, etc).

Parameters
errorWriter:ErrorWriter

Doc from com.thoughtworks.xstream.converters.ErrorReporter.appendErrors.

the error writer

closeback to summary
public void close()

Close the reader, if necessary.

getAttributeback to summary
public String getAttribute(String name)

Get the value of an attribute of the current node.

If no such attribute exists, the method returns null.

getAttributeback to summary
public String getAttribute(int index)

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.

getAttributeCountback to summary
public int getAttributeCount()

Number of attributes in current node.

getAttributeNameback to summary
public String getAttributeName(int index)

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.

getAttributeNamesback to summary
public Iterator<E> getAttributeNames()

Iterator with the names of the attributes.

Note, the iterator is only valid as long as the internal state of the underlying parser is still at the start of the current element. The behavior is undefined if the parser moved on.

getNodeNameback to summary
public String getNodeName()

Get the name of the current node.

getValueback to summary
public String getValue()

Get the value (text content) of the current node.

hasMoreChildrenback to summary
public boolean hasMoreChildren()

Does the node have any more children remaining that have not yet been read?

moveDownback to summary
public void moveDown()

Select the current child as current node. A call to this function must be balanced with a call to moveUp().

moveUpback to summary
public void moveUp()

Select the parent node as current node.

underlyingReaderback to summary
public HierarchicalStreamReader underlyingReader()

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.