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.mixin.Schemable, 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.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

    Fields
    Modifier and Type
    Field
    Description
    protected 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

    Constructors
    Constructor
    Description
    AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode)
    Constructs an according instance wrapping the given Transmission (using TransmissionMetrics.DEFAULT_ENDIANESS by default).
    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).
    AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm)
    Constructs an according instance wrapping the given Transmission (using TransmissionMetrics.DEFAULT_ENDIANESS by default).
    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).
    AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.mixin.ConcatenateMode aCrcChecksumConcatenateMode, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode)
    Constructs an according instance wrapping the given Transmission (using TransmissionMetrics.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 given Transmission.
    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.
    AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode)
    Constructs an according instance wrapping the given Transmission (using TransmissionMetrics.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 given Transmission.
    AbstractCrcTransmissionDecorator(DECORATEE aDecoratee, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess)
    Constructs an according instance wrapping the given Transmission.
    Constructs an according instance wrapping the given Transmission.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    long
    int
    Determines the overall length of this Transmission.
    int
    void
    Resets any dynamic data (e.g. values such as payloads or checksums) and must not(!)
    Provides the Sequence representation of this Transmission.
    org.refcodes.struct.SimpleTypeMap
    Returns the SimpleTypeMap representation of this Transmission.
    void
    transmitTo(OutputStream aOutputStream, InputStream aReturnStream)
    Transmits the Sequence representing the implementing type's instance to the given OutputStream.

    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.serial.Transmission

    transmitTo, transmitTo
  • Field Details

  • Constructor Details

    • 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 aChecksumValidationMode)
      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.
      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 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 aChecksumValidationMode, 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.
      aChecksumValidationMode - 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 aChecksumValidationMode)
      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.
      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 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 aChecksumValidationMode, 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.
      aChecksumValidationMode - The mode of operation when validating provided CRC checksums against calculated ones.
      aEndianess - The Endianess to use when calculating the CRC checksum.
  • Method Details

    • toSequence

      public Sequence toSequence()
      Provides the Sequence representation of this Transmission. In case of nested Transmission instances, all Sequence representations from all sub-segments are accumulated to the result as well. Caution, the Transmission (or its nested Transmission instances) may be backed by the returned Sequence.
      Specified by:
      toSequence in interface Transmission
      Returns:
      The according instance's Sequence.
    • 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
    • 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. the TransmissionMetrics).
      Specified by:
      reset in interface org.refcodes.mixin.Resetable
      Specified by:
      reset in interface Transmission
    • toSchema

      public SerialSchema toSchema()
      Specified by:
      toSchema in interface org.refcodes.mixin.Schemable
      Specified by:
      toSchema in interface Transmission
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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.