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.Resetable,org.refcodes.numerical.ChecksumValidationModeAccessor,org.refcodes.numerical.CrcAlgorithmAccessor,org.refcodes.numerical.CrcChecksumAccessor,org.refcodes.numerical.CrcChecksumConcatenateModeAccessor,org.refcodes.numerical.CrcMixin,org.refcodes.numerical.EndianessAccessor,org.refcodes.schema.Schemable,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.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.ChecksumValidationModePropertyNested 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.CrcAlgorithmPropertyNested 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.CrcChecksumPropertyNested 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.CrcChecksumConcatenateModePropertyNested 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.EndianessPropertyNested 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.serial.Transmission
Transmission.TransmissionMixin -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected DECORATEEstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.refcodes.numerical.AbstractCrcMixin
_checksumValidationMode, _crcAlgorithm, _crcChecksumConcatenateMode, _endianess -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode) Constructs an according instance wrapping the givenTransmission(usingTransmissionMetrics.DEFAULT_ENDIANESSby default).AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode, org.refcodes.numerical.Endianess aEndianess) Constructs an according instance wrapping the givenTransmission(usingTransmissionMetrics.DEFAULT_ENDIANESSby default).AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm) Constructs an according instance wrapping the givenTransmission(usingTransmissionMetrics.DEFAULT_ENDIANESSby default).AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode) Constructs an according instance wrapping the givenTransmission(usingTransmissionMetrics.DEFAULT_ENDIANESSby 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_ENDIANESSby 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_ENDIANESSby 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 TypeMethodDescriptionbooleanlongintDetermines the overall length of thisTransmission.inthashCode()voidreset()Resets any dynamic data (e.g. values such as payloads or checksums) and must not(!)toSchema()Provides theSequencerepresentation of thisTransmission.org.refcodes.struct.SimpleTypeMapReturns theSimpleTypeMaprepresentation of thisTransmission.toString()voidtransmitTo(OutputStream aOutputStream, InputStream aReturnStream) Transmits theSequencerepresenting the implementing type's instance to the givenOutputStream.Methods inherited from class org.refcodes.numerical.AbstractCrcMixin
getChecksumValidationMode, getCrcAlgorithm, getCrcChecksumConcatenateMode, getEndianessMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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 theTransmissionMetricsconfiguration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aDecoratee- TheTransmissionto be wrapped.aTransmissionMetrics- TheTransmissionMetricsto 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_ENDIANESSby default).- Parameters:
aDecoratee- TheTransmissionto be wrapped.aCrcAlgorithm- TheCrcAlgorithmto 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_ENDIANESSby default).- Parameters:
aDecoratee- TheTransmissionto be wrapped.aCrcAlgorithm- TheCrcAlgorithmto 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- TheTransmissionto be wrapped.aCrcAlgorithm- TheCrcAlgorithmto be used for CRC checksum calculation.aEndianess- TheEndianessto 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- TheTransmissionto be wrapped.aCrcAlgorithm- TheCrcAlgorithmto be used for CRC checksum calculation.aChecksumValidationMode- The mode of operation when validating provided CRC checksums against calculated ones.aEndianess- TheEndianessto 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_ENDIANESSby default).- Parameters:
aDecoratee- TheTransmissionto be wrapped.aCrcChecksumConcatenateMode- The mode of concatenation to for concatenating the decoratee'sSequencewith 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_ENDIANESSby default).- Parameters:
aDecoratee- TheTransmissionto be wrapped.aCrcChecksumConcatenateMode- The mode of concatenation to for concatenating the decoratee'sSequencewith the according CRC checksum.aEndianess- TheEndianessto 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_ENDIANESSby default).- Parameters:
aDecoratee- TheTransmissionto be wrapped.aCrcAlgorithm- TheCrcAlgorithmto be used for CRC checksum calculation.aCrcChecksumConcatenateMode- The mode of concatenation to for concatenating the decoratee'sSequencewith 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_ENDIANESSby default).- Parameters:
aDecoratee- TheTransmissionto be wrapped.aCrcAlgorithm- TheCrcAlgorithmto be used for CRC checksum calculation.aCrcChecksumConcatenateMode- The mode of concatenation to for concatenating the decoratee'sSequencewith 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- TheTransmissionto be wrapped.aCrcAlgorithm- TheCrcAlgorithmto be used for CRC checksum calculation.aCrcChecksumConcatenateMode- The mode of concatenation to for concatenating the decoratee'sSequencewith the according CRC checksum.aEndianess- TheEndianessto 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- TheTransmissionto be wrapped.aCrcAlgorithm- TheCrcAlgorithmto be used for CRC checksum calculation.aCrcChecksumConcatenateMode- The mode of concatenation for concatenating the decoratee'sSequencewith the according CRC checksum.aChecksumValidationMode- The mode of operation when validating provided CRC checksums against calculated ones.aEndianess- TheEndianessto use when calculating the CRC checksum.
-
-
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- Returns:
- The according instance's
Sequence.
-
transmitTo
Transmits theSequencerepresenting the implementing type's instance to the givenOutputStream. Implementations providing error correction methods use the provided feedbackInputStreamto do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the transmitted data.- Specified by:
transmitToin interfaceTransmission- Specified by:
transmitToin interfaceTransmission.TransmissionMixin- Parameters:
aOutputStream- TheOutputStreamwhere to write this instance'sSequenceto.aReturnStream- AnInputStreambeing 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 theOutputStreamcaused problems.
-
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>
-
getCrcChecksum
public long getCrcChecksum()- Specified by:
getCrcChecksumin interfaceorg.refcodes.numerical.CrcChecksumAccessor
-
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
-
toSchema
- Specified by:
toSchemain interfaceorg.refcodes.schema.Schemable- Specified by:
toSchemain interfaceTransmission
-
hashCode
public int hashCode()- Overrides:
hashCodein classorg.refcodes.numerical.AbstractCrcMixin
-
equals
- Overrides:
equalsin classorg.refcodes.numerical.AbstractCrcMixin
-
toString
-
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.
-