Class AbstractReferenceeLengthSegment<REFERENCEE extends Transmission>

    • Constructor Detail

      • 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​(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,
                                               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 Detail

      • 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.
      • 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode 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.