- 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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor
org.refcodes.mixin.AliasAccessor.AliasBuilder<B extends org.refcodes.mixin.AliasAccessor.AliasBuilder<B>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasPropertyNested classes/interfaces inherited from interface org.refcodes.mixin.ChildrenAccessor
org.refcodes.mixin.ChildrenAccessor.ChildrenBuilder<T extends Object,B extends org.refcodes.mixin.ChildrenAccessor.ChildrenBuilder<T, B>>, org.refcodes.mixin.ChildrenAccessor.ChildrenMutator<T extends Object>, org.refcodes.mixin.ChildrenAccessor.ChildrenProperty<T extends Object> Nested classes/interfaces inherited from interface org.refcodes.mixin.EncodingAccessor
org.refcodes.mixin.EncodingAccessor.EncodingBuilder<E extends Object,B extends org.refcodes.mixin.EncodingAccessor.EncodingBuilder<E, B>>, org.refcodes.mixin.EncodingAccessor.EncodingMutator<E extends Object>, org.refcodes.mixin.EncodingAccessor.EncodingProperty<E extends Object> Nested classes/interfaces inherited from interface org.refcodes.numerical.EndianessAccessor
org.refcodes.numerical.EndianessAccessor.EndianessBuilder<B extends org.refcodes.numerical.EndianessAccessor.EndianessBuilder<B>>, org.refcodes.numerical.EndianessAccessor.EndianessMutator, org.refcodes.numerical.EndianessAccessor.EndianessPropertyNested classes/interfaces inherited from interface org.refcodes.mixin.LengthAccessor
org.refcodes.mixin.LengthAccessor.LengthBuilder<B extends org.refcodes.mixin.LengthAccessor.LengthBuilder<B>>, org.refcodes.mixin.LengthAccessor.LengthMutator, org.refcodes.mixin.LengthAccessor.LengthPropertyNested classes/interfaces inherited from interface org.refcodes.serial.LengthWidthAccessor
LengthWidthAccessor.LengthWidthBuilder<B extends LengthWidthAccessor.LengthWidthBuilder<B>>, LengthWidthAccessor.LengthWidthMutator, LengthWidthAccessor.LengthWidthPropertyNested classes/interfaces inherited from interface org.refcodes.mixin.PayloadAccessor
org.refcodes.mixin.PayloadAccessor.PayloadBuilder<P extends Object,B extends org.refcodes.mixin.PayloadAccessor.PayloadBuilder<P, B>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<P extends Object>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<P extends Object> Nested classes/interfaces inherited from interface org.refcodes.serial.Segment
Segment.SegmentMixinNested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixinNested classes/interfaces inherited from interface org.refcodes.mixin.TypeAccessor
org.refcodes.mixin.TypeAccessor.TypeBuilder<T extends Object,B extends org.refcodes.mixin.TypeAccessor.TypeBuilder<T, B>>, org.refcodes.mixin.TypeAccessor.TypeMutator<T extends Object>, org.refcodes.mixin.TypeAccessor.TypeProperty<T extends Object> -
Field Summary
Fields inherited from class org.refcodes.serial.AbstractTransmissionComposite
_children -
Constructor Summary
ConstructorsConstructorDescriptionComplexTypeSegment(Class<T> aType) Constructs theComplexTypeSegmentfrom the givenClassfor the according type T.ComplexTypeSegment(Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset) Constructs theComplexTypeSegmentfrom the givenClassfor the according type T.ComplexTypeSegment(Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegmentfrom the givenClassfor the according type T.ComplexTypeSegment(Class<T> aType, String... aAttributes) Constructs theComplexTypeSegmentfrom the givenClassfor the according type T.ComplexTypeSegment(Class<T> aType, TransmissionMetrics aTransmissionMetrics) Constructs theComplexTypeSegmentfrom the givenClassfor the according type T.ComplexTypeSegment(Class<T> aType, TransmissionMetrics aTransmissionMetrics, String... aAttributes) Constructs theComplexTypeSegmentfrom the givenClassfor the according type T.ComplexTypeSegment(String aAlias, Class<T> aType) Constructs theComplexTypeSegmentfrom the givenClassfor the according type T.ComplexTypeSegment(String aAlias, Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset) Constructs theComplexTypeSegmentfrom the givenClassfor the according type T.ComplexTypeSegment(String aAlias, Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegmentfrom the givenClassfor the according type T.ComplexTypeSegment(String aAlias, Class<T> aType, String... aAttributes) Constructs theComplexTypeSegmentfrom the givenClassfor the according type T.ComplexTypeSegment(String aAlias, T aValue) Constructs theComplexTypeSegmentfrom the given data structure instance.ComplexTypeSegment(String aAlias, T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset) Constructs theComplexTypeSegmentfrom the given data structure instance.ComplexTypeSegment(String aAlias, T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegmentfrom the given data structure instance..ComplexTypeSegment(String aAlias, T aValue, String... aAttributes) Constructs theComplexTypeSegmentfrom the given data structure instance..ComplexTypeSegment(T aValue) Constructs theComplexTypeSegmentfrom the given data structure instance.ComplexTypeSegment(T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset) Constructs theComplexTypeSegmentfrom the given data structure instance.ComplexTypeSegment(T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegmentfrom the given data structure instance..ComplexTypeSegment(T aValue, String... aAttributes) Constructs theComplexTypeSegmentfrom the given data structure instance..ComplexTypeSegment(T aValue, TransmissionMetrics aTransmissionMetrics) Constructs theComplexTypeSegmentfrom the given data structure instance.ComplexTypeSegment(T aValue, TransmissionMetrics aTransmissionMetrics, String... aAttributes) Constructs theComplexTypeSegmentfrom the given data structure instance.. -
Method Summary
Modifier and TypeMethodDescriptionintfromTransmission(Sequence aSequence, int aOffset) (Re-)initializes this instance with the the givenSequencedata.getAlias()String[]Retrieves the attributes to process from the given data structure and the order in which the attributes are processed.org.refcodes.numerical.EndianessintRetrieves the length width (in bytes) from the length width (in bytes) property.getType()voidreceiveFrom(InputStream aInputStream, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream.voidsetPayload(T aValue) toString()withPayload(T aValue) Methods inherited from class org.refcodes.serial.SegmentComposite
equals, hashCode, toSchemaMethods inherited from class org.refcodes.serial.AbstractTransmissionComposite
getChildren, iterator, resetMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.refcodes.mixin.PayloadAccessor
getPayloadOrMethods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadProperty
letPayloadMethods inherited from interface org.refcodes.serial.Segment
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFromMethods inherited from interface org.refcodes.serial.Transmission
reset, transmitTo, transmitToMethods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitToMethods inherited from interface org.refcodes.serial.TransmissionComposite
getLength, toSequence, toSimpleTypeMap
-
Constructor Details
-
ComplexTypeSegment
Constructs theComplexTypeSegmentfrom the givenClassfor 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 invokeComplexTypeSegment(Class, TransmissionMetrics, String[])instead! The configuration attributes are taken from theTransmissionMetricsconfiguration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aType- The data structure's type.aTransmissionMetrics- TheTransmissionMetricsto be used for configuring this instance.
-
ComplexTypeSegment
public ComplexTypeSegment(Class<T> aType, TransmissionMetrics aTransmissionMetrics, String... aAttributes) Constructs theComplexTypeSegmentfrom the givenClassfor 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 theTransmissionMetricsconfiguration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aType- The data structure's type.aTransmissionMetrics- TheTransmissionMetricsto be used for configuring this instance.aAttributes- The attributes or null if all attributes are to be processed in alphabetical order.
-
ComplexTypeSegment
Constructs theComplexTypeSegmentfrom 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 invokeComplexTypeSegment(Class, TransmissionMetrics, String[])instead! The configuration attributes are taken from theTransmissionMetricsconfiguration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aValue- The data structure instance.aTransmissionMetrics- TheTransmissionMetricsto be used for configuring this instance.
-
ComplexTypeSegment
public ComplexTypeSegment(T aValue, TransmissionMetrics aTransmissionMetrics, String... aAttributes) Constructs theComplexTypeSegmentfrom 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 theTransmissionMetricsconfiguration 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- TheTransmissionMetricsto be used for configuring this instance.aAttributes- The attributes or null if all attributes are to be processed in alphabetical order.
-
ComplexTypeSegment
Constructs theComplexTypeSegmentfrom the givenClassfor 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 invokeComplexTypeSegment(Class, String[])instead!- Parameters:
aType- The data structure's type.
-
ComplexTypeSegment
Constructs theComplexTypeSegmentfrom the givenClassfor 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
Constructs theComplexTypeSegmentfrom 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 invokeComplexTypeSegment(Class, String[])instead!- Parameters:
aValue- The data structure instance.
-
ComplexTypeSegment
Constructs theComplexTypeSegmentfrom 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 theComplexTypeSegmentfrom the givenClassfor 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 invokeComplexTypeSegment(Class, String[])instead! -
ComplexTypeSegment
public ComplexTypeSegment(Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegmentfrom the givenClassfor 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- TheEndianessto be used for (length) values.aCharset- TheCharsetto be used for encoding and decodingStringinstances.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 theComplexTypeSegmentfrom 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 invokeComplexTypeSegment(Class, String[])instead! -
ComplexTypeSegment
public ComplexTypeSegment(T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegmentfrom 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- TheEndianessto be used for (length) values.aCharset- TheCharsetto be used for encoding and decodingStringinstances.aAttributes- The attributes or null if all attributes are to be processed in alphabetical order.
-
ComplexTypeSegment
Constructs theComplexTypeSegmentfrom the givenClassfor 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 invokeComplexTypeSegment(Class, String[])instead!- Parameters:
aAlias- The alias which identifies the content of this segment.aType- The data structure's type.
-
ComplexTypeSegment
Constructs theComplexTypeSegmentfrom the givenClassfor 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
Constructs theComplexTypeSegmentfrom 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 invokeComplexTypeSegment(Class, String[])instead!- Parameters:
aAlias- The alias which identifies the content of this segment.aValue- The data structure instance.
-
ComplexTypeSegment
Constructs theComplexTypeSegmentfrom 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 theComplexTypeSegmentfrom the givenClassfor 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 invokeComplexTypeSegment(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- TheEndianessto be used for (length) values.aCharset- TheCharsetto be used for encoding and decodingStringinstances.
-
ComplexTypeSegment
public ComplexTypeSegment(String aAlias, Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegmentfrom the givenClassfor 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- TheEndianessto be used for (length) values.aCharset- TheCharsetto be used for encoding and decodingStringinstances.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 theComplexTypeSegmentfrom 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 invokeComplexTypeSegment(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- TheEndianessto be used for (length) values.aCharset- TheCharsetto be used for encoding and decodingStringinstances.
-
ComplexTypeSegment
public ComplexTypeSegment(String aAlias, T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegmentfrom 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- TheEndianessto be used for (length) values.aCharset- TheCharsetto be used for encoding and decodingStringinstances.aAttributes- The attributes or null if all attributes are to be processed in alphabetical order.
-
-
Method Details
-
getType
- Specified by:
getTypein interfaceorg.refcodes.mixin.TypeAccessor<T>
-
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:
getLengthWidthin interfaceLengthWidthAccessor- Returns:
- The length width (in bytes) stored by the length width (in bytes) property.
-
getEndianess
public org.refcodes.numerical.Endianess getEndianess()- Specified by:
getEndianessin interfaceorg.refcodes.numerical.EndianessAccessor
-
getEncoding
- Specified by:
getEncodingin interfaceorg.refcodes.mixin.EncodingAccessor<T>
-
fromTransmission
(Re-)initializes this instance with the the givenSequencedata.- Specified by:
fromTransmissionin interfaceSegment- Overrides:
fromTransmissionin classSegmentComposite<Segment>- Parameters:
aSequence- TheSequencedata from which to (re-)initialize this instance.aOffset- The offset where to start processing the providedSequence.- Returns:
- The index after the last offset into the given
Sequenceprocessed by this method. - Throws:
TransmissionException- thrown in case a givenSequencecannot be processed.
-
receiveFrom
(Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream. Implementations providing error correction methods use the provided feedbackOutputStreamto do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.- Specified by:
receiveFromin interfaceSegment- Specified by:
receiveFromin interfaceSegment.SegmentMixin- Overrides:
receiveFromin classSegmentComposite<Segment>- Parameters:
aInputStream- TheInputStreamfrom which to read the instance's (re-)initializationSequencefrom.aReturnStream- AnOutputStreambeing 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 theInputStreamcaused problems.TransmissionException- thrown in case a given transmission cannot be processed.
-
getPayload
- Specified by:
getPayloadin interfaceorg.refcodes.mixin.PayloadAccessor<T>
-
withPayload
- Specified by:
withPayloadin interfaceorg.refcodes.mixin.PayloadAccessor.PayloadBuilder<T,PayloadTransmission<T>>
-
setPayload
- Specified by:
setPayloadin interfaceorg.refcodes.mixin.PayloadAccessor.PayloadMutator<T>
-
getAlias
- Specified by:
getAliasin interfaceorg.refcodes.mixin.AliasAccessor
-
toString
- Overrides:
toStringin classSegmentComposite<Segment>
-