java.lang.Object
org.refcodes.serial.AbstractMagicBytesTransmission
- All Implemented Interfaces:
Serializable
,org.refcodes.mixin.AliasAccessor
,org.refcodes.mixin.EncodingAccessor<Charset>
,org.refcodes.mixin.LengthAccessor
,org.refcodes.mixin.MagicBytesAccessor
,org.refcodes.mixin.MagicBytesAccessor.MagicBytesMutator
,org.refcodes.mixin.MagicBytesAccessor.MagicBytesProperty
,org.refcodes.mixin.PayloadAccessor<byte[]>
,org.refcodes.mixin.PayloadAccessor.PayloadBuilder<byte[],
,PayloadTransmission<byte[]>> org.refcodes.mixin.PayloadAccessor.PayloadMutator<byte[]>
,org.refcodes.mixin.PayloadAccessor.PayloadProperty<byte[]>
,org.refcodes.mixin.Schemable<SerialSchema>
,MagicBytesAccessor
,MagicBytesAccessor.MagicBytesMutator
,MagicBytesAccessor.MagicBytesProperty
,MagicBytesLengthAccessor
,PayloadTransmission<byte[]>
,Transmission
,Transmission.TransmissionMixin
- Direct Known Subclasses:
AbstractMagicBytesTransmissionDecorator
,MagicBytesSegment
public abstract class AbstractMagicBytesTransmission
extends Object
implements PayloadTransmission<byte[]>, Transmission.TransmissionMixin, MagicBytesAccessor.MagicBytesProperty, MagicBytesLengthAccessor, org.refcodes.mixin.EncodingAccessor<Charset>
Magic bytes are usually found (somewhere) at the beginning of a file or a
stream. A
AbstractMagicBytesTransmission
provides the base
functionality to manage magic bytes.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor
org.refcodes.mixin.AliasAccessor.AliasBuilder<B extends org.refcodes.mixin.AliasAccessor.AliasBuilder<B>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.EncodingAccessor
org.refcodes.mixin.EncodingAccessor.EncodingBuilder<E extends Object,
B extends org.refcodes.mixin.EncodingAccessor.EncodingBuilder<E, B>>, org.refcodes.mixin.EncodingAccessor.EncodingMutator<E extends Object>, org.refcodes.mixin.EncodingAccessor.EncodingProperty<E extends Object> Nested classes/interfaces inherited from interface org.refcodes.mixin.LengthAccessor
org.refcodes.mixin.LengthAccessor.LengthBuilder<B extends org.refcodes.mixin.LengthAccessor.LengthBuilder<B>>, org.refcodes.mixin.LengthAccessor.LengthMutator, org.refcodes.mixin.LengthAccessor.LengthProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.MagicBytesAccessor
org.refcodes.mixin.MagicBytesAccessor.MagicBytesBuilder<B extends org.refcodes.mixin.MagicBytesAccessor.MagicBytesBuilder<B>>, org.refcodes.mixin.MagicBytesAccessor.MagicBytesMutator, org.refcodes.mixin.MagicBytesAccessor.MagicBytesProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.MagicBytesAccessor
MagicBytesAccessor.MagicBytesBuilder<B extends MagicBytesAccessor.MagicBytesBuilder<B>>, MagicBytesAccessor.MagicBytesMutator, MagicBytesAccessor.MagicBytesProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.MagicBytesLengthAccessor
MagicBytesLengthAccessor.MagicBytesLengthBuilder<B extends MagicBytesLengthAccessor.MagicBytesLengthBuilder<B>>, MagicBytesLengthAccessor.MagicBytesLengthMutator, MagicBytesLengthAccessor.MagicBytesLengthProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.PayloadAccessor
org.refcodes.mixin.PayloadAccessor.PayloadBuilder<P extends Object,
B extends org.refcodes.mixin.PayloadAccessor.PayloadBuilder<P, B>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<P extends Object>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<P extends Object> Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin
-
Field Summary
-
Constructor Summary
ConstructorDescriptionAbstractMagicBytesTransmission
(String aAlias, byte[] aMagicBytes) Constructs anAbstractMagicBytesTransmission
with the according magic bytes.AbstractMagicBytesTransmission
(String aAlias, byte[] aMagicBytes, TransmissionMetrics aTransmissionMetrics) Constructs an according instance for magic bytes of the given length.AbstractMagicBytesTransmission
(String aAlias, int aMagicBytesLength) Constructs anAbstractMagicBytesTransmission
for magic bytes of the given length.AbstractMagicBytesTransmission
(String aAlias, String aMagicBytes) Constructs anAbstractMagicBytesTransmission
with the according magic bytes (retrieved from the givenString
).AbstractMagicBytesTransmission
(String aAlias, String aMagicBytes, Charset aCharset) Constructs anAbstractMagicBytesTransmission
with the according magic bytes (retrieved from the givenString
).AbstractMagicBytesTransmission
(String aAlias, String aMagicBytes, TransmissionMetrics aTransmissionMetrics) Constructs an according instance for magic bytes of the given length.AbstractMagicBytesTransmission
(String aAlias, TransmissionMetrics aTransmissionMetrics) Constructs an according instance for magic bytes of the given length. -
Method Summary
Modifier and TypeMethodDescriptionboolean
getAlias()
byte[]
Returns the magic bytes as stored by this instance.int
Retrieves the magic bytes length from the magic bytes magic bytes length property.byte[]
Returns the magic bytes as ofgetMagicBytes()
.int
hashCode()
void
setMagicBytes
(byte[] aMagicBytes) Sets the magic bytes to be stored by this instance.void
setMagicBytes
(String aMagicBytes) Sets the magic bytes from the providedString
to be stored by this instance (uses theTransmissionMetrics.DEFAULT_ENCODING
) for byte conversion).void
setMagicBytes
(String aMagicBytes, Charset aCharset) Sets the magic bytes from the providedString
to be stored by this instance.void
setPayload
(byte[] aValue) Sets the magic bytes as ofsetMagicBytes(byte[])
.Retrieves theString
representation of the given magic bytes using the latest providedCharset
for conversion or theTransmissionMetrics.DEFAULT_ENCODING
in case noCharset
has been provided.toMagicBytesString
(String aCharset) Retrieves theString
representation of the given magic bytes using the providedCharset
for conversion or theTransmissionMetrics.DEFAULT_ENCODING
in case noCharset
has been provided.toSchema()
Retrieves theSerialSchema
representing theTransmission
.Provides theSequence
representation of thisTransmission
.org.refcodes.struct.SimpleTypeMap
Returns theSimpleTypeMap
representation of thisTransmission
.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.serial.MagicBytesAccessor
toMagicBytes, toMagicBytes
Methods inherited from interface org.refcodes.mixin.MagicBytesAccessor.MagicBytesProperty
letMagicBytes, letMagicBytes
Methods inherited from interface org.refcodes.serial.MagicBytesAccessor.MagicBytesProperty
letMagicBytes
Methods inherited from interface org.refcodes.mixin.PayloadAccessor
getPayloadOr
Methods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadBuilder
withPayload
Methods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadProperty
letPayload
Methods inherited from interface org.refcodes.serial.Transmission
getLength, transmitTo, transmitTo
Methods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitTo
-
Field Details
-
MAGIC_BYTES
- See Also:
-
MAGIC_BYTES_TEXT
- See Also:
-
_magicBytes
protected byte[] _magicBytes -
_magicBytesLength
protected int _magicBytesLength -
_charset
-
_alias
-
-
Constructor Details
-
AbstractMagicBytesTransmission
Constructs an according instance for magic bytes of the given length. The configuration attributes are taken from theTransmissionMetrics
configuration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aAlias
- The alias which identifies the content of this segment.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.
-
AbstractMagicBytesTransmission
public AbstractMagicBytesTransmission(String aAlias, String aMagicBytes, TransmissionMetrics aTransmissionMetrics) Constructs an according instance for magic bytes of the given length. The configuration attributes are taken from theTransmissionMetrics
configuration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aAlias
- The alias which identifies the content of this segment.aMagicBytes
- TheString
to be stored by this instance as magic bytes.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.
-
AbstractMagicBytesTransmission
public AbstractMagicBytesTransmission(String aAlias, byte[] aMagicBytes, TransmissionMetrics aTransmissionMetrics) Constructs an according instance for magic bytes of the given length. The configuration attributes are taken from theTransmissionMetrics
configuration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aAlias
- The alias which identifies the content of this segment.aMagicBytes
- The bytes to be stored by this instance as magic bytes.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.
-
AbstractMagicBytesTransmission
Constructs anAbstractMagicBytesTransmission
for magic bytes of the given length.- Parameters:
aAlias
- The alias which identifies the content of this segment.aMagicBytesLength
- The length of the magic bytes sequence.
-
AbstractMagicBytesTransmission
Constructs anAbstractMagicBytesTransmission
with the according magic bytes (retrieved from the givenString
).- Parameters:
aAlias
- The alias which identifies the content of this segment.aMagicBytes
- TheString
to be stored by this instance as magic bytes (uses theTransmissionMetrics.DEFAULT_ENCODING
) for byte conversion).
-
AbstractMagicBytesTransmission
Constructs anAbstractMagicBytesTransmission
with the according magic bytes (retrieved from the givenString
). -
AbstractMagicBytesTransmission
Constructs anAbstractMagicBytesTransmission
with the according magic bytes.- Parameters:
aAlias
- The alias which identifies the content of this segment.aMagicBytes
- The magic bytes to be stored by this instance.
-
-
Method Details
-
setPayload
public void setPayload(byte[] aValue) Sets the magic bytes as ofsetMagicBytes(byte[])
.- Specified by:
setPayload
in interfaceorg.refcodes.mixin.PayloadAccessor.PayloadMutator<byte[]>
-
getAlias
- Specified by:
getAlias
in interfaceorg.refcodes.mixin.AliasAccessor
-
getMagicBytes
public byte[] getMagicBytes()Returns the magic bytes as stored by this instance.- Specified by:
getMagicBytes
in interfaceorg.refcodes.mixin.MagicBytesAccessor
- Returns:
- The according magic bytes.
-
setMagicBytes
public void setMagicBytes(byte[] aMagicBytes) Sets the magic bytes to be stored by this instance.- Specified by:
setMagicBytes
in interfaceorg.refcodes.mixin.MagicBytesAccessor.MagicBytesMutator
- Parameters:
aMagicBytes
- The according magic bytes to store.
-
setMagicBytes
Sets the magic bytes from the providedString
to be stored by this instance (uses theTransmissionMetrics.DEFAULT_ENCODING
) for byte conversion).- Specified by:
setMagicBytes
in interfaceorg.refcodes.mixin.MagicBytesAccessor.MagicBytesMutator
- Specified by:
setMagicBytes
in interfaceMagicBytesAccessor.MagicBytesMutator
- Parameters:
aMagicBytes
- The String from which to copy the according magic bytes from.
-
setMagicBytes
Sets the magic bytes from the providedString
to be stored by this instance. -
toMagicBytesString
Retrieves theString
representation of the given magic bytes using the latest providedCharset
for conversion or theTransmissionMetrics.DEFAULT_ENCODING
in case noCharset
has been provided.- Returns:
- The
String
representation of the magic bytes.
-
toMagicBytesString
Retrieves theString
representation of the given magic bytes using the providedCharset
for conversion or theTransmissionMetrics.DEFAULT_ENCODING
in case noCharset
has been provided. -
toSequence
Provides theSequence
representation of thisTransmission
. In case of nestedTransmission
instances, allSequence
representations from all sub-segments are accumulated to the result as well. Caution, the Transmission (or its nestedTransmission
instances) may be backed by the returnedSequence
.- Specified by:
toSequence
in interfaceTransmission
- Returns:
- The according instance's
Sequence
.
-
getMagicBytesLength
public int getMagicBytesLength()Retrieves the magic bytes length from the magic bytes magic bytes length property.- Specified by:
getMagicBytesLength
in interfaceMagicBytesLengthAccessor
- Returns:
- The magic bytes length stored by the magic bytes magic bytes length property.
-
getPayload
public byte[] getPayload()Returns the magic bytes as ofgetMagicBytes()
.- Specified by:
getPayload
in interfaceorg.refcodes.mixin.PayloadAccessor<byte[]>
-
toSchema
Retrieves theSerialSchema
representing theTransmission
. Retrieving aSerialSchema
is useful when analyzing and debugging data structures such as aAllocSectionDecoratorSegment
instance to help document, learn and verify on the structure (as well as the content) of that veryAllocSectionDecoratorSegment
.- Specified by:
toSchema
in interfaceorg.refcodes.mixin.Schemable<SerialSchema>
- Specified by:
toSchema
in interfaceTransmission
- Returns:
- The
SerialSchema
representation of the implementing type for debugging and verification (or documentation) purposes.
-
getEncoding
- Specified by:
getEncoding
in interfaceorg.refcodes.mixin.EncodingAccessor<Charset>
-
toString
-
hashCode
public int hashCode() -
equals
-
toSimpleTypeMap
public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()Returns theSimpleTypeMap
representation of thisTransmission
. In case this Transmission hasTransmission
children, then the children are queried as well and contained in the resultingSimpleTypeMap
. The aliases of the accordingTransmission
instances represent the resulting path to aTransmission
's final simple type.- Specified by:
toSimpleTypeMap
in interfaceTransmission
- Returns:
- The
SimpleTypeMap
representing thisTransmission
and (if any) its children, with the according aliases forming the paths to theTransmission
's values.
-