public final class BinaryVectorDescriptorSerializer extends Object implements DescriptorSerializer<BinaryVectorDescriptor>
BinaryVectorDescriptor
.
The serialized representation is BinaryVectorDescriptorImpl
.Guarded.EnsureThat, Guarded.New
Constructor and Description |
---|
BinaryVectorDescriptorSerializer(Object guardObject,
int size,
BinaryVectors.Endianness endianness)
Construct.
|
Modifier and Type | Method and Description |
---|---|
BinaryVectorDescriptor |
fromByteArray(byte[] desc)
Builds a descriptor from its byte array representation.
|
BinaryVectorDescriptor |
fromString(String desc)
Builds a descriptor from its string representation.
|
Object |
getGuardObject()
Gets the guard object associated to the generated descriptors/utilities.
|
boolean |
serializerIsEqualWith(DescriptorSerializer other)
Check strict equivalence of serializers.
|
byte[] |
toByteArray(BinaryVectorDescriptor desc)
Creates the byte array representation of a descriptor object.
|
String |
toString(BinaryVectorDescriptor desc)
Creates the String representation of a descriptor object.
|
public BinaryVectorDescriptorSerializer(Object guardObject, int size, BinaryVectors.Endianness endianness)
External API contracts: guarding must ensure that this instance is fed with
BinaryVectorDescriptorImpl
instances with matching size
and BinaryVectors.Endianness
parameter.
guardObject
- Associated guard objects.size
- Associated sizeendianness
- Endianness parameter of underlying BinaryVectorDescriptorImpl
constructors.public byte[] toByteArray(BinaryVectorDescriptor desc)
DescriptorSerializer
The descriptors bare form can be reconstructed using DescriptorSerializer.fromByteArray(byte[])
.
toByteArray
in interface DescriptorSerializer<BinaryVectorDescriptor>
desc
- Descriptor (only bare form is considered)public String toString(BinaryVectorDescriptor desc)
DescriptorSerializer
The descriptors bare form can be reconstructed using DescriptorSerializer.fromString(java.lang.String)
.
toString
in interface DescriptorSerializer<BinaryVectorDescriptor>
desc
- Descriptor (only bare form is considered)public BinaryVectorDescriptor fromString(String desc)
DescriptorSerializer
Please note that the compatibility of this (the reconstructing) DescriptorGenerator
, regarding to the
serializing generator (on which DescriptorSerializer.toString(com.chemaxon.descriptors.common.Descriptor)
was called to construct the String form) is not checked; compatibility must be ensured by the user application.
fromString
in interface DescriptorSerializer<BinaryVectorDescriptor>
desc
- String representationpublic BinaryVectorDescriptor fromByteArray(byte[] desc)
DescriptorSerializer
Please note that the compatibility of this (the reconstructing) DescriptorGenerator
, regarding to the
serializing generator (on which
DescriptorSerializer.toByteArray(com.chemaxon.descriptors.common.Descriptor)
was called to construct the
byte array form) is not checked; compatibility must be ensured by the user application.
fromByteArray
in interface DescriptorSerializer<BinaryVectorDescriptor>
desc
- Byte array of the descriptorpublic Object getGuardObject()
Guarded
This method is intended to use only for ensuring the compatibility of manipulated objects.
Implementations might use the associated DescriptorGenerator
or DescriptorParameters
reference as
the guard object, however it is a non recommended practice to use this method to access the associated generator
to perform further operations on it.
getGuardObject
in interface Guarded
null
.public boolean serializerIsEqualWith(DescriptorSerializer other)
DescriptorSerializer
serializerIsEqualWith
in interface DescriptorSerializer<BinaryVectorDescriptor>
other
- Other serializertrue
when and only when the two serializers (this
and other
) are the same thus
interchangeable. Implementations typically check class equivalence, guard object match and parameter match.