Interface BinaryDataType

All Superinterfaces:
DataType<Binary>

public interface BinaryDataType extends DataType<Binary>
Binary data type.

Binary values can be used to store and transmit arbitrary information. The responsibility for formatting and interpreting the information belongs solely to the application. Before using Binary for a topic, consider other data types such as JSON; these may provide a simpler interface for your application.

The implementation provides support for binary deltas.

Since:
5.7
Author:
DiffusionData Limited
See Also:
  • Method Details

    • binaryDeltaType

      DeltaType<Binary,BinaryDelta> binaryDeltaType()
      Returns support for binary deltas.

      Equivalent to calling deltaType(BinaryDelta.class).

      Specified by:
      binaryDeltaType in interface DataType<Binary>
      Returns:
      the delta type, or null if none
    • readValue

      Binary readValue(byte[] bytes, int offset, int length) throws IndexOutOfBoundsException
      Create a value from binary.

      Implementations can choose not to fully validate values when they are read, but instead defer parsing until it is required. See DataType.validate(Object).

      There are no invalid Binary instances, so this method does not throw InvalidDataException.

      Specified by:
      readValue in interface DataType<Binary>
      Parameters:
      bytes - The binary data. The implementation may re-use the array to avoid copying so the caller must ensure the array is not modified.
      offset - start of the data within bytes
      length - length of the data within bytes
      Throws:
      IndexOutOfBoundsException - if either offset or length is negative, or offset + length > bytes.length
    • readValue

      Binary readValue(byte[] bytes)
      Create a value from binary. Equivalent to readValue(in, 0, in.length).

      There are no invalid Binary instances, so this method does not throw InvalidDataException.

      Specified by:
      readValue in interface DataType<Binary>
      Parameters:
      bytes - The binary data. The implementation may re-use the array to avoid copying so the caller must ensure the array is not modified.
    • readValue

      Binary readValue(Bytes bytes)
      Create a value from binary. Equivalent to readValue(bytes.toByteArray()).

      There are no invalid Binary instances, so this method does not throw InvalidDataException.

      Specified by:
      readValue in interface DataType<Binary>
      Parameters:
      bytes - the binary data
    • readAs

      <T> T readAs(Class<T> classOfT, byte[] bytes, int offset, int length) throws IllegalArgumentException, IndexOutOfBoundsException
      Create a value of a compatible class from a binary.

      If valueType is incompatible with this data type, this method will throw an IllegalArgumentException. Compatibility can be tested with DataType.canReadAs(Class).

      There are no invalid Binary instances, so this method does not throw InvalidDataException.

      Specified by:
      readAs in interface DataType<Binary>
      Type Parameters:
      T - type of classOfT
      Parameters:
      classOfT - the type of the result
      bytes - The binary data. The implementation may re-use the array to avoid copying so the caller must ensure the array is not modified.
      offset - start of the data within bytes
      length - length of the data within bytes
      Throws:
      IllegalArgumentException - if classOfT is incompatible with this data type
      IndexOutOfBoundsException - if either offset or length is negative, or offset + length > bytes.length
    • readAs

      <T> T readAs(Class<T> classOfT, byte[] bytes) throws IllegalArgumentException
      Create a value of a compatible class from binary. Equivalent to readAs(classOfT, in, 0, in.length).

      There are no invalid Binary instances, so this method does not throw InvalidDataException.

      Specified by:
      readAs in interface DataType<Binary>
      Type Parameters:
      T - type of classOfT
      Parameters:
      classOfT - the type of the result
      bytes - The binary data. The implementation may re-use the array to avoid copying so the caller must ensure the array is not modified.
      Throws:
      IllegalArgumentException - if classOfT is incompatible with this data type
    • readAs

      <T> T readAs(Class<T> classOfT, Bytes bytes) throws IllegalArgumentException
      Create a value of a compatible class from binary. Equivalent to readAs(classOfT, bytes.toByteArray()).

      There are no invalid Binary instances, so this method does not throw InvalidDataException.

      Specified by:
      readAs in interface DataType<Binary>
      Type Parameters:
      T - type of classOfT
      Parameters:
      classOfT - the type of the result
      bytes - the binary data
      Throws:
      IllegalArgumentException - if classOfT is incompatible with this data type