Class NumberSegment

All Implemented Interfaces:
Serializable, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.PayloadAccessor<Long>, org.refcodes.mixin.PayloadAccessor.PayloadBuilder<Long,PayloadTransmission<Long>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<Long>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<Long>, org.refcodes.mixin.Schemable<SerialSchema>, org.refcodes.mixin.ValueAccessor<Long>, org.refcodes.mixin.ValueAccessor.ValueBuilder<Long,NumberSegment>, org.refcodes.mixin.ValueAccessor.ValueMutator<Long>, org.refcodes.mixin.ValueAccessor.ValueProperty<Long>, PayloadSegment<Long>, PayloadTransmission<Long>, Segment, Segment.SegmentMixin, Transmission, Transmission.TransmissionMixin
Direct Known Subclasses:
SequenceNumberSegment

public class NumberSegment extends AbstractPayloadSegment<Long> implements Segment, org.refcodes.mixin.ValueAccessor.ValueProperty<Long>, org.refcodes.mixin.ValueAccessor.ValueBuilder<Long,NumberSegment>
The NumberSegment is an implementation of a Segment carrying in long an integer value with a configurable width (in bytes) as payload.
See Also:
  • Field Details

  • Constructor Details

    • NumberSegment

      public NumberSegment(int aNumberWidth, TransmissionMetrics aTransmissionMetrics)
      Constructs an according instance from the given configuration. 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:
      aNumberWidth - The number of bytes to be occupied by the number.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • NumberSegment

      public NumberSegment(int aNumberWidth, Long aValue, TransmissionMetrics aTransmissionMetrics)
      Constructs an according instance from the given configuration. 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:
      aNumberWidth - The number of bytes to be occupied by the number.
      aValue - The payload to be contained by the DoubleArraySection.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • NumberSegment

      public NumberSegment(String aAlias, int aNumberWidth, TransmissionMetrics aTransmissionMetrics)
      Constructs an according instance from the given configuration. 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:
      aAlias - The alias which identifies the content of this instance.
      aNumberWidth - The number of bytes to be occupied by the number.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • NumberSegment

      public NumberSegment(int aNumberWidth)
      Constructs an empty NumberSegment with a TransmissionMetrics.DEFAULT_ENDIANESS endian representation of the NumberSegment's value.
      Parameters:
      aNumberWidth - The number of bytes to be occupied by the number.
    • NumberSegment

      public NumberSegment(int aNumberWidth, org.refcodes.numerical.Endianess aEndianess)
      Constructs an empty NumberSegment with the given Endianess.
      Parameters:
      aNumberWidth - The number of bytes to be occupied by the number.
      aEndianess - The Endianess to be used for payload values.
    • NumberSegment

      public NumberSegment(int aNumberWidth, Long aValue)
      Constructs a NumberSegment with the given long payload and a TransmissionMetrics.DEFAULT_ENDIANESS endian representation of the NumberSegment's value.
      Parameters:
      aNumberWidth - The number of bytes to be occupied by the number.
      aValue - The payload to be contained by the NumberSegment.
    • NumberSegment

      public NumberSegment(int aNumberWidth, Long aValue, org.refcodes.numerical.Endianess aEndianess)
      Constructs a NumberSegment with the given long payload and the given Endianess for the representation of the NumberSegment's value (payload).
      Parameters:
      aNumberWidth - The number of bytes to be occupied by the number.
      aValue - The value (payload) to be contained by the NumberSegment.
      aEndianess - The Endianess to be used for payload values.
    • NumberSegment

      public NumberSegment(String aAlias, int aNumberWidth)
      Constructs an empty NumberSegment with a TransmissionMetrics.DEFAULT_ENDIANESS endian representation of the NumberSegment's value.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aNumberWidth - The number of bytes to be occupied by the number.
    • NumberSegment

      public NumberSegment(String aAlias, int aNumberWidth, org.refcodes.numerical.Endianess aEndianess)
      Constructs an empty NumberSegment with the given Endianess.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aNumberWidth - The number of bytes to be occupied by the number.
      aEndianess - The Endianess to be used for payload values.
    • NumberSegment

      public NumberSegment(String aAlias, int aNumberWidth, Long aValue)
      Constructs a NumberSegment with the given long payload and a TransmissionMetrics.DEFAULT_ENDIANESS endian representation of the NumberSegment's value.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aNumberWidth - The number of bytes to be occupied by the number.
      aValue - The payload to be contained by the NumberSegment.
    • NumberSegment

      public NumberSegment(String aAlias, int aNumberWidth, Long aValue, org.refcodes.numerical.Endianess aEndianess)
      Constructs a NumberSegment with the given long payload and the given Endianess for the representation of the NumberSegment's value (payload).
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aNumberWidth - The number of bytes to be occupied by the number.
      aValue - The value (payload) to be contained by the NumberSegment.
      aEndianess - The Endianess to be used for payload values.
  • 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.
    • 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.
    • 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).
    • 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<SerialSchema>
      Specified by:
      toSchema in interface Transmission
      Returns:
      The SerialSchema representation of the implementing type for debugging and verification (or documentation) purposes.
    • withPayload

      public NumberSegment withPayload(Long aValue)
      Specified by:
      withPayload in interface org.refcodes.mixin.PayloadAccessor.PayloadBuilder<Long,PayloadTransmission<Long>>
    • getValue

      public Long getValue()
      Specified by:
      getValue in interface org.refcodes.mixin.ValueAccessor<Long>
    • setValue

      public void setValue(Long aValue)
      Specified by:
      setValue in interface org.refcodes.mixin.ValueAccessor.ValueMutator<Long>
    • withValue

      public NumberSegment withValue(Long aValue)
      Specified by:
      withValue in interface org.refcodes.mixin.ValueAccessor.ValueBuilder<Long,NumberSegment>