Package org.apache.cassandra.dht
Class Token.TokenFactory
- java.lang.Object
-
- org.apache.cassandra.dht.Token.TokenFactory
-
- Enclosing class:
- Token
public abstract static class Token.TokenFactory extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description TokenFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ByteSource
asComparableBytes(Token token, ByteComparable.Version version)
Produce a byte-comparable representation of the token.int
byteSize(Token token)
abstract Token
fromByteArray(java.nio.ByteBuffer bytes)
Token
fromByteBuffer(java.nio.ByteBuffer bytes, int position, int length)
abstract Token
fromComparableBytes(ByteSource.Peekable comparableBytes, ByteComparable.Version version)
Translates the given byte-comparable representation to a token instance.abstract Token
fromString(java.lang.String string)
void
serialize(Token token, java.nio.ByteBuffer out)
void
serialize(Token token, DataOutputPlus out)
abstract java.nio.ByteBuffer
toByteArray(Token token)
abstract java.lang.String
toString(Token token)
abstract void
validate(java.lang.String token)
-
-
-
Method Detail
-
toByteArray
public abstract java.nio.ByteBuffer toByteArray(Token token)
-
fromByteArray
public abstract Token fromByteArray(java.nio.ByteBuffer bytes)
-
asComparableBytes
public ByteSource asComparableBytes(Token token, ByteComparable.Version version)
Produce a byte-comparable representation of the token. SeeToken.asComparableBytes(org.apache.cassandra.utils.bytecomparable.ByteComparable.Version)
-
fromComparableBytes
public abstract Token fromComparableBytes(ByteSource.Peekable comparableBytes, ByteComparable.Version version)
Translates the given byte-comparable representation to a token instance. If the given bytes don't correspond to the encoding of an instance of the expected token type, anIllegalArgumentException
may be thrown.- Parameters:
comparableBytes
- A byte-comparable representation (presumably of a token of some expected token type).- Returns:
- A new
Token
instance, corresponding to the given byte-ordered representation. If we were to callToken.asComparableBytes(ByteComparable.Version)
on the returned object, we should get aByteSource
equal to the input one as a result. - Throws:
java.lang.IllegalArgumentException
- if the bytes do not encode a valid token.
-
toString
public abstract java.lang.String toString(Token token)
-
fromString
public abstract Token fromString(java.lang.String string)
-
validate
public abstract void validate(java.lang.String token) throws ConfigurationException
- Throws:
ConfigurationException
-
serialize
public void serialize(Token token, DataOutputPlus out) throws java.io.IOException
- Throws:
java.io.IOException
-
serialize
public void serialize(Token token, java.nio.ByteBuffer out) throws java.io.IOException
- Throws:
java.io.IOException
-
fromByteBuffer
public Token fromByteBuffer(java.nio.ByteBuffer bytes, int position, int length)
-
byteSize
public int byteSize(Token token)
-
-