Class CharArraySection

java.lang.Object
org.refcodes.serial.AbstractPayloadSection<char[]>
org.refcodes.serial.CharArraySection
All Implemented Interfaces:
Serializable, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.EncodingAccessor<Charset>, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.PayloadAccessor<char[]>, org.refcodes.mixin.PayloadAccessor.PayloadBuilder<char[],PayloadTransmission<char[]>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<char[]>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<char[]>, org.refcodes.mixin.Schemable<SerialSchema>, PayloadSection<char[]>, PayloadTransmission<char[]>, Section, Section.SectionMixin, Transmission, Transmission.TransmissionMixin

public class CharArraySection extends AbstractPayloadSection<char[]> implements PayloadSection<char[]>, org.refcodes.mixin.EncodingAccessor<Charset>
The CharArraySection is an implementation of a PayloadSection carrying a char array as payload.
See Also:
  • Constructor Details

    • CharArraySection

      public CharArraySection(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.
    • CharArraySection

      public CharArraySection(TransmissionMetrics aTransmissionMetrics, char... aValue)
      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.
      aValue - The payload to be contained by the CharArraySection.
    • CharArraySection

      public CharArraySection(TransmissionMetrics aTransmissionMetrics, Character... aValue)
      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.
      aValue - The payload to be contained by the CharArraySection.
    • CharArraySection

      public CharArraySection(String aAlias, 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.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • CharArraySection

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

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

      public CharArraySection()
      Constructs an empty CharArraySection. Uses UTF-16 by default for encoding.
    • CharArraySection

      public CharArraySection(Charset aCharset)
      Constructs an empty CharArraySection.
      Parameters:
      aCharset - The charset to be used for encoding.
    • CharArraySection

      public CharArraySection(char[] aPayload)
      Constructs a CharArraySection with the given char array payload. Uses TransmissionMetrics.DEFAULT_ENCODING by default for encoding.
      Parameters:
      aPayload - The payload to be contained by the PayloadSection.
    • CharArraySection

      public CharArraySection(Character[] aPayload)
      Constructs a CharArraySection with the given char array payload. Uses TransmissionMetrics.DEFAULT_ENCODING by default for encoding.
      Parameters:
      aPayload - The payload to be contained by the PayloadSection.
    • CharArraySection

      public CharArraySection(Charset aCharset, char... aPayload)
      Constructs a CharArraySection with the given char array payload. Uses TransmissionMetrics.DEFAULT_ENCODING by default for encoding.
      Parameters:
      aCharset - The charset to be used for encoding.
      aPayload - The payload to be contained by the PayloadSection.
    • CharArraySection

      public CharArraySection(Charset aCharset, Character... aPayload)
      Constructs a CharArraySection with the given char array payload. Uses TransmissionMetrics.DEFAULT_ENCODING by default for encoding.
      Parameters:
      aCharset - The charset to be used for encoding.
      aPayload - The payload to be contained by the PayloadSection.
    • CharArraySection

      public CharArraySection(String aAlias)
      Constructs an empty CharArraySection. Uses UTF-16 by default for encoding.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
    • CharArraySection

      public CharArraySection(String aAlias, Charset aCharset)
      Constructs an empty CharArraySection.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aCharset - The charset to be used for encoding.
    • CharArraySection

      public CharArraySection(String aAlias, char[] aPayload)
      Constructs a CharArraySection with the given char array payload. Uses TransmissionMetrics.DEFAULT_ENCODING by default for encoding.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aPayload - The payload to be contained by the PayloadSection.
    • CharArraySection

      public CharArraySection(String aAlias, Character[] aPayload)
      Constructs a CharArraySection with the given char array payload. Uses TransmissionMetrics.DEFAULT_ENCODING by default for encoding.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aPayload - The payload to be contained by the PayloadSection.
    • CharArraySection

      public CharArraySection(String aAlias, Charset aCharset, char... aPayload)
      Constructs a CharArraySection with the given char array payload. Uses TransmissionMetrics.DEFAULT_ENCODING by default for encoding.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aCharset - The charset to be used for encoding.
      aPayload - The payload to be contained by the PayloadSection.
    • CharArraySection

      public CharArraySection(String aAlias, Charset aCharset, Character... aPayload)
      Constructs a CharArraySection with the given char array payload. Uses TransmissionMetrics.DEFAULT_ENCODING by default for encoding.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aCharset - The charset to be used for encoding.
      aPayload - The payload to be contained by the PayloadSection.
  • Method Details

    • withPayload

      public CharArraySection withPayload(char[] aValue)
      Specified by:
      withPayload in interface org.refcodes.mixin.PayloadAccessor.PayloadBuilder<char[],PayloadTransmission<char[]>>
    • 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()
      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.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractPayloadSection<char[]>
    • getEncoding

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

      public void setPayload(Character[] aPayload)
      Convenience method to convert the array of wrapper types into its counterpart with primitive types before invoking AbstractPayloadSection.setPayload(Object).
      Parameters:
      aPayload - The payload with the wrapper types.
    • withPayload

      public CharArraySection withPayload(Character[] aPayload)
      Convenience method to convert the array of wrapper types into its counterpart with primitive types before invoking withPayload(char[]).
      Parameters:
      aPayload - The payload with the wrapper types.
      Returns:
      This instance as of the builder pattern.