Class AbstractReferenceeLengthSegment<REFERENCEE extends Transmission>

java.lang.Object
org.refcodes.serial.AbstractReferenceeLengthSegment<REFERENCEE>
All Implemented Interfaces:
Serializable, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.Schemable<SerialSchema>, org.refcodes.numerical.EndianessAccessor, AllocLengthAccessor, LengthWidthAccessor, Segment, Transmission, Transmission.TransmissionMixin
Direct Known Subclasses:
AbstractLengthDecoratorSegment, AllocSegmentHead, LengthSegment

public abstract class AbstractReferenceeLengthSegment<REFERENCEE extends Transmission> extends Object implements Segment, Transmission.TransmissionMixin, LengthWidthAccessor, org.refcodes.numerical.EndianessAccessor, AllocLengthAccessor
The AbstractReferenceeLengthSegment represents a allocated length value as of the referenced Transmission element's length.
See Also:
  • Field Details

  • Constructor Details

    • AbstractReferenceeLengthSegment

      public AbstractReferenceeLengthSegment(TransmissionMetrics aTransmissionMetrics)
      Constructs an according instance. 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:
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • AbstractReferenceeLengthSegment

      public AbstractReferenceeLengthSegment(REFERENCEE aReferencee, TransmissionMetrics aTransmissionMetrics)
      Constructs an according instance. 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:
      aReferencee - The referenced Transmission which's length is to be used.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • AbstractReferenceeLengthSegment

      public AbstractReferenceeLengthSegment()
      Constructs an empty allocation value with a width of TransmissionMetrics.DEFAULT_LENGTH_WIDTH bytes used to specify the decoratee's length and a TransmissionMetrics.DEFAULT_ENDIANESS endian representation of the decoratee's length.
    • AbstractReferenceeLengthSegment

      public AbstractReferenceeLengthSegment(org.refcodes.numerical.Endianess aEndianess)
      Constructs an empty allocation value with a width of TransmissionMetrics.DEFAULT_LENGTH_WIDTH bytes used to specify the decoratee's length and the provided Endianess representation of the decoratee's length.
      Parameters:
      aEndianess - The Endianess to be used for length values.
    • AbstractReferenceeLengthSegment

      public AbstractReferenceeLengthSegment(int aLengthWidth)
      Constructs an empty allocation value with the given number of bytes used to specify the decoratee's length and a TransmissionMetrics.DEFAULT_ENDIANESS endian representation of the decoratee's length.
      Parameters:
      aLengthWidth - The width (in bytes) to be used for length values.
    • AbstractReferenceeLengthSegment

      public AbstractReferenceeLengthSegment(int aLengthWidth, org.refcodes.numerical.Endianess aEndianess)
      Constructs an empty allocation value with the given number of bytes used to specify the decoratee's length and the provided Endianess representation of the decoratee's length.
      Parameters:
      aLengthWidth - The width (in bytes) to be used for length values.
      aEndianess - The Endianess to be used for length values.
    • AbstractReferenceeLengthSegment

      public AbstractReferenceeLengthSegment(REFERENCEE aReferencee)
      Constructs the allocation value with the given decoratee and a width of TransmissionMetrics.DEFAULT_LENGTH_WIDTH bytes used to specify the decoratee's length a TransmissionMetrics.DEFAULT_ENDIANESS endian representation of the decoratee's length.
      Parameters:
      aReferencee - The decoratee used for this allocation value.
    • AbstractReferenceeLengthSegment

      public AbstractReferenceeLengthSegment(REFERENCEE aReferencee, org.refcodes.numerical.Endianess aEndianess)
      Constructs the allocation value with the given decoratee and a width of TransmissionMetrics.DEFAULT_LENGTH_WIDTH bytes used to specify the decoratee's length and the provided Endianess representation of the decoratee's length.
      Parameters:
      aReferencee - The decoratee used for this allocation value.
      aEndianess - The Endianess to be used for length values.
    • AbstractReferenceeLengthSegment

      public AbstractReferenceeLengthSegment(REFERENCEE aReferencee, int aLengthWidth)
      Constructs the allocation value with the given decoratee and with the given number of bytes used to specify the decoratee's length and a TransmissionMetrics.DEFAULT_ENDIANESS endian representation of the decoratee's length.
      Parameters:
      aReferencee - The decoratee used for this allocation value.
      aLengthWidth - The width (in bytes) to be used for length values.
    • AbstractReferenceeLengthSegment

      public AbstractReferenceeLengthSegment(REFERENCEE aReferencee, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess)
      Constructs the allocation value with the given decoratee and with the given number of bytes used to specify the decoratee's length and the provided Endianess representation of the decoratee's length.
      Parameters:
      aReferencee - The decoratee used for this allocation value.
      aLengthWidth - The width (in bytes) to be used for length values.
      aEndianess - The Endianess to be used for length values.
  • Method Details

    • getLengthWidth

      public int getLengthWidth()
      Retrieves the length width (in bytes) from the length width (in bytes) property.
      Specified by:
      getLengthWidth in interface LengthWidthAccessor
      Returns:
      The length width (in bytes) stored by the length width (in bytes) property.
    • 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.
    • fromTransmission

      public int fromTransmission(Sequence aSequence, int aOffset) throws TransmissionException
      (Re-)initializes this instance with the the given Sequence data.
      Specified by:
      fromTransmission in interface Segment
      Parameters:
      aSequence - The Sequence data from which to (re-)initialize this instance.
      aOffset - The offset where to start processing the provided Sequence.
      Returns:
      The index after the last offset into the given Sequence processed by this method.
      Throws:
      TransmissionException - thrown in case a given Sequence cannot be processed.
    • receiveFrom

      public void receiveFrom(InputStream aInputStream, OutputStream aReturnStream) throws IOException, TransmissionException
      (Re-)initializes this instance by receiving the according Sequence from the given InputStream. Implementations providing error correction methods use the provided feedback OutputStream to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.
      Specified by:
      receiveFrom in interface Segment
      Parameters:
      aInputStream - The InputStream from which to read the instance's (re-)initialization Sequence from.
      aReturnStream - An OutputStream 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 reading data from the InputStream caused problems.
      TransmissionException - thrown in case a given transmission cannot be processed.
    • 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).
    • getEndianess

      public org.refcodes.numerical.Endianess getEndianess()
      Specified by:
      getEndianess in interface org.refcodes.numerical.EndianessAccessor
    • getAllocLength

      public int getAllocLength()
      Returns the allocated length in bytes declared by this instance.
      Specified by:
      getAllocLength in interface AllocLengthAccessor
      Returns:
      The allocated length in bytes.
    • toSchema

      public SerialSchema toSchema()
      Retrieves the SerialSchema representing the Transmission. Retrieving a SerialSchema is useful when analyzing and debugging data structures such as a AllocSectionDecoratorSegment instance to help document, learn and verify on the structure (as well as the content) of that very AllocSectionDecoratorSegment.
      Specified by:
      toSchema in interface org.refcodes.mixin.Schemable<REFERENCEE extends Transmission>
      Specified by:
      toSchema in interface Transmission
      Returns:
      The SerialSchema representation of the implementing type for debugging and verification (or documentation) purposes.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • 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.