java.lang.Object
org.refcodes.serial.AbstractMagicBytesTransmission
org.refcodes.serial.MagicBytesSegment
org.refcodes.serial.AssertMagicBytesSegment
- 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[]>
,Segment
,Segment.SegmentMixin
,Transmission
,Transmission.TransmissionMixin
public class AssertMagicBytesSegment extends MagicBytesSegment
The
AssertMagicBytesSegment
extends the MagicBytesSegment
and
enforces the configured magic bytes to match the received magic bytes (as of
Segment.fromTransmission(Sequence)
and
Segment.SegmentMixin.receiveFrom(java.io.InputStream, java.io.OutputStream)
or the like).
In case the assertion of the configured magic bytes fails during receiving,
then a BadMagicBytesException
or
BadMagicBytesSequenceException
is thrown.- 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.Segment
Segment.SegmentMixin
Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin
-
Field Summary
Fields inherited from class org.refcodes.serial.AbstractMagicBytesTransmission
_alias, _charset, _magicBytes, _magicBytesLength, MAGIC_BYTES, MAGIC_BYTES_TEXT
-
Constructor Summary
Constructors Constructor Description AssertMagicBytesSegment(byte... aMagicBytes)
AssertMagicBytesSegment(String aMagicBytes)
AssertMagicBytesSegment(String aAlias, byte... aMagicBytes)
AssertMagicBytesSegment(String aAlias, String aMagicBytes)
AssertMagicBytesSegment(String aAlias, String aMagicBytes, Charset aCharset)
AssertMagicBytesSegment(String aMagicBytes, Charset aCharset)
-
Method Summary
Modifier and Type Method Description int
fromTransmission(Sequence aSequence, int aOffset)
(Re-)initializes this instance with the the givenSequence
data.Schema
toSchema()
Retrieves theSchema
representing theTransmission
.Methods inherited from class org.refcodes.serial.MagicBytesSegment
getLength, toTransmission, withPayload
Methods inherited from class org.refcodes.serial.AbstractMagicBytesTransmission
equals, getAlias, getEncoding, getMagicBytes, getMagicBytesLength, getPayload, hashCode, setMagicBytes, setMagicBytes, setMagicBytes, setPayload, toMagicBytesString, toMagicBytesString, toSimpleTypeMap, toString
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.mixin.PayloadAccessor
getPayloadOr
Methods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadProperty
letPayload
Methods inherited from interface org.refcodes.serial.Segment
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFrom
Methods inherited from interface org.refcodes.serial.Segment.SegmentMixin
receiveFrom
Methods inherited from interface org.refcodes.serial.Transmission
toSimpleTypeMap, transmitTo, transmitTo
Methods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitTo
-
Constructor Details
-
AssertMagicBytesSegment
public AssertMagicBytesSegment(byte... aMagicBytes) -
AssertMagicBytesSegment
-
AssertMagicBytesSegment
-
AssertMagicBytesSegment
-
AssertMagicBytesSegment
-
AssertMagicBytesSegment
-
-
Method Details
-
fromTransmission
public int fromTransmission(Sequence aSequence, int aOffset) throws BadMagicBytesSequenceException, TransmissionException(Re-)initializes this instance with the the givenSequence
data.- Specified by:
fromTransmission
in interfaceSegment
- Overrides:
fromTransmission
in classMagicBytesSegment
- Parameters:
aSequence
- TheSequence
data from which to (re-)initialize this instance.aOffset
- The offset where to start processing the providedSequence
.- Returns:
- The index after the last offset into the given
Sequence
processed by this method. - Throws:
TransmissionException
- thrown in case a givenSequence
cannot be processed.BadMagicBytesSequenceException
-
toSchema
Retrieves theSchema
representing theTransmission
. Retrieving aSchema
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 interfaceTransmission
- Overrides:
toSchema
in classAbstractMagicBytesTransmission
- Returns:
- The
Schema
representation of the implementing type for debugging and verification (or documentation) purposes.
-