com.thoughtworks.xstream.io.binary
Class Token

java.lang.Object
  extended by com.thoughtworks.xstream.io.binary.Token
Direct Known Subclasses:
Token.Attribute, Token.EndNode, Token.MapIdToValue, Token.StartNode, Token.Value

public abstract class Token
extends Object

Represents the Tokens stored in the binary stream used by BinaryStreamReader and BinaryStreamWriter.

A token consists of a type and (depending on this type) it may additionally have an ID (positive long number) and/or a value (String).

The first byte of the token represents how many subsequent bytes are used by the ID.

Since:
1.2
Author:
Joe Walnes
See Also:
BinaryStreamReader, BinaryStreamWriter

Nested Class Summary
static class Token.Attribute
           
static class Token.EndNode
           
static class Token.Formatter
           
static class Token.MapIdToValue
           
static class Token.StartNode
           
static class Token.Value
           
 
Field Summary
protected  long id
           
static byte TYPE_ATTRIBUTE
           
static byte TYPE_END_NODE
           
static byte TYPE_MAP_ID_TO_VALUE
           
static byte TYPE_START_NODE
           
static byte TYPE_VALUE
           
static byte TYPE_VERSION
           
protected  String value
           
 
Constructor Summary
Token(byte type)
           
 
Method Summary
 boolean equals(Object o)
           
 long getId()
           
 byte getType()
           
 String getValue()
           
 int hashCode()
           
abstract  void readFrom(DataInput in, byte idType)
           
protected  long readId(DataInput in, byte idType)
           
protected  String readString(DataInput in)
           
 String toString()
           
protected  void writeId(DataOutput out, long id, byte idType)
           
protected  void writeString(DataOutput out, String string)
           
abstract  void writeTo(DataOutput out, byte idType)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_VERSION

public static final byte TYPE_VERSION
See Also:
Constant Field Values

TYPE_MAP_ID_TO_VALUE

public static final byte TYPE_MAP_ID_TO_VALUE
See Also:
Constant Field Values

TYPE_START_NODE

public static final byte TYPE_START_NODE
See Also:
Constant Field Values

TYPE_END_NODE

public static final byte TYPE_END_NODE
See Also:
Constant Field Values

TYPE_ATTRIBUTE

public static final byte TYPE_ATTRIBUTE
See Also:
Constant Field Values

TYPE_VALUE

public static final byte TYPE_VALUE
See Also:
Constant Field Values

id

protected long id

value

protected String value
Constructor Detail

Token

public Token(byte type)
Method Detail

getType

public byte getType()

getId

public long getId()

getValue

public String getValue()

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

writeTo

public abstract void writeTo(DataOutput out,
                             byte idType)
                      throws IOException
Throws:
IOException

readFrom

public abstract void readFrom(DataInput in,
                              byte idType)
                       throws IOException
Throws:
IOException

writeId

protected void writeId(DataOutput out,
                       long id,
                       byte idType)
                throws IOException
Throws:
IOException

writeString

protected void writeString(DataOutput out,
                           String string)
                    throws IOException
Throws:
IOException

readId

protected long readId(DataInput in,
                      byte idType)
               throws IOException
Throws:
IOException

readString

protected String readString(DataInput in)
                     throws IOException
Throws:
IOException


Copyright © 2004-2014 XStream. All Rights Reserved.