Class BytesCodec

java.lang.Object
org.fusesource.hawtbuf.codec.BytesCodec
All Implemented Interfaces:
Codec<byte[]>

public class BytesCodec extends Object implements Codec<byte[]>
Implementation of a Marshaller for byte arrays
  • Field Details

    • INSTANCE

      public static final BytesCodec INSTANCE
  • Constructor Details

    • BytesCodec

      public BytesCodec()
  • Method Details

    • encode

      public void encode(byte[] data, DataOutput dataOut) throws IOException
      Description copied from interface: Codec
      Write the payload of the object to the DataOutput stream.
      Specified by:
      encode in interface Codec<byte[]>
      Parameters:
      data -
      dataOut -
      Throws:
      IOException
    • decode

      public byte[] decode(DataInput dataIn) throws IOException
      Description copied from interface: Codec
      Read the payload of the object from the DataInput stream.
      Specified by:
      decode in interface Codec<byte[]>
      Parameters:
      dataIn -
      Returns:
      unmarshalled object
      Throws:
      IOException
    • getFixedSize

      public int getFixedSize()
      Specified by:
      getFixedSize in interface Codec<byte[]>
      Returns:
      -1 if the object do not always marshall to a fixed size, otherwise return that fixed size.
    • deepCopy

      public byte[] deepCopy(byte[] source)
      Specified by:
      deepCopy in interface Codec<byte[]>
      Returns:
      a deep copy of the source object. If the source is immutable the same source should be returned.
    • isDeepCopySupported

      public boolean isDeepCopySupported()
      Specified by:
      isDeepCopySupported in interface Codec<byte[]>
      Returns:
      true if the Codec.deepCopy(Object) operations is supported.
    • isEstimatedSizeSupported

      public boolean isEstimatedSizeSupported()
      Specified by:
      isEstimatedSizeSupported in interface Codec<byte[]>
      Returns:
      true if the Codec.estimatedSize(Object) operation is supported.
    • estimatedSize

      public int estimatedSize(byte[] object)
      Specified by:
      estimatedSize in interface Codec<byte[]>
      Parameters:
      object -
      Returns:
      the estimated marshaled size of the object.