com.thoughtworks.xstream.io.binary
Class BinaryStreamReader

java.lang.Object
  extended bycom.thoughtworks.xstream.io.binary.BinaryStreamReader
All Implemented Interfaces:
HierarchicalStreamReader

public class BinaryStreamReader
extends java.lang.Object
implements HierarchicalStreamReader

A HierarchicalStreamReader that reads from a binary stream created by BinaryStreamWriter.

This produces

Since:
1.2
Author:
Joe Walnes
See Also:
BinaryStreamReader

Constructor Summary
BinaryStreamReader(java.io.InputStream inputStream)
           
 
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.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.
 java.util.Iterator getAttributeNames()
          Names of attributes (as Strings).
 java.lang.String getNodeName()
          Get the name of the current node.
 java.lang.String getValue()
          Get the value (text content) of the current node.
 boolean hasMoreChildren()
          Does the node have any more children remaining that have not yet been read?
 void moveDown()
          Select the current child as current node.
 void moveUp()
          Select the parent node as current node.
 void pushBack(Token token)
           
 HierarchicalStreamReader underlyingReader()
          Return the underlying HierarchicalStreamReader implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryStreamReader

public BinaryStreamReader(java.io.InputStream inputStream)
Method Detail

hasMoreChildren

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

Specified by:
hasMoreChildren in interface HierarchicalStreamReader

getNodeName

public java.lang.String getNodeName()
Description copied from interface: HierarchicalStreamReader
Get the name of the current node.

Specified by:
getNodeName in interface HierarchicalStreamReader

getValue

public java.lang.String getValue()
Description copied from interface: HierarchicalStreamReader
Get the value (text content) of the current node.

Specified by:
getValue in interface HierarchicalStreamReader

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.

Specified by:
getAttribute in interface HierarchicalStreamReader

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.

Specified by:
getAttribute in interface HierarchicalStreamReader

getAttributeCount

public int getAttributeCount()
Description copied from interface: HierarchicalStreamReader
Number of attributes in current node.

Specified by:
getAttributeCount in interface HierarchicalStreamReader

getAttributeName

public java.lang.String getAttributeName(int index)
Description copied from interface: HierarchicalStreamReader
Name of attribute in current node.

Specified by:
getAttributeName in interface HierarchicalStreamReader

getAttributeNames

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

Specified by:
getAttributeNames in interface HierarchicalStreamReader

moveDown

public void moveDown()
Description copied from interface: HierarchicalStreamReader
Select the current child as current node. A call to this function must be balanced with a call to HierarchicalStreamReader.moveUp().

Specified by:
moveDown in interface HierarchicalStreamReader

moveUp

public void moveUp()
Description copied from interface: HierarchicalStreamReader
Select the parent node as current node.

Specified by:
moveUp in interface HierarchicalStreamReader

pushBack

public void pushBack(Token token)

close

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

Specified by:
close in interface HierarchicalStreamReader

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.

Specified by:
underlyingReader in interface HierarchicalStreamReader

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).

Specified by:
appendErrors in interface HierarchicalStreamReader


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