Class AbstractCrcTransmissionDecorator<DECORATEE extends Transmission>

  • 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.numerical.CrcAlgorithmAccessor, org.refcodes.numerical.CrcChecksumAccessor, org.refcodes.numerical.CrcChecksumConcatenateModeAccessor, org.refcodes.numerical.CrcChecksumValidationModeAccessor, 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:
    Serialized Form
    • Nested Class Summary

      • 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.numerical.CrcChecksumValidationModeAccessor

        org.refcodes.numerical.CrcChecksumValidationModeAccessor.CrcChecksumValidationModeBuilder<B extends org.refcodes.numerical.CrcChecksumValidationModeAccessor.CrcChecksumValidationModeBuilder<B>>, org.refcodes.numerical.CrcChecksumValidationModeAccessor.CrcChecksumValidationModeMutator, org.refcodes.numerical.CrcChecksumValidationModeAccessor.CrcChecksumValidationModeProperty
      • 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
    • Constructor Detail

      • AbstractCrcTransmissionDecorator

        public AbstractCrcTransmissionDecorator​(DECORATEE aDecoratee,
                                                TransmissionMetrics aTransmissionMetrics)
        Constructs an according instance wrapping the given Transmission. The configuration attributes are taken from the TransmissionMetrics configuration object, though only those attributes are supported which are also supported by the other constructors!
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
      • AbstractCrcTransmissionDecorator

        public AbstractCrcTransmissionDecorator​(DECORATEE aDecoratee,
                                                org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm)
        Constructs an according instance wrapping the given Transmission (using TransmissionMetrics.DEFAULT_ENDIANESS by default).
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
      • AbstractCrcTransmissionDecorator

        public AbstractCrcTransmissionDecorator​(DECORATEE aDecoratee,
                                                org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm,
                                                org.refcodes.numerical.ChecksumValidationMode aCrcChecksumValidationMode)
        Constructs an according instance wrapping the given Transmission (using TransmissionMetrics.DEFAULT_ENDIANESS by default).
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
        aCrcChecksumValidationMode - 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 given Transmission.
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
        aEndianess - The Endianess to use when calculating the CRC checksum.
      • AbstractCrcTransmissionDecorator

        public AbstractCrcTransmissionDecorator​(DECORATEE aDecoratee,
                                                org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm,
                                                org.refcodes.numerical.ChecksumValidationMode aCrcChecksumValidationMode,
                                                org.refcodes.numerical.Endianess aEndianess)
        Constructs an according instance wrapping the given Transmission.
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
        aCrcChecksumValidationMode - The mode of operation when validating provided CRC checksums against calculated ones.
        aEndianess - The Endianess to use when calculating the CRC checksum.
      • AbstractCrcTransmissionDecorator

        public AbstractCrcTransmissionDecorator​(DECORATEE aDecoratee,
                                                org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode)
        Constructs an according instance wrapping the given Transmission (using TransmissionMetrics.DEFAULT_ENDIANESS by default).
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aCrcChecksumConcatenateMode - The mode of concatenation to for concatenating the decoratee's Sequence 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 given Transmission (using TransmissionMetrics.DEFAULT_ENDIANESS by default).
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aCrcChecksumConcatenateMode - The mode of concatenation to for concatenating the decoratee's Sequence with the according CRC checksum.
        aEndianess - The Endianess 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 given Transmission (using TransmissionMetrics.DEFAULT_ENDIANESS by default).
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
        aCrcChecksumConcatenateMode - The mode of concatenation to for concatenating the decoratee's Sequence with the according CRC checksum.
      • AbstractCrcTransmissionDecorator

        public AbstractCrcTransmissionDecorator​(DECORATEE aDecoratee,
                                                org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm,
                                                org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode,
                                                org.refcodes.numerical.ChecksumValidationMode aCrcChecksumValidationMode)
        Constructs an according instance wrapping the given Transmission (using TransmissionMetrics.DEFAULT_ENDIANESS by default).
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
        aCrcChecksumConcatenateMode - The mode of concatenation to for concatenating the decoratee's Sequence with the according CRC checksum.
        aCrcChecksumValidationMode - 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 given Transmission.
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
        aCrcChecksumConcatenateMode - The mode of concatenation to for concatenating the decoratee's Sequence with the according CRC checksum.
        aEndianess - The Endianess 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 aCrcChecksumValidationMode,
                                                org.refcodes.numerical.Endianess aEndianess)
        Constructs an according instance wrapping the given Transmission.
        Parameters:
        aDecoratee - The Transmission to be wrapped.
        aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
        aCrcChecksumConcatenateMode - The mode of concatenation for concatenating the decoratee's Sequence with the according CRC checksum.
        aCrcChecksumValidationMode - The mode of operation when validating provided CRC checksums against calculated ones.
        aEndianess - The Endianess to use when calculating the CRC checksum.
    • Method Detail

      • transmitTo

        public void transmitTo​(OutputStream aOutputStream,
                               InputStream aReturnStream)
                        throws IOException
        Transmits the Sequence representing the implementing type's instance to the given OutputStream. Implementations providing error correction methods use the provided feedback InputStream to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the transmitted data.
        Specified by:
        transmitTo in interface Transmission
        Specified by:
        transmitTo in interface Transmission.TransmissionMixin
        Parameters:
        aOutputStream - The OutputStream where to write this instance's Sequence to.
        aReturnStream - An InputStream 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 the OutputStream caused problems.
      • getLength

        public int getLength()
        Determines the overall length of this Transmission. In case of nested Transmission instances, all length values from all sub-segments are accumulated to the result as well.
        Specified by:
        getLength in interface org.refcodes.mixin.LengthAccessor
        Specified by:
        getLength in interface Transmission
        Returns:
        The (overall) length of the Transmission (including any sub-segments).
      • getDecoratee

        public DECORATEE getDecoratee()
        Specified by:
        getDecoratee in interface org.refcodes.mixin.DecorateeAccessor<DECORATEE extends Transmission>
      • getCrcChecksum

        public long getCrcChecksum()
        Specified by:
        getCrcChecksum in interface org.refcodes.numerical.CrcChecksumAccessor
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class org.refcodes.numerical.AbstractCrcMixin
      • equals

        public boolean equals​(Object obj)
        Overrides:
        equals in class org.refcodes.numerical.AbstractCrcMixin
      • toSimpleTypeMap

        public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()
        Returns the SimpleTypeMap representation of this Transmission. In case this Transmission has Transmission children, then the children are queried as well and contained in the resulting SimpleTypeMap. The aliases of the according Transmission instances represent the resulting path to a Transmission's final simple type.
        Specified by:
        toSimpleTypeMap in interface Transmission
        Returns:
        The SimpleTypeMap representing this Transmission and (if any) its children, with the according aliases forming the paths to the Transmission's values.