Class Token.TokenFactory

  • Enclosing class:
    Token

    public abstract static class Token.TokenFactory
    extends java.lang.Object
    • Constructor Detail

      • TokenFactory

        public TokenFactory()
    • Method Detail

      • toByteArray

        public abstract java.nio.ByteBuffer toByteArray​(Token token)
      • fromByteArray

        public abstract Token fromByteArray​(java.nio.ByteBuffer bytes)
      • 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, an IllegalArgumentException 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 call Token.asComparableBytes(ByteComparable.Version) on the returned object, we should get a ByteSource 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)
      • 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)