Module org.refcodes.serial
Package org.refcodes.serial
Class AbstractMagicBytesTransmissionDecorator<DECORATEE extends Transmission>
java.lang.Object
org.refcodes.serial.AbstractMagicBytesTransmission
org.refcodes.serial.AbstractMagicBytesTransmissionDecorator<DECORATEE>
- Type Parameters:
DECORATEE
- The decoratee type describing the decoratee subclass decoratee.
- All Implemented Interfaces:
Serializable
,org.refcodes.mixin.AliasAccessor
,org.refcodes.mixin.DecorateeAccessor<DECORATEE>
,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:
MagicBytesSectionDecorator
,MagicBytesSegmentDecorator
public abstract class AbstractMagicBytesTransmissionDecorator<DECORATEE extends Transmission>
extends AbstractMagicBytesTransmission
implements Transmission, org.refcodes.mixin.DecorateeAccessor<DECORATEE>
Magic bytes are usually found (somewhere) at the beginning of a file or a
stream. A
AbstractMagicBytesTransmissionDecorator
decorates a
decoratee decoratee and prefixes this decoratee instance with given 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.DecorateeAccessor
org.refcodes.mixin.DecorateeAccessor.DecorateeBuilder<DECORATEE extends Object,
B extends org.refcodes.mixin.DecorateeAccessor.DecorateeBuilder<DECORATEE, B>>, org.refcodes.mixin.DecorateeAccessor.DecorateeMutator<DECORATEE extends Object>, org.refcodes.mixin.DecorateeAccessor.DecorateeProperty<DECORATEE extends Object> 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
Fields inherited from class org.refcodes.serial.AbstractMagicBytesTransmission
_charset, _magicBytes, _magicBytesLength, MAGIC_BYTES, MAGIC_BYTES_TEXT
-
Constructor Summary
ConstructorDescriptionAbstractMagicBytesTransmissionDecorator
(String aAlias, DECORATEE aDecoratee, byte[] aMagicBytes) Enriches the provided decoratee with the given magic bytes being prefixed.AbstractMagicBytesTransmissionDecorator
(String aAlias, DECORATEE aDecoratee, int aMagicBytesLength) Enriches the provided decoratee with magic bytes of the given length to be prefixed.AbstractMagicBytesTransmissionDecorator
(String aAlias, DECORATEE aDecoratee, String aMagicBytes) Enriches the provided decoratee with magic bytes being prefixed (retrieved from the givenString
).AbstractMagicBytesTransmissionDecorator
(String aAlias, DECORATEE aDecoratee, String aMagicBytes, Charset aCharset) Enriches the provided decoratee with magic bytes being prefixed (retrieved from the givenString
).AbstractMagicBytesTransmissionDecorator
(String aAlias, DECORATEE aDecoratee, TransmissionMetrics aTransmissionMetrics) Enriches the provided decoratee with magic bytes of the given length to be prefixed. -
Method Summary
Modifier and TypeMethodDescriptionboolean
getAlias()
int
Determines the overall length of thisTransmission
.int
hashCode()
void
setPayload
(byte[] aValue) Sets the magic bytes as ofAbstractMagicBytesTransmission.setMagicBytes(byte[])
.toSchema()
Retrieves theSerialSchema
representing theTransmission
.Provides theSequence
representation of thisTransmission
.toString()
Methods inherited from class org.refcodes.serial.AbstractMagicBytesTransmission
getEncoding, getMagicBytes, getMagicBytesLength, getPayload, setMagicBytes, setMagicBytes, setMagicBytes, toMagicBytesString, toMagicBytesString, toSimpleTypeMap
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
toSimpleTypeMap, transmitTo, transmitTo
Methods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitTo
-
Field Details
-
_decoratee
-
_alias
-
-
Constructor Details
-
AbstractMagicBytesTransmissionDecorator
public AbstractMagicBytesTransmissionDecorator(String aAlias, DECORATEE aDecoratee, TransmissionMetrics aTransmissionMetrics) Enriches the provided decoratee with magic bytes of the given length to be prefixed. 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.aDecoratee
- The decoratee which to be prefixed with magic bytes.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.
-
AbstractMagicBytesTransmissionDecorator
public AbstractMagicBytesTransmissionDecorator(String aAlias, DECORATEE aDecoratee, int aMagicBytesLength) Enriches the provided decoratee with magic bytes of the given length to be prefixed.- Parameters:
aAlias
- The alias which identifies the content of this segment.aDecoratee
- The decoratee which to be prefixed with magic bytes.aMagicBytesLength
- The length of the magic bytes sequence.
-
AbstractMagicBytesTransmissionDecorator
public AbstractMagicBytesTransmissionDecorator(String aAlias, DECORATEE aDecoratee, String aMagicBytes) Enriches the provided decoratee with magic bytes being prefixed (retrieved from the givenString
).- Parameters:
aAlias
- The alias which identifies the content of this segment.aDecoratee
- The decoratee which to be prefixed with magic bytes.aMagicBytes
- TheString
to be stored by this instance as magic bytes (uses theTransmissionMetrics.DEFAULT_ENCODING
) for byte conversion).
-
AbstractMagicBytesTransmissionDecorator
public AbstractMagicBytesTransmissionDecorator(String aAlias, DECORATEE aDecoratee, String aMagicBytes, Charset aCharset) Enriches the provided decoratee with magic bytes being prefixed (retrieved from the givenString
). -
AbstractMagicBytesTransmissionDecorator
public AbstractMagicBytesTransmissionDecorator(String aAlias, DECORATEE aDecoratee, byte[] aMagicBytes) Enriches the provided decoratee with the given magic bytes being prefixed.- Parameters:
aAlias
- The alias which identifies the content of this segment.aDecoratee
- The decoratee which to be prefixed with magic bytes.aMagicBytes
- The magic bytes to be prefixed.
-
-
Method Details
-
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
- Overrides:
toSequence
in classAbstractMagicBytesTransmission
- Returns:
- The according instance's
Sequence
.
-
getLength
public int getLength()Determines the overall length of thisTransmission
. In case of nestedTransmission
instances, all length values from all sub-segments are accumulated to the result as well.- Specified by:
getLength
in interfaceorg.refcodes.mixin.LengthAccessor
- Specified by:
getLength
in interfaceTransmission
- Returns:
- The (overall) length of the
Transmission
(including any sub-segments).
-
getDecoratee
- Specified by:
getDecoratee
in interfaceorg.refcodes.mixin.DecorateeAccessor<DECORATEE extends Transmission>
-
setPayload
public void setPayload(byte[] aValue) Sets the magic bytes as ofAbstractMagicBytesTransmission.setMagicBytes(byte[])
.- Specified by:
setPayload
in interfaceorg.refcodes.mixin.PayloadAccessor.PayloadMutator<DECORATEE extends Transmission>
- Overrides:
setPayload
in classAbstractMagicBytesTransmission
-
getAlias
- Specified by:
getAlias
in interfaceorg.refcodes.mixin.AliasAccessor
- Overrides:
getAlias
in classAbstractMagicBytesTransmission
-
toString
- Overrides:
toString
in classAbstractMagicBytesTransmission
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractMagicBytesTransmission
-
equals
- Overrides:
equals
in classAbstractMagicBytesTransmission
-
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<DECORATEE extends Transmission>
- Specified by:
toSchema
in interfaceTransmission
- Overrides:
toSchema
in classAbstractMagicBytesTransmission
- Returns:
- The
SerialSchema
representation of the implementing type for debugging and verification (or documentation) purposes.
-