Class TypeCodec.PrimitiveByteCodec

  • Enclosing class:
    TypeCodec<T>

    public abstract static class TypeCodec.PrimitiveByteCodec
    extends TypeCodec<java.lang.Byte>
    A codec that is capable of handling primitive bytes, thus avoiding the overhead of boxing and unboxing such primitives.
    • Method Detail

      • serializeNoBoxing

        public abstract java.nio.ByteBuffer serializeNoBoxing​(byte v,
                                                              ProtocolVersion protocolVersion)
      • deserializeNoBoxing

        public abstract byte deserializeNoBoxing​(java.nio.ByteBuffer v,
                                                 ProtocolVersion protocolVersion)
      • serialize

        public java.nio.ByteBuffer serialize​(java.lang.Byte value,
                                             ProtocolVersion protocolVersion)
        Description copied from class: TypeCodec
        Serialize the given value according to the CQL type handled by this codec.

        Implementation notes:

        1. Null values should be gracefully handled and no exception should be raised; these should be considered as the equivalent of a NULL CQL value;
        2. Codecs for CQL collection types should not permit null elements;
        3. Codecs for CQL collection types should treat a null input as the equivalent of an empty collection.
        Specified by:
        serialize in class TypeCodec<java.lang.Byte>
        Parameters:
        value - An instance of T; may be null.
        protocolVersion - the protocol version to use when serializing bytes. In most cases, the proper value to provide for this argument is the value returned by ProtocolOptions#getProtocolVersion (which is the protocol version in use by the driver).
        Returns:
        A ByteBuffer instance containing the serialized form of T
      • deserialize

        public java.lang.Byte deserialize​(java.nio.ByteBuffer bytes,
                                          ProtocolVersion protocolVersion)
        Description copied from class: TypeCodec
        Deserialize the given ByteBuffer instance according to the CQL type handled by this codec.

        Implementation notes:

        1. Null or empty buffers should be gracefully handled and no exception should be raised; these should be considered as the equivalent of a NULL CQL value and, in most cases, should map to null or a default value for the corresponding Java type, if applicable;
        2. Codecs for CQL collection types should clearly document whether they return immutable collections or not (note that the driver's default collection codecs return mutable collections);
        3. Codecs for CQL collection types should avoid returning null; they should return empty collections instead (the driver's default collection codecs all comply with this rule).
        4. The provided ByteBuffer should never be consumed by read operations that modify its current position; if necessary, ByteBuffer.duplicate() duplicate} it before consuming.
        Specified by:
        deserialize in class TypeCodec<java.lang.Byte>
        Parameters:
        bytes - A ByteBuffer instance containing the serialized form of T; may be null or empty.
        protocolVersion - the protocol version to use when serializing bytes. In most cases, the proper value to provide for this argument is the value returned by ProtocolOptions#getProtocolVersion (which is the protocol version in use by the driver).
        Returns:
        An instance of T