Top Description Inners Fields Constructors Methods
com.thoughtworks.xstream.io.binary

public abstract Class Token

extends Object
Class Inheritance
Known Direct Subclasses
com.thoughtworks.xstream.io.binary.Token.MapIdToValue, com.thoughtworks.xstream.io.binary.Token.StartNode, com.thoughtworks.xstream.io.binary.Token.EndNode, com.thoughtworks.xstream.io.binary.Token.Attribute, com.thoughtworks.xstream.io.binary.Token.Value
Imports
com.thoughtworks.xstream.io.StreamException, java.io.DataOutput, .IOException, .DataInput

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.

Author
Joe Walnes
Since
1.2
See Also
BinaryStreamReader, BinaryStreamWriter

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
public static class
public static class
public static class

Field Summary

Modifier and TypeField and Description
protected long
private static final byte
private static final byte
private static final byte
private static final byte
private static final String
private static final byte
private static final int
private final byte
public static final byte
public static final byte
public static final byte
private static final byte
public static final byte
public static final byte
public static final byte
protected String

Constructor Summary

AccessConstructor and Description
public
Token(byte type)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public long
public byte
public String
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public abstract void
readFrom(DataInput in, byte idType)

protected long
readId(DataInput in, byte idType)

protected String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
protected void
writeId(DataOutput out, long id, byte idType)

protected void
public abstract void
writeTo(DataOutput out, byte idType)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

idback to summary
protected long id
ID_EIGHT_BYTESback to summary
private static final byte ID_EIGHT_BYTES
ID_FOUR_BYTESback to summary
private static final byte ID_FOUR_BYTES
ID_MASKback to summary
private static final byte ID_MASK
ID_ONE_BYTEback to summary
private static final byte ID_ONE_BYTE
ID_SPLITTEDback to summary
private static final String ID_SPLITTED
ID_TWO_BYTESback to summary
private static final byte ID_TWO_BYTES
MAX_UTF8_LENGTHback to summary
private static final int MAX_UTF8_LENGTH
typeback to summary
private final byte type
TYPE_ATTRIBUTEback to summary
public static final byte TYPE_ATTRIBUTE
TYPE_END_NODEback to summary
public static final byte TYPE_END_NODE
TYPE_MAP_ID_TO_VALUEback to summary
public static final byte TYPE_MAP_ID_TO_VALUE
TYPE_MASKback to summary
private static final byte TYPE_MASK
TYPE_START_NODEback to summary
public static final byte TYPE_START_NODE
TYPE_VALUEback to summary
public static final byte TYPE_VALUE
TYPE_VERSIONback to summary
public static final byte TYPE_VERSION
valueback to summary
protected String value

Constructor Detail

Tokenback to summary
public Token(byte type)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

getIdback to summary
public long getId()
getTypeback to summary
public byte getType()
getValueback to summary
public String getValue()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

readFromback to summary
public abstract void readFrom(DataInput in, byte idType) throws IOException
readIdback to summary
protected long readId(DataInput in, byte idType) throws IOException
readStringback to summary
protected String readString(DataInput in) throws IOException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

writeIdback to summary
protected void writeId(DataOutput out, long id, byte idType) throws IOException
writeStringback to summary
protected void writeString(DataOutput out, String string) throws IOException
writeToback to summary
public abstract void writeTo(DataOutput out, byte idType) throws IOException
com.thoughtworks.xstream.io.binary back to summary

public Class Token.Attribute

extends Token
Class Inheritance

Field Summary

Inherited from com.thoughtworks.xstream.io.binary.Token:
idTYPE_ATTRIBUTETYPE_END_NODETYPE_MAP_ID_TO_VALUETYPE_START_NODETYPE_VALUETYPE_VERSIONvalue

Constructor Summary

AccessConstructor and Description
public
Attribute(long id, String value)

public

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from com.thoughtworks.xstream.io.binary.Token:
equalsgetIdgetTypegetValuehashCodereadIdreadStringtoStringwriteIdwriteString

Constructor Detail

Attributeback to summary
public Attribute(long id, String value)
Attributeback to summary
public Attribute()

Method Detail

readFromback to summary
public void readFrom(DataInput in, byte idType) throws IOException

Implements abstract com.thoughtworks.xstream.io.binary.Token.readFrom.

writeToback to summary
public void writeTo(DataOutput out, byte idType) throws IOException

Implements abstract com.thoughtworks.xstream.io.binary.Token.writeTo.

com.thoughtworks.xstream.io.binary back to summary

public Class Token.EndNode

extends Token
Class Inheritance

Field Summary

Inherited from com.thoughtworks.xstream.io.binary.Token:
idTYPE_ATTRIBUTETYPE_END_NODETYPE_MAP_ID_TO_VALUETYPE_START_NODETYPE_VALUETYPE_VERSIONvalue

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from com.thoughtworks.xstream.io.binary.Token:
equalsgetIdgetTypegetValuehashCodereadIdreadStringtoStringwriteIdwriteString

Constructor Detail

EndNodeback to summary
public EndNode()

Method Detail

readFromback to summary
public void readFrom(DataInput in, byte idType)

Implements abstract com.thoughtworks.xstream.io.binary.Token.readFrom.

writeToback to summary
public void writeTo(DataOutput out, byte idType)

Implements abstract com.thoughtworks.xstream.io.binary.Token.writeTo.

com.thoughtworks.xstream.io.binary back to summary

public Class Token.Formatter

extends Object
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Token
contructToken(byte type)

public Token
public void
write(DataOutput out, Token token)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Formatterback to summary
public Formatter()

Method Detail

contructTokenback to summary
private Token contructToken(byte type)
readback to summary
public Token read(DataInput in) throws IOException
writeback to summary
public void write(DataOutput out, Token token) throws IOException
com.thoughtworks.xstream.io.binary back to summary

public Class Token.MapIdToValue

extends Token
Class Inheritance

Field Summary

Inherited from com.thoughtworks.xstream.io.binary.Token:
idTYPE_ATTRIBUTETYPE_END_NODETYPE_MAP_ID_TO_VALUETYPE_START_NODETYPE_VALUETYPE_VERSIONvalue

Constructor Summary

AccessConstructor and Description
public
MapIdToValue(long id, String value)

public

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from com.thoughtworks.xstream.io.binary.Token:
equalsgetIdgetTypegetValuehashCodereadIdreadStringtoStringwriteIdwriteString

Constructor Detail

MapIdToValueback to summary
public MapIdToValue(long id, String value)
MapIdToValueback to summary
public MapIdToValue()

Method Detail

readFromback to summary
public void readFrom(DataInput in, byte idType) throws IOException

Implements abstract com.thoughtworks.xstream.io.binary.Token.readFrom.

writeToback to summary
public void writeTo(DataOutput out, byte idType) throws IOException

Implements abstract com.thoughtworks.xstream.io.binary.Token.writeTo.

com.thoughtworks.xstream.io.binary back to summary

public Class Token.StartNode

extends Token
Class Inheritance

Field Summary

Inherited from com.thoughtworks.xstream.io.binary.Token:
idTYPE_ATTRIBUTETYPE_END_NODETYPE_MAP_ID_TO_VALUETYPE_START_NODETYPE_VALUETYPE_VERSIONvalue

Constructor Summary

AccessConstructor and Description
public
StartNode(long id)

public

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from com.thoughtworks.xstream.io.binary.Token:
equalsgetIdgetTypegetValuehashCodereadIdreadStringtoStringwriteIdwriteString

Constructor Detail

StartNodeback to summary
public StartNode(long id)
StartNodeback to summary
public StartNode()

Method Detail

readFromback to summary
public void readFrom(DataInput in, byte idType) throws IOException

Implements abstract com.thoughtworks.xstream.io.binary.Token.readFrom.

writeToback to summary
public void writeTo(DataOutput out, byte idType) throws IOException

Implements abstract com.thoughtworks.xstream.io.binary.Token.writeTo.

com.thoughtworks.xstream.io.binary back to summary

public Class Token.Value

extends Token
Class Inheritance

Field Summary

Inherited from com.thoughtworks.xstream.io.binary.Token:
idTYPE_ATTRIBUTETYPE_END_NODETYPE_MAP_ID_TO_VALUETYPE_START_NODETYPE_VALUETYPE_VERSIONvalue

Constructor Summary

AccessConstructor and Description
public
Value(String value)

public

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from com.thoughtworks.xstream.io.binary.Token:
equalsgetIdgetTypegetValuehashCodereadIdreadStringtoStringwriteIdwriteString

Constructor Detail

Valueback to summary
public Value(String value)
Valueback to summary
public Value()

Method Detail

readFromback to summary
public void readFrom(DataInput in, byte idType) throws IOException

Implements abstract com.thoughtworks.xstream.io.binary.Token.readFrom.

writeToback to summary
public void writeTo(DataOutput out, byte idType) throws IOException

Implements abstract com.thoughtworks.xstream.io.binary.Token.writeTo.