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.ObjectRepresents the Tokens stored in the binary stream used byBinaryStreamReaderandBinaryStreamWriter.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
- See Also:
BinaryStreamReader,BinaryStreamWriter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classToken.Attributestatic classToken.EndNodestatic classToken.Formatterstatic classToken.MapIdToValuestatic classToken.StartNodestatic classToken.Value
-
Field Summary
Fields Modifier and Type Field Description protected longidprivate static byteID_EIGHT_BYTESprivate static byteID_FOUR_BYTESprivate static byteID_MASKprivate static byteID_ONE_BYTEprivate static java.lang.StringID_SPLITTEDprivate static byteID_TWO_BYTESprivate static intMAX_UTF8_LENGTHprivate bytetypestatic byteTYPE_ATTRIBUTEstatic byteTYPE_END_NODEstatic byteTYPE_MAP_ID_TO_VALUEprivate static byteTYPE_MASKstatic byteTYPE_START_NODEstatic byteTYPE_VALUEstatic byteTYPE_VERSIONprotected java.lang.Stringvalue
-
Constructor Summary
Constructors Constructor Description Token(byte type)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)longgetId()bytegetType()java.lang.StringgetValue()inthashCode()abstract voidreadFrom(java.io.DataInput in, byte idType)protected longreadId(java.io.DataInput in, byte idType)protected java.lang.StringreadString(java.io.DataInput in)java.lang.StringtoString()protected voidwriteId(java.io.DataOutput out, long id, byte idType)protected voidwriteString(java.io.DataOutput out, java.lang.String string)abstract voidwriteTo(java.io.DataOutput out, byte idType)
-
-
-
Field Detail
-
TYPE_MASK
private static final byte TYPE_MASK
- See Also:
- Constant Field Values
-
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_MASK
private static final byte ID_MASK
- See Also:
- Constant Field Values
-
ID_ONE_BYTE
private static final byte ID_ONE_BYTE
- See Also:
- Constant Field Values
-
ID_TWO_BYTES
private static final byte ID_TWO_BYTES
- See Also:
- Constant Field Values
-
ID_FOUR_BYTES
private static final byte ID_FOUR_BYTES
- See Also:
- Constant Field Values
-
ID_EIGHT_BYTES
private static final byte ID_EIGHT_BYTES
- See Also:
- Constant Field Values
-
ID_SPLITTED
private static final java.lang.String ID_SPLITTED
- See Also:
- Constant Field Values
-
MAX_UTF8_LENGTH
private static final int MAX_UTF8_LENGTH
- See Also:
- Constant Field Values
-
type
private final byte type
-
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:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein 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
-
-