- 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[]>,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. AAbstractMagicBytesTransmissionprovides the base functionality to manage magic bytes.- See Also:
- Serialized Form
-
-
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
Fields Modifier and Type Field Description protected String_aliasprotected String_charsetprotected byte[]_magicBytesprotected int_magicBytesLengthstatic StringMAGIC_BYTESstatic StringMAGIC_BYTES_TEXT
-
Constructor Summary
Constructors Constructor Description AbstractMagicBytesTransmission(String aAlias, byte[] aMagicBytes)Constructs anAbstractMagicBytesTransmissionwith 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 anAbstractMagicBytesTransmissionfor magic bytes of the given length.AbstractMagicBytesTransmission(String aAlias, String aMagicBytes)Constructs anAbstractMagicBytesTransmissionwith the according magic bytes (retrieved from the givenString).AbstractMagicBytesTransmission(String aAlias, String aMagicBytes, Charset aCharset)Constructs anAbstractMagicBytesTransmissionwith 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)StringgetAlias()CharsetgetEncoding()byte[]getMagicBytes()Returns the magic bytes as stored by this instance.intgetMagicBytesLength()Retrieves the magic bytes length from the magic bytes magic bytes length property.byte[]getPayload()Returns the magic bytes as ofgetMagicBytes().inthashCode()voidsetMagicBytes(byte[] aMagicBytes)Sets the magic bytes to be stored by this instance.voidsetMagicBytes(String aMagicBytes)Sets the magic bytes from the providedStringto be stored by this instance (uses theTransmissionMetrics.DEFAULT_ENCODING) for byte conversion).voidsetMagicBytes(String aMagicBytes, Charset aCharset)Sets the magic bytes from the providedStringto be stored by this instance.voidsetPayload(byte[] aValue)Sets the magic bytes as ofsetMagicBytes(byte[]).StringtoMagicBytesString()Retrieves theStringrepresentation of the given magic bytes using the latest providedCharsetfor conversion or theTransmissionMetrics.DEFAULT_ENCODINGin case noCharsethas been provided.StringtoMagicBytesString(String aCharset)Retrieves theStringrepresentation of the given magic bytes using the providedCharsetfor conversion or theTransmissionMetrics.DEFAULT_ENCODINGin case noCharsethas been provided.SchematoSchema()Retrieves theSchemarepresenting theTransmission.org.refcodes.struct.SimpleTypeMaptoSimpleTypeMap()Returns theSimpleTypeMaprepresentation of thisTransmission.StringtoString()SequencetoTransmission()Provides theSequencerepresentation of thisTransmission.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
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.serial.Transmission
getLength, transmitTo, transmitTo
-
Methods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitTo
-
-
-
-
Field Detail
-
MAGIC_BYTES
public static final String MAGIC_BYTES
- See Also:
- Constant Field Values
-
MAGIC_BYTES_TEXT
public static final String MAGIC_BYTES_TEXT
- See Also:
- Constant Field Values
-
_magicBytes
protected byte[] _magicBytes
-
_magicBytesLength
protected int _magicBytesLength
-
_charset
protected String _charset
-
_alias
protected String _alias
-
-
Constructor Detail
-
AbstractMagicBytesTransmission
public AbstractMagicBytesTransmission(String aAlias, TransmissionMetrics aTransmissionMetrics)
Constructs an according instance for magic bytes of the given length. 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.aTransmissionMetrics- TheTransmissionMetricsto 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 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.aMagicBytes- TheStringto be stored by this instance as magic bytes.aTransmissionMetrics- TheTransmissionMetricsto 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 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.aMagicBytes- The bytes to be stored by this instance as magic bytes.aTransmissionMetrics- TheTransmissionMetricsto be used for configuring this instance.
-
AbstractMagicBytesTransmission
public AbstractMagicBytesTransmission(String aAlias, int aMagicBytesLength)
Constructs anAbstractMagicBytesTransmissionfor 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
public AbstractMagicBytesTransmission(String aAlias, String aMagicBytes)
Constructs anAbstractMagicBytesTransmissionwith the according magic bytes (retrieved from the givenString).- Parameters:
aAlias- The alias which identifies the content of this segment.aMagicBytes- TheStringto be stored by this instance as magic bytes (uses theTransmissionMetrics.DEFAULT_ENCODING) for byte conversion).
-
AbstractMagicBytesTransmission
public AbstractMagicBytesTransmission(String aAlias, String aMagicBytes, Charset aCharset)
Constructs anAbstractMagicBytesTransmissionwith the according magic bytes (retrieved from the givenString).
-
AbstractMagicBytesTransmission
public AbstractMagicBytesTransmission(String aAlias, byte[] aMagicBytes)
Constructs anAbstractMagicBytesTransmissionwith 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 Detail
-
setPayload
public void setPayload(byte[] aValue)
Sets the magic bytes as ofsetMagicBytes(byte[]).- Specified by:
setPayloadin interfaceorg.refcodes.mixin.PayloadAccessor.PayloadMutator<byte[]>
-
getAlias
public String getAlias()
- Specified by:
getAliasin interfaceorg.refcodes.mixin.AliasAccessor
-
getMagicBytes
public byte[] getMagicBytes()
Returns the magic bytes as stored by this instance.- Specified by:
getMagicBytesin 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:
setMagicBytesin interfaceorg.refcodes.mixin.MagicBytesAccessor.MagicBytesMutator- Parameters:
aMagicBytes- The according magic bytes to store.
-
setMagicBytes
public void setMagicBytes(String aMagicBytes)
Sets the magic bytes from the providedStringto be stored by this instance (uses theTransmissionMetrics.DEFAULT_ENCODING) for byte conversion).- Specified by:
setMagicBytesin interfaceorg.refcodes.mixin.MagicBytesAccessor.MagicBytesMutator- Specified by:
setMagicBytesin interfaceMagicBytesAccessor.MagicBytesMutator- Parameters:
aMagicBytes- The String from which to copy the according magic bytes from.
-
setMagicBytes
public void setMagicBytes(String aMagicBytes, Charset aCharset)
Sets the magic bytes from the providedStringto be stored by this instance.
-
toMagicBytesString
public String toMagicBytesString()
Retrieves theStringrepresentation of the given magic bytes using the latest providedCharsetfor conversion or theTransmissionMetrics.DEFAULT_ENCODINGin case noCharsethas been provided.- Returns:
- The
Stringrepresentation of the magic bytes.
-
toMagicBytesString
public String toMagicBytesString(String aCharset)
Retrieves theStringrepresentation of the given magic bytes using the providedCharsetfor conversion or theTransmissionMetrics.DEFAULT_ENCODINGin case noCharsethas been provided.
-
toTransmission
public Sequence toTransmission()
Provides theSequencerepresentation of thisTransmission. In case of nestedTransmissioninstances, allSequencerepresentations from all sub-segments are accumulated to the result as well.- Specified by:
toTransmissionin 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:
getMagicBytesLengthin 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:
getPayloadin interfaceorg.refcodes.mixin.PayloadAccessor<byte[]>
-
toSchema
public Schema toSchema()
Retrieves theSchemarepresenting theTransmission. Retrieving aSchemais useful when analyzing and debugging data structures such as aAllocSectionDecoratorSegmentinstance to help document, learn and verify on the structure (as well as the content) of that veryAllocSectionDecoratorSegment.- Specified by:
toSchemain interfaceTransmission- Returns:
- The
Schemarepresentation of the implementing type for debugging and verification (or documentation) purposes.
-
getEncoding
public Charset getEncoding()
- Specified by:
getEncodingin interfaceorg.refcodes.mixin.EncodingAccessor<Charset>
-
toSimpleTypeMap
public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()
Returns theSimpleTypeMaprepresentation of thisTransmission. In case this Transmission hasTransmissionchildren, then the children are queried as well and contained in the resultingSimpleTypeMap. The aliases of the accordingTransmissioninstances represent the resulting path to aTransmission's final simple type.- Specified by:
toSimpleTypeMapin interfaceTransmission- Returns:
- The
SimpleTypeMaprepresenting thisTransmissionand (if any) its children, with the according aliases forming the paths to theTransmission's values.
-
-