Class ComplexTypeSegment<T>

Type Parameters:
T - The type of the data structure representing the payload.
All Implemented Interfaces:
Serializable, Iterable<Segment>, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.ChildrenAccessor<Segment[]>, org.refcodes.mixin.EncodingAccessor<Charset>, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.PayloadAccessor<T>, org.refcodes.mixin.PayloadAccessor.PayloadBuilder<T,PayloadTransmission<T>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<T>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<T>, org.refcodes.mixin.Resetable, org.refcodes.mixin.TypeAccessor<T>, org.refcodes.numerical.EndianessAccessor, org.refcodes.schema.Schemable, LengthWidthAccessor, PayloadSegment<T>, PayloadTransmission<T>, Segment, Segment.SegmentMixin, Transmission, Transmission.TransmissionMixin, TransmissionComposite<Segment>

public class ComplexTypeSegment<T> extends SegmentComposite<Segment> implements PayloadSegment<T>, org.refcodes.mixin.TypeAccessor<T>, LengthWidthAccessor, org.refcodes.numerical.EndianessAccessor, org.refcodes.mixin.EncodingAccessor<Charset>
A ComplexTypeSegment takes a POJO (a data structure) and creates from its content a Segment representing the POJO's structure. Inspect it's structure with SegmentComposite.toSchema() and Schema.toString()!
See Also:
  • Constructor Details

    • ComplexTypeSegment

      public ComplexTypeSegment(Class<T> aType, TransmissionMetrics aTransmissionMetrics)
      Constructs the ComplexTypeSegment from the given Class for the according type T. The attributes of the given data structure are processed all and in alphabetical order. For specifying a predefined set of attributes and their order, please invoke ComplexTypeSegment(Class, TransmissionMetrics, String[]) instead! 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:
      aType - The data structure's type.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • ComplexTypeSegment

      public ComplexTypeSegment(Class<T> aType, TransmissionMetrics aTransmissionMetrics, String... aAttributes)
      Constructs the ComplexTypeSegment from the given Class for the according type T. The attributes of the given data structure are processed using the predefined set of attributes in their according order 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:
      aType - The data structure's type.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
      aAttributes - The attributes or null if all attributes are to be processed in alphabetical order.
    • ComplexTypeSegment

      public ComplexTypeSegment(T aValue, TransmissionMetrics aTransmissionMetrics)
      Constructs the ComplexTypeSegment from the given data structure instance. The attributes of the given data structure are processed all and in alphabetical order. For specifying a predefined set of attributes and their order, please invoke ComplexTypeSegment(Class, TransmissionMetrics, String[]) instead! 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 data structure instance.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • ComplexTypeSegment

      public ComplexTypeSegment(T aValue, TransmissionMetrics aTransmissionMetrics, String... aAttributes)
      Constructs the ComplexTypeSegment from the given data structure instance.. The attributes of the given data structure are processed using the predefined set of attributes in their according order. 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 value from which to construct the complex type..
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
      aAttributes - The attributes or null if all attributes are to be processed in alphabetical order.
    • ComplexTypeSegment

      public ComplexTypeSegment(Class<T> aType)
      Constructs the ComplexTypeSegment from the given Class for the according type T. The attributes of the given data structure are processed all and in alphabetical order. For specifying a predefined set of attributes and their order, please invoke ComplexTypeSegment(Class, String[]) instead!
      Parameters:
      aType - The data structure's type.
    • ComplexTypeSegment

      public ComplexTypeSegment(Class<T> aType, String... aAttributes)
      Constructs the ComplexTypeSegment from the given Class for the according type T. The attributes of the given data structure are processed using the predefined set of attributes in their according order.
      Parameters:
      aType - The data structure's type.
      aAttributes - The attributes or null if all attributes are to be processed in alphabetical order.
    • ComplexTypeSegment

      public ComplexTypeSegment(T aValue)
      Constructs the ComplexTypeSegment from the given data structure instance. The attributes of the given data structure are processed all and in alphabetical order. For specifying a predefined set of attributes and their order, please invoke ComplexTypeSegment(Class, String[]) instead!
      Parameters:
      aValue - The data structure instance.
    • ComplexTypeSegment

      public ComplexTypeSegment(T aValue, String... aAttributes)
      Constructs the ComplexTypeSegment from the given data structure instance.. The attributes of the given data structure are processed using the predefined set of attributes in their according order.
      Parameters:
      aValue - The value from which to construct the complex type.
      aAttributes - The attributes or null if all attributes are to be processed in alphabetical order.
    • ComplexTypeSegment

      public ComplexTypeSegment(Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset)
      Constructs the ComplexTypeSegment from the given Class for the according type T. The attributes of the given data structure are processed all and in alphabetical order. For specifying a predefined set of attributes and their order, please invoke ComplexTypeSegment(Class, String[]) instead!
      Parameters:
      aType - The data structure's type.
      aLengthWidth - The width (in bytes) to be used for length values.
      aEndianess - The Endianess to be used for (length) values.
      aCharset - The Charset to be used for encoding and decoding String instances.
    • ComplexTypeSegment

      public ComplexTypeSegment(Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes)
      Constructs the ComplexTypeSegment from the given Class for the according type T. The attributes of the given data structure are processed using the predefined set of attributes in their according order
      Parameters:
      aType - The data structure's type.
      aLengthWidth - The width (in bytes) to be used for length values.
      aEndianess - The Endianess to be used for (length) values.
      aCharset - The Charset to be used for encoding and decoding String instances.
      aAttributes - The attributes or null if all attributes are to be processed in alphabetical order.
    • ComplexTypeSegment

      public ComplexTypeSegment(T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset)
      Constructs the ComplexTypeSegment from the given data structure instance. The attributes of the given data structure are processed all and in alphabetical order. For specifying a predefined set of attributes and their order, please invoke ComplexTypeSegment(Class, String[]) instead!
      Parameters:
      aValue - The data structure instance.
      aLengthWidth - The width (in bytes) to be used for length values.
      aEndianess - The Endianess to be used for (length) values.
      aCharset - The Charset to be used for encoding and decoding String instances.
    • ComplexTypeSegment

      public ComplexTypeSegment(T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes)
      Constructs the ComplexTypeSegment from the given data structure instance.. The attributes of the given data structure are processed using the predefined set of attributes in their according order
      Parameters:
      aValue - The value from which to construct the complex type..
      aLengthWidth - The width (in bytes) to be used for length values.
      aEndianess - The Endianess to be used for (length) values.
      aCharset - The Charset to be used for encoding and decoding String instances.
      aAttributes - The attributes or null if all attributes are to be processed in alphabetical order.
    • ComplexTypeSegment

      public ComplexTypeSegment(String aAlias, Class<T> aType)
      Constructs the ComplexTypeSegment from the given Class for the according type T. The attributes of the given data structure are processed all and in alphabetical order. For specifying a predefined set of attributes and their order, please invoke ComplexTypeSegment(Class, String[]) instead!
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aType - The data structure's type.
    • ComplexTypeSegment

      public ComplexTypeSegment(String aAlias, Class<T> aType, String... aAttributes)
      Constructs the ComplexTypeSegment from the given Class for the according type T. The attributes of the given data structure are processed using the predefined set of attributes in their according order
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aType - The data structure's type.
      aAttributes - The attributes or null if all attributes are to be processed in alphabetical order.
    • ComplexTypeSegment

      public ComplexTypeSegment(String aAlias, T aValue)
      Constructs the ComplexTypeSegment from the given data structure instance. The attributes of the given data structure are processed all and in alphabetical order. For specifying a predefined set of attributes and their order, please invoke ComplexTypeSegment(Class, String[]) instead!
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aValue - The data structure instance.
    • ComplexTypeSegment

      public ComplexTypeSegment(String aAlias, T aValue, String... aAttributes)
      Constructs the ComplexTypeSegment from the given data structure instance.. The attributes of the given data structure are processed using the predefined set of attributes in their according order
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aValue - The value from which to construct the complex type..
      aAttributes - The attributes or null if all attributes are to be processed in alphabetical order.
    • ComplexTypeSegment

      public ComplexTypeSegment(String aAlias, Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset)
      Constructs the ComplexTypeSegment from the given Class for the according type T. The attributes of the given data structure are processed all and in alphabetical order. For specifying a predefined set of attributes and their order, please invoke ComplexTypeSegment(Class, String[]) instead!
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aType - The data structure's type.
      aLengthWidth - The width (in bytes) to be used for length values.
      aEndianess - The Endianess to be used for (length) values.
      aCharset - The Charset to be used for encoding and decoding String instances.
    • ComplexTypeSegment

      public ComplexTypeSegment(String aAlias, Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes)
      Constructs the ComplexTypeSegment from the given Class for the according type T. The attributes of the given data structure are processed using the predefined set of attributes in their according order
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aType - The data structure's type.
      aLengthWidth - The width (in bytes) to be used for length values.
      aEndianess - The Endianess to be used for (length) values.
      aCharset - The Charset to be used for encoding and decoding String instances.
      aAttributes - The attributes or null if all attributes are to be processed in alphabetical order.
    • ComplexTypeSegment

      public ComplexTypeSegment(String aAlias, T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset)
      Constructs the ComplexTypeSegment from the given data structure instance. The attributes of the given data structure are processed all and in alphabetical order. For specifying a predefined set of attributes and their order, please invoke ComplexTypeSegment(Class, String[]) instead!
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aValue - The data structure instance.
      aLengthWidth - The width (in bytes) to be used for length values.
      aEndianess - The Endianess to be used for (length) values.
      aCharset - The Charset to be used for encoding and decoding String instances.
    • ComplexTypeSegment

      public ComplexTypeSegment(String aAlias, T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes)
      Constructs the ComplexTypeSegment from the given data structure instance.. The attributes of the given data structure are processed using the predefined set of attributes in their according order
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aValue - The value from which to construct the complex type..
      aLengthWidth - The width (in bytes) to be used for length values.
      aEndianess - The Endianess to be used for (length) values.
      aCharset - The Charset to be used for encoding and decoding String instances.
      aAttributes - The attributes or null if all attributes are to be processed in alphabetical order.
  • Method Details

    • getType

      public Class<T> getType()
      Specified by:
      getType in interface org.refcodes.mixin.TypeAccessor<T>
    • getAttributes

      public String[] getAttributes()
      Retrieves the attributes to process from the given data structure and the order in which the attributes are processed.
      Returns:
      The attributes or null if all attributes are to be processed in alphabetical order.
    • getLengthWidth

      public int getLengthWidth()
      Retrieves the length width (in bytes) from the length width (in bytes) property.
      Specified by:
      getLengthWidth in interface LengthWidthAccessor
      Returns:
      The length width (in bytes) stored by the length width (in bytes) property.
    • getEndianess

      public org.refcodes.numerical.Endianess getEndianess()
      Specified by:
      getEndianess in interface org.refcodes.numerical.EndianessAccessor
    • getEncoding

      public Charset getEncoding()
      Specified by:
      getEncoding in interface org.refcodes.mixin.EncodingAccessor<T>
    • 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
      Overrides:
      fromTransmission in class SegmentComposite<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.
    • receiveFrom

      public void receiveFrom(InputStream aInputStream, OutputStream aReturnStream) throws IOException
      (Re-)initializes this instance by receiving the according Sequence from the given InputStream. Implementations providing error correction methods use the provided feedback OutputStream to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.
      Specified by:
      receiveFrom in interface Segment
      Specified by:
      receiveFrom in interface Segment.SegmentMixin
      Overrides:
      receiveFrom in class SegmentComposite<Segment>
      Parameters:
      aInputStream - The InputStream from which to read the instance's (re-)initialization Sequence from.
      aReturnStream - An OutputStream being the return channel to handle "stop-and-wait ARQ" or the like in case of a bidirectional connection. Can be null in case we have a unidirectional connection.
      Throws:
      IOException - thrown in case reading data from the InputStream caused problems.
      TransmissionException - thrown in case a given transmission cannot be processed.
    • getPayload

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

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

      public void setPayload(T aValue)
      Specified by:
      setPayload in interface org.refcodes.mixin.PayloadAccessor.PayloadMutator<T>
    • getAlias

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

      public String toString()
      Overrides:
      toString in class SegmentComposite<Segment>