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.Resetable,org.refcodes.schema.Schemable,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.AliasPropertyNested 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.LengthPropertyNested 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.MagicBytesPropertyNested classes/interfaces inherited from interface org.refcodes.serial.MagicBytesAccessor
MagicBytesAccessor.MagicBytesBuilder<B extends MagicBytesAccessor.MagicBytesBuilder<B>>, MagicBytesAccessor.MagicBytesMutator, MagicBytesAccessor.MagicBytesPropertyNested classes/interfaces inherited from interface org.refcodes.serial.MagicBytesLengthAccessor
MagicBytesLengthAccessor.MagicBytesLengthBuilder<B extends MagicBytesLengthAccessor.MagicBytesLengthBuilder<B>>, MagicBytesLengthAccessor.MagicBytesLengthMutator, MagicBytesLengthAccessor.MagicBytesLengthPropertyNested 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
FieldsFields inherited from class org.refcodes.serial.AbstractMagicBytesTransmission
_charset, _magicBytes, _magicBytesLength, MAGIC_BYTES, MAGIC_BYTES_TEXT -
Constructor Summary
ConstructorsConstructorDescriptionAbstractMagicBytesTransmissionDecorator(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 TypeMethodDescriptionbooleangetAlias()intDetermines the overall length of thisTransmission.inthashCode()voidreset()Resets any dynamic data (e.g. values such as payloads or checksums) and must not(!)voidsetPayload(byte[] aValue) Sets the magic bytes as ofAbstractMagicBytesTransmission.setMagicBytes(byte[]).toSchema()Provides theSequencerepresentation of thisTransmission.toString()Methods inherited from class org.refcodes.serial.AbstractMagicBytesTransmission
getEncoding, getMagicBytes, getMagicBytesLength, getPayload, setMagicBytes, setMagicBytes, setMagicBytes, toMagicBytesString, toMagicBytesString, toSimpleTypeMapMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.refcodes.serial.MagicBytesAccessor
toMagicBytes, toMagicBytesMethods inherited from interface org.refcodes.mixin.MagicBytesAccessor.MagicBytesProperty
letMagicBytes, letMagicBytesMethods inherited from interface org.refcodes.serial.MagicBytesAccessor.MagicBytesProperty
letMagicBytesMethods inherited from interface org.refcodes.mixin.PayloadAccessor
getPayloadOrMethods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadBuilder
withPayloadMethods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadProperty
letPayloadMethods inherited from interface org.refcodes.serial.Transmission
toSimpleTypeMap, transmitTo, transmitToMethods 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 theTransmissionMetricsconfiguration 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- TheTransmissionMetricsto 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- TheStringto 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 theSequencerepresentation of thisTransmission. In case of nestedTransmissioninstances, allSequencerepresentations from all sub-segments are accumulated to the result as well. Caution, the Transmission (or its nestedTransmissioninstances) may be backed by the returnedSequence.- Specified by:
toSequencein interfaceTransmission- Overrides:
toSequencein classAbstractMagicBytesTransmission- Returns:
- The according instance's
Sequence.
-
getLength
public int getLength()Determines the overall length of thisTransmission. In case of nestedTransmissioninstances, all length values from all sub-segments are accumulated to the result as well.- Specified by:
getLengthin interfaceorg.refcodes.mixin.LengthAccessor- Specified by:
getLengthin interfaceTransmission- Returns:
- The (overall) length of the
Transmission(including any sub-segments).
-
getDecoratee
- Specified by:
getDecorateein interfaceorg.refcodes.mixin.DecorateeAccessor<DECORATEE extends Transmission>
-
setPayload
public void setPayload(byte[] aValue) Sets the magic bytes as ofAbstractMagicBytesTransmission.setMagicBytes(byte[]).- Specified by:
setPayloadin interfaceorg.refcodes.mixin.PayloadAccessor.PayloadMutator<DECORATEE extends Transmission>- Overrides:
setPayloadin classAbstractMagicBytesTransmission
-
getAlias
- Specified by:
getAliasin interfaceorg.refcodes.mixin.AliasAccessor- Overrides:
getAliasin classAbstractMagicBytesTransmission
-
reset
public void reset()Resets any dynamic data (e.g. values such as payloads or checksums) and must not(!) reset any configurations or settings required to produce the dynamic data (e.g. theTransmissionMetrics).- Specified by:
resetin interfaceorg.refcodes.mixin.Resetable- Specified by:
resetin interfaceTransmission- Overrides:
resetin classAbstractMagicBytesTransmission
-
toString
- Overrides:
toStringin classAbstractMagicBytesTransmission
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractMagicBytesTransmission
-
equals
- Overrides:
equalsin classAbstractMagicBytesTransmission
-
toSchema
- Specified by:
toSchemain interfaceorg.refcodes.schema.Schemable- Specified by:
toSchemain interfaceTransmission- Overrides:
toSchemain classAbstractMagicBytesTransmission
-