Class StringSection

All Implemented Interfaces:
Serializable, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.EncodingAccessor<Charset>, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.PayloadAccessor<String>, org.refcodes.mixin.PayloadAccessor.PayloadBuilder<String,PayloadTransmission<String>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<String>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<String>, org.refcodes.mixin.Resetable, org.refcodes.mixin.Schemable, PayloadSection<String>, PayloadTransmission<String>, Section, Section.SectionMixin, Transmission, Transmission.TransmissionMixin

public class StringSection extends AbstractPayloadSection<String> implements org.refcodes.mixin.EncodingAccessor<Charset>
The StringSection is an implementation of a Section carrying a String as payload. By default, if not otherwise specified, the TransmissionMetrics.DEFAULT_ENCODING encoding is used for encoding and decoding String instances.
See Also:
  • Constructor Details

    • StringSection

      public StringSection(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:
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • StringSection

      public StringSection(String 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:
      aValue - The payload to be contained by the StringSection.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • StringSection

      public StringSection(String aAlias, String 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:
      aAlias - The alias which identifies the content of this instance.
      aValue - The payload to be contained by the StringSection.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • StringSection

      public StringSection()
      Constructs an empty StringSection using the TransmissionMetrics.DEFAULT_ENCODING encoding for the payload.
    • StringSection

      public StringSection(String aValue)
      Constructs a StringSection with the given String payload being encoded with the TransmissionMetrics.DEFAULT_ENCODING.
      Parameters:
      aValue - The payload to be contained by this StringSection.
    • StringSection

      public StringSection(Charset aCharset)
      Constructs a StringSection with a payload expected to be encoded with the given Charset.
      Parameters:
      aCharset - The Charset to be used for encoding and decoding String instances.
    • StringSection

      public StringSection(String aValue, Charset aCharset)
      Constructs a StringSection with the given String payload being encoded with the given Charset.
      Parameters:
      aValue - The payload to be contained by this StringSection.
      aCharset - The Charset to be used for encoding the String.
    • StringSection

      public StringSection(String aAlias, String aValue)
      Constructs a StringSection with the given String payload being encoded with the TransmissionMetrics.DEFAULT_ENCODING.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aValue - The payload to be contained by this StringSection.
    • StringSection

      public StringSection(String aAlias, String aValue, Charset aCharset)
      Constructs a StringSection with the given String payload being encoded with the given Charset.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aValue - The payload to be contained by this StringSection.
      aCharset - The Charset to be used for encoding the String.
  • 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 void fromTransmission(Sequence aSequence, int aOffset, int aLength) throws TransmissionException
      (Re-)initializes this instance with the the given Sequence data.
      Specified by:
      fromTransmission in interface Section
      Parameters:
      aSequence - The Sequence data from which to (re-)initialize this instance.
      aOffset - The offset where to start processing the provided Sequence.
      aLength - The length of data assigned by the Sequence.
      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 StringSection withPayload(String aValue)
      Specified by:
      withPayload in interface org.refcodes.mixin.PayloadAccessor.PayloadBuilder<String,PayloadTransmission<String>>
    • getEncoding

      public Charset getEncoding()
      Specified by:
      getEncoding in interface org.refcodes.mixin.EncodingAccessor<Charset>