Class Token
- java.lang.Object
-
- com.thoughtworks.xstream.io.binary.Token
-
- Direct Known Subclasses:
Token.Attribute
,Token.EndNode
,Token.MapIdToValue
,Token.StartNode
,Token.Value
public abstract class Token extends java.lang.Object
Represents the Tokens stored in the binary stream used byBinaryStreamReader
andBinaryStreamWriter
.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
Nested Classes Modifier and Type Class Description 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
Fields Modifier and Type Field Description 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 java.lang.String
value
-
Constructor Summary
Constructors Constructor Description Token(byte type)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
long
getId()
byte
getType()
java.lang.String
getValue()
int
hashCode()
abstract void
readFrom(java.io.DataInput in, byte idType)
protected long
readId(java.io.DataInput in, byte idType)
protected java.lang.String
readString(java.io.DataInput in)
java.lang.String
toString()
protected void
writeId(java.io.DataOutput out, long id, byte idType)
protected void
writeString(java.io.DataOutput out, java.lang.String string)
abstract void
writeTo(java.io.DataOutput out, byte idType)
-
-
-
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 java.lang.String value
-
-
Method Detail
-
getType
public byte getType()
-
getId
public long getId()
-
getValue
public java.lang.String getValue()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
writeTo
public abstract void writeTo(java.io.DataOutput out, byte idType) throws java.io.IOException
- Throws:
java.io.IOException
-
readFrom
public abstract void readFrom(java.io.DataInput in, byte idType) throws java.io.IOException
- Throws:
java.io.IOException
-
writeId
protected void writeId(java.io.DataOutput out, long id, byte idType) throws java.io.IOException
- Throws:
java.io.IOException
-
writeString
protected void writeString(java.io.DataOutput out, java.lang.String string) throws java.io.IOException
- Throws:
java.io.IOException
-
readId
protected long readId(java.io.DataInput in, byte idType) throws java.io.IOException
- Throws:
java.io.IOException
-
readString
protected java.lang.String readString(java.io.DataInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
-