Class ByteSegment

All Implemented Interfaces:
Serializable, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.PayloadAccessor<Byte>, org.refcodes.mixin.PayloadAccessor.PayloadBuilder<Byte,PayloadTransmission<Byte>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<Byte>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<Byte>, org.refcodes.mixin.Schemable, PayloadSegment<Byte>, PayloadTransmission<Byte>, Segment, Segment.SegmentMixin, Transmission, Transmission.TransmissionMixin

public class ByteSegment extends AbstractPayloadSegment<Byte> implements Segment
The ByteSegment is an implementation of a Segment carrying in byte value as payload.
See Also:
  • Field Details

  • Constructor Details

    • ByteSegment

      public ByteSegment()
      Constructs an empty ByteSegment.
    • ByteSegment

      public ByteSegment(Byte aValue)
      Constructs a ByteSegment with the given byte payload.
      Parameters:
      aValue - The value (payload) to be contained by the Segment.
    • ByteSegment

      public ByteSegment(String aAlias)
      Constructs an empty ByteSegment.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
    • ByteSegment

      public ByteSegment(String aAlias, Byte aValue)
      Constructs a ByteSegment with the given byte payload.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aValue - The value (payload) to be contained by the Segment.
  • 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()
      Specified by:
      toSchema in interface org.refcodes.mixin.Schemable
      Specified by:
      toSchema in interface Transmission
    • withPayload

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