Class FixedLengthSequenceSegment

java.lang.Object
org.refcodes.serial.FixedLengthSequenceSegment
All Implemented Interfaces:
Serializable, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.PayloadAccessor<Sequence>, org.refcodes.mixin.PayloadAccessor.PayloadBuilder<Sequence,PayloadTransmission<Sequence>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<Sequence>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<Sequence>, org.refcodes.mixin.Resetable, org.refcodes.schema.Schemable, PayloadSegment<Sequence>, PayloadTransmission<Sequence>, Segment, Segment.SegmentMixin, Transmission, Transmission.TransmissionMixin

public class FixedLengthSequenceSegment extends Object implements PayloadSegment<Sequence>, Segment.SegmentMixin
The FixedLengthSequenceSegment is a Segment representing a Sequence of a fixed length (as of the arguments passed to one of its constructors).
See Also:
  • Field Details

    • _sequence

      protected Sequence _sequence
    • _alias

      protected String _alias
  • Constructor Details

  • Method Details

    • 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).
    • 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.
    • 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.schema.Schemable
      Specified by:
      toSchema in interface Transmission
    • getAlias

      public String getAlias()
      Specified by:
      getAlias in interface org.refcodes.mixin.AliasAccessor
    • withPayload

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

      public Sequence getPayload()
      Specified by:
      getPayload in interface org.refcodes.mixin.PayloadAccessor<Sequence>
    • setPayload

      public void setPayload(Sequence aValue)
      Specified by:
      setPayload in interface org.refcodes.mixin.PayloadAccessor.PayloadMutator<Sequence>
    • 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.