Interface BinaryDataType
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 Summary
Modifier and TypeMethodDescriptionReturns support for binary deltas.<T> TCreate a value of a compatible class from binary.<T> TCreate a value of a compatible class from a binary.<T> TCreate a value of a compatible class from binary.readValue(byte[] bytes) Create a value from binary.readValue(byte[] bytes, int offset, int length) Create a value from binary.Create a value from binary.Methods inherited from interface com.pushtechnology.diffusion.datatype.DataType
canReadAs, deltaType, deltaType, getTypeName, serializedBinaryDeltaType, toBytes, validate, validate, writeValue
-
Method Details
-
binaryDeltaType
DeltaType<Binary,BinaryDelta> binaryDeltaType()Returns support for binary deltas.Equivalent to calling
deltaType(BinaryDelta.class).- Specified by:
binaryDeltaTypein interfaceDataType<Binary>- Returns:
- the delta type, or null if none
-
readValue
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:
readValuein interfaceDataType<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 byteslength- length of the data within bytes- Throws:
IndexOutOfBoundsException- if eitheroffsetorlengthis negative, oroffset + length > bytes.length
-
readValue
Create a value from binary. Equivalent toreadValue(in, 0, in.length).There are no invalid Binary instances, so this method does not throw
InvalidDataException. -
readValue
Create a value from binary. Equivalent toreadValue(bytes.toByteArray()).There are no invalid Binary instances, so this method does not throw
InvalidDataException. -
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
valueTypeis incompatible with this data type, this method will throw an IllegalArgumentException. Compatibility can be tested withDataType.canReadAs(Class).There are no invalid Binary instances, so this method does not throw
InvalidDataException.- Specified by:
readAsin interfaceDataType<Binary>- Type Parameters:
T- type ofclassOfT- Parameters:
classOfT- the type of the resultbytes- 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 byteslength- length of the data within bytes- Throws:
IllegalArgumentException- ifclassOfTis incompatible with this data typeIndexOutOfBoundsException- if eitheroffsetorlengthis negative, oroffset + length > bytes.length
-
readAs
Create a value of a compatible class from binary. Equivalent toreadAs(classOfT, in, 0, in.length).There are no invalid Binary instances, so this method does not throw
InvalidDataException.- Specified by:
readAsin interfaceDataType<Binary>- Type Parameters:
T- type ofclassOfT- Parameters:
classOfT- the type of the resultbytes- 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- ifclassOfTis incompatible with this data type
-
readAs
Create a value of a compatible class from binary. Equivalent toreadAs(classOfT, bytes.toByteArray()).There are no invalid Binary instances, so this method does not throw
InvalidDataException.- Specified by:
readAsin interfaceDataType<Binary>- Type Parameters:
T- type ofclassOfT- Parameters:
classOfT- the type of the resultbytes- the binary data- Throws:
IllegalArgumentException- ifclassOfTis incompatible with this data type
-