Class CodecUtils


  • public final class CodecUtils
    extends java.lang.Object
    A set of utility methods to deal with type conversion and serialization.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.nio.ByteBuffer pack​(java.nio.ByteBuffer[] buffers, int elements, ProtocolVersion version)
      Utility method that "packs" together a list of ByteBuffers containing serialized collection elements.
      static java.nio.ByteBuffer readBytes​(java.nio.ByteBuffer bb, int length)
      Read length bytes from bb into a new ByteBuffer.
      static java.nio.ByteBuffer readValue​(java.nio.ByteBuffer input, ProtocolVersion version)
      Utility method that reads a value.
      static void writeValue​(java.nio.ByteBuffer output, java.nio.ByteBuffer value, ProtocolVersion version)
      Utility method that writes a value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • pack

        public static java.nio.ByteBuffer pack​(java.nio.ByteBuffer[] buffers,
                                               int elements,
                                               ProtocolVersion version)
        Utility method that "packs" together a list of ByteBuffers containing serialized collection elements. Mainly intended for use with collection codecs when serializing collections.
        Parameters:
        buffers - the collection elements
        elements - the total number of elements
        version - the protocol version to use
        Returns:
        The serialized collection
      • readValue

        public static java.nio.ByteBuffer readValue​(java.nio.ByteBuffer input,
                                                    ProtocolVersion version)
        Utility method that reads a value. Mainly intended for collection codecs when deserializing CQL collections.
        Parameters:
        input - The ByteBuffer to read from.
        version - The protocol version to use.
        Returns:
        The collection element.
      • writeValue

        public static void writeValue​(java.nio.ByteBuffer output,
                                      java.nio.ByteBuffer value,
                                      ProtocolVersion version)
        Utility method that writes a value. Mainly intended for collection codecs when deserializing CQL collections.
        Parameters:
        output - The ByteBuffer to write to.
        value - The value to write.
        version - The protocol version to use.
      • readBytes

        public static java.nio.ByteBuffer readBytes​(java.nio.ByteBuffer bb,
                                                    int length)
        Read length bytes from bb into a new ByteBuffer.
        Parameters:
        bb - The ByteBuffer to read.
        length - The number of bytes to read.
        Returns:
        The read bytes.