Module org.refcodes.serial
Package org.refcodes.serial
Class AbstractCrcTransmissionDecorator<DECORATEE extends Transmission>
java.lang.Object
org.refcodes.numerical.AbstractCrcMixin
org.refcodes.serial.AbstractCrcTransmissionDecorator<DECORATEE>
- Type Parameters:
DECORATEE
- The decoratee type describing the according subclass to be enriched with a CRC checksum.
- All Implemented Interfaces:
Serializable
,org.refcodes.mixin.DecorateeAccessor<DECORATEE>
,org.refcodes.mixin.LengthAccessor
,org.refcodes.mixin.Schemable<SerialSchema>
,org.refcodes.numerical.ChecksumValidationModeAccessor
,org.refcodes.numerical.CrcAlgorithmAccessor
,org.refcodes.numerical.CrcChecksumAccessor
,org.refcodes.numerical.CrcChecksumConcatenateModeAccessor
,org.refcodes.numerical.CrcMixin
,org.refcodes.numerical.EndianessAccessor
,Transmission
,Transmission.TransmissionMixin
- Direct Known Subclasses:
CrcSectionDecorator
,CrcSegmentDecorator
public abstract class AbstractCrcTransmissionDecorator<DECORATEE extends Transmission>
extends org.refcodes.numerical.AbstractCrcMixin
implements Transmission, Transmission.TransmissionMixin, org.refcodes.mixin.DecorateeAccessor<DECORATEE>, org.refcodes.numerical.CrcMixin, org.refcodes.numerical.CrcChecksumAccessor
A
AbstractCrcTransmissionDecorator
wraps a Transmission
instance and enriches the Transmission
with a CRC checksum.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.numerical.ChecksumValidationModeAccessor
org.refcodes.numerical.ChecksumValidationModeAccessor.ChecksumValidationModeBuilder<B extends org.refcodes.numerical.ChecksumValidationModeAccessor.ChecksumValidationModeBuilder<B>>, org.refcodes.numerical.ChecksumValidationModeAccessor.ChecksumValidationModeMutator, org.refcodes.numerical.ChecksumValidationModeAccessor.ChecksumValidationModeProperty
Nested classes/interfaces inherited from interface org.refcodes.numerical.CrcAlgorithmAccessor
org.refcodes.numerical.CrcAlgorithmAccessor.CrcAlgorithmBuilder<B extends org.refcodes.numerical.CrcAlgorithmAccessor.CrcAlgorithmBuilder<B>>, org.refcodes.numerical.CrcAlgorithmAccessor.CrcAlgorithmMutator, org.refcodes.numerical.CrcAlgorithmAccessor.CrcAlgorithmProperty
Nested classes/interfaces inherited from interface org.refcodes.numerical.CrcChecksumAccessor
org.refcodes.numerical.CrcChecksumAccessor.CrcChecksumBuilder<B extends org.refcodes.numerical.CrcChecksumAccessor.CrcChecksumBuilder<B>>, org.refcodes.numerical.CrcChecksumAccessor.CrcChecksumMutator, org.refcodes.numerical.CrcChecksumAccessor.CrcChecksumProperty
Nested classes/interfaces inherited from interface org.refcodes.numerical.CrcChecksumConcatenateModeAccessor
org.refcodes.numerical.CrcChecksumConcatenateModeAccessor.CrcChecksumConcatenateModeBuilder<B extends org.refcodes.numerical.CrcChecksumConcatenateModeAccessor.CrcChecksumConcatenateModeBuilder<B>>, org.refcodes.numerical.CrcChecksumConcatenateModeAccessor.CrcChecksumConcatenateModeMutator, org.refcodes.numerical.CrcChecksumConcatenateModeAccessor.CrcChecksumConcatenateModeProperty
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.numerical.EndianessAccessor
org.refcodes.numerical.EndianessAccessor.EndianessBuilder<B extends org.refcodes.numerical.EndianessAccessor.EndianessBuilder<B>>, org.refcodes.numerical.EndianessAccessor.EndianessMutator, org.refcodes.numerical.EndianessAccessor.EndianessProperty
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.serial.Transmission
Transmission.TransmissionMixin
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
protected DECORATEE
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class org.refcodes.numerical.AbstractCrcMixin
_checksumValidationMode, _crcAlgorithm, _crcChecksumConcatenateMode, _endianess
-
Constructor Summary
ConstructorDescriptionAbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).AbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).AbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).AbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).AbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).AbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission
.AbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission
.AbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).AbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission
.AbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission
.AbstractCrcTransmissionDecorator
(DECORATEE aDecoratee, TransmissionMetrics aTransmissionMetrics) Constructs an according instance wrapping the givenTransmission
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
long
int
Determines the overall length of thisTransmission
.int
hashCode()
toSchema()
Retrieves theSerialSchema
representing theTransmission
.Provides theSequence
representation of thisTransmission
.org.refcodes.struct.SimpleTypeMap
Returns theSimpleTypeMap
representation of thisTransmission
.toString()
void
transmitTo
(OutputStream aOutputStream, InputStream aReturnStream) Transmits theSequence
representing the implementing type's instance to the givenOutputStream
.Methods inherited from class org.refcodes.numerical.AbstractCrcMixin
getChecksumValidationMode, getCrcAlgorithm, getCrcChecksumConcatenateMode, getEndianess
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.numerical.ChecksumValidationModeAccessor
getChecksumValidationMode
Methods inherited from interface org.refcodes.numerical.CrcAlgorithmAccessor
getCrcAlgorithm
Methods inherited from interface org.refcodes.numerical.CrcChecksumConcatenateModeAccessor
getCrcChecksumConcatenateMode
Methods inherited from interface org.refcodes.numerical.EndianessAccessor
getEndianess
Methods inherited from interface org.refcodes.serial.Transmission
transmitTo, transmitTo
-
Field Details
-
CRC_ENDIANESS
- See Also:
-
CRC_CHECKSUM
- See Also:
-
CRC_CHECKSUM_HEX
- See Also:
-
CRC_ALGORITHM
- See Also:
-
CRC_BYTE_WIDTH
- See Also:
-
CRC_CHECKSUM_CONCATENATION_MODE
- See Also:
-
CRC_CHECKSUM_LITTLE_ENDIAN_BYTES
- See Also:
-
CRC_CHECKSUM_BIG_ENDIAN_BYTES
- See Also:
-
_decoratee
-
_crcChecksum
protected long _crcChecksum
-
-
Constructor Details
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, TransmissionMetrics aTransmissionMetrics) Constructs an according instance wrapping the givenTransmission
. The configuration attributes are taken from theTransmissionMetrics
configuration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission
.- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aEndianess
- TheEndianess
to use when calculating the CRC checksum.
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission
.- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aEndianess
- TheEndianess
to use when calculating the CRC checksum.
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aCrcChecksumConcatenateMode
- The mode of concatenation to for concatenating the decoratee'sSequence
with the according CRC checksum.
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aCrcChecksumConcatenateMode
- The mode of concatenation to for concatenating the decoratee'sSequence
with the according CRC checksum.aEndianess
- TheEndianess
to use when calculating the CRC checksum.
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aCrcChecksumConcatenateMode
- The mode of concatenation to for concatenating the decoratee'sSequence
with the according CRC checksum.
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode) Constructs an according instance wrapping the givenTransmission
(usingTransmissionMetrics.DEFAULT_ENDIANESS
by default).- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aCrcChecksumConcatenateMode
- The mode of concatenation to for concatenating the decoratee'sSequence
with the according CRC checksum.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission
.- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aCrcChecksumConcatenateMode
- The mode of concatenation to for concatenating the decoratee'sSequence
with the according CRC checksum.aEndianess
- TheEndianess
to use when calculating the CRC checksum.
-
AbstractCrcTransmissionDecorator
public AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission
.- Parameters:
aDecoratee
- TheTransmission
to be wrapped.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aCrcChecksumConcatenateMode
- The mode of concatenation for concatenating the decoratee'sSequence
with the according CRC checksum.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aEndianess
- TheEndianess
to use when calculating the CRC checksum.
-
-
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
- Returns:
- The according instance's
Sequence
.
-
transmitTo
Transmits theSequence
representing the implementing type's instance to the givenOutputStream
. Implementations providing error correction methods use the provided feedbackInputStream
to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the transmitted data.- Specified by:
transmitTo
in interfaceTransmission
- Specified by:
transmitTo
in interfaceTransmission.TransmissionMixin
- Parameters:
aOutputStream
- TheOutputStream
where to write this instance'sSequence
to.aReturnStream
- AnInputStream
being the return channel to handle "stop-and-wait ARQ" or the like in case of a bidirectional connection. Can be null in case we have a unidirectional connection.- Throws:
IOException
- thrown in case writing data to theOutputStream
caused problems.
-
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>
-
getCrcChecksum
public long getCrcChecksum()- Specified by:
getCrcChecksum
in interfaceorg.refcodes.numerical.CrcChecksumAccessor
-
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
- Returns:
- The
SerialSchema
representation of the implementing type for debugging and verification (or documentation) purposes.
-
hashCode
public int hashCode()- Overrides:
hashCode
in classorg.refcodes.numerical.AbstractCrcMixin
-
equals
- Overrides:
equals
in classorg.refcodes.numerical.AbstractCrcMixin
-
toString
-
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.
-