- 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.Schemable
,org.refcodes.mixin.TypeAccessor<T>
,org.refcodes.numerical.EndianessAccessor
,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 AbstractSchema.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.AliasProperty
Nested 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.EndianessProperty
Nested 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.LengthProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.LengthWidthAccessor
LengthWidthAccessor.LengthWidthBuilder<B extends LengthWidthAccessor.LengthWidthBuilder<B>>, LengthWidthAccessor.LengthWidthMutator, LengthWidthAccessor.LengthWidthProperty
Nested 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.SegmentMixin
Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin
Nested 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 theComplexTypeSegment
from the givenClass
for the according type T.ComplexTypeSegment
(Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset) Constructs theComplexTypeSegment
from the givenClass
for the according type T.ComplexTypeSegment
(Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegment
from the givenClass
for the according type T.ComplexTypeSegment
(Class<T> aType, String... aAttributes) Constructs theComplexTypeSegment
from the givenClass
for the according type T.ComplexTypeSegment
(Class<T> aType, TransmissionMetrics aTransmissionMetrics) Constructs theComplexTypeSegment
from the givenClass
for the according type T.ComplexTypeSegment
(Class<T> aType, TransmissionMetrics aTransmissionMetrics, String... aAttributes) Constructs theComplexTypeSegment
from the givenClass
for the according type T.ComplexTypeSegment
(String aAlias, Class<T> aType) Constructs theComplexTypeSegment
from the givenClass
for the according type T.ComplexTypeSegment
(String aAlias, Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset) Constructs theComplexTypeSegment
from the givenClass
for the according type T.ComplexTypeSegment
(String aAlias, Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegment
from the givenClass
for the according type T.ComplexTypeSegment
(String aAlias, Class<T> aType, String... aAttributes) Constructs theComplexTypeSegment
from the givenClass
for the according type T.ComplexTypeSegment
(String aAlias, T aValue) Constructs theComplexTypeSegment
from the given data structure instance.ComplexTypeSegment
(String aAlias, T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset) Constructs theComplexTypeSegment
from the given data structure instance.ComplexTypeSegment
(String aAlias, T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegment
from the given data structure instance..ComplexTypeSegment
(String aAlias, T aValue, String... aAttributes) Constructs theComplexTypeSegment
from the given data structure instance..ComplexTypeSegment
(T aValue) Constructs theComplexTypeSegment
from the given data structure instance.ComplexTypeSegment
(T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset) Constructs theComplexTypeSegment
from the given data structure instance.ComplexTypeSegment
(T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegment
from the given data structure instance..ComplexTypeSegment
(T aValue, String... aAttributes) Constructs theComplexTypeSegment
from the given data structure instance..ComplexTypeSegment
(T aValue, TransmissionMetrics aTransmissionMetrics) Constructs theComplexTypeSegment
from the given data structure instance.ComplexTypeSegment
(T aValue, TransmissionMetrics aTransmissionMetrics, String... aAttributes) Constructs theComplexTypeSegment
from the given data structure instance.. -
Method Summary
Modifier and TypeMethodDescriptionint
fromTransmission
(Sequence aSequence, int aOffset) (Re-)initializes this instance with the the givenSequence
data.getAlias()
String[]
Retrieves the attributes to process from the given data structure and the order in which the attributes are processed.org.refcodes.numerical.Endianess
int
Retrieves the length width (in bytes) from the length width (in bytes) property.getType()
void
receiveFrom
(InputStream aInputStream, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.void
setPayload
(T aValue) toString()
withPayload
(T aValue) Methods inherited from class org.refcodes.serial.SegmentComposite
equals, hashCode, toSchema
Methods inherited from class org.refcodes.serial.AbstractTransmissionComposite
getChildren, iterator
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.refcodes.mixin.PayloadAccessor
getPayloadOr
Methods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadProperty
letPayload
Methods inherited from interface org.refcodes.serial.Segment
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFrom
Methods inherited from interface org.refcodes.serial.Transmission
transmitTo, transmitTo
Methods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitTo
Methods inherited from interface org.refcodes.serial.TransmissionComposite
getLength, toSequence, toSimpleTypeMap
-
Constructor Details
-
ComplexTypeSegment
Constructs theComplexTypeSegment
from the givenClass
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 invokeComplexTypeSegment(Class, TransmissionMetrics, String[])
instead! The configuration attributes are taken from theTransmissionMetrics
configuration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aType
- The data structure's type.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.
-
ComplexTypeSegment
public ComplexTypeSegment(Class<T> aType, TransmissionMetrics aTransmissionMetrics, String... aAttributes) Constructs theComplexTypeSegment
from the givenClass
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 theTransmissionMetrics
configuration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aType
- The data structure's type.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.aAttributes
- The attributes or null if all attributes are to be processed in alphabetical order.
-
ComplexTypeSegment
Constructs theComplexTypeSegment
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 invokeComplexTypeSegment(Class, TransmissionMetrics, String[])
instead! The configuration attributes are taken from theTransmissionMetrics
configuration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aValue
- The data structure instance.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.
-
ComplexTypeSegment
public ComplexTypeSegment(T aValue, TransmissionMetrics aTransmissionMetrics, String... aAttributes) Constructs theComplexTypeSegment
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 theTransmissionMetrics
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
- TheTransmissionMetrics
to be used for configuring this instance.aAttributes
- The attributes or null if all attributes are to be processed in alphabetical order.
-
ComplexTypeSegment
Constructs theComplexTypeSegment
from the givenClass
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 invokeComplexTypeSegment(Class, String[])
instead!- Parameters:
aType
- The data structure's type.
-
ComplexTypeSegment
Constructs theComplexTypeSegment
from the givenClass
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
Constructs theComplexTypeSegment
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 invokeComplexTypeSegment(Class, String[])
instead!- Parameters:
aValue
- The data structure instance.
-
ComplexTypeSegment
Constructs theComplexTypeSegment
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 theComplexTypeSegment
from the givenClass
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 invokeComplexTypeSegment(Class, String[])
instead! -
ComplexTypeSegment
public ComplexTypeSegment(Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegment
from the givenClass
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
- TheEndianess
to be used for (length) values.aCharset
- TheCharset
to be used for encoding and decodingString
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 theComplexTypeSegment
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 invokeComplexTypeSegment(Class, String[])
instead! -
ComplexTypeSegment
public ComplexTypeSegment(T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegment
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
- TheEndianess
to be used for (length) values.aCharset
- TheCharset
to be used for encoding and decodingString
instances.aAttributes
- The attributes or null if all attributes are to be processed in alphabetical order.
-
ComplexTypeSegment
Constructs theComplexTypeSegment
from the givenClass
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 invokeComplexTypeSegment(Class, String[])
instead!- Parameters:
aAlias
- The alias which identifies the content of this segment.aType
- The data structure's type.
-
ComplexTypeSegment
Constructs theComplexTypeSegment
from the givenClass
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
Constructs theComplexTypeSegment
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 invokeComplexTypeSegment(Class, String[])
instead!- Parameters:
aAlias
- The alias which identifies the content of this segment.aValue
- The data structure instance.
-
ComplexTypeSegment
Constructs theComplexTypeSegment
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 theComplexTypeSegment
from the givenClass
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 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
- TheEndianess
to be used for (length) values.aCharset
- TheCharset
to be used for encoding and decodingString
instances.
-
ComplexTypeSegment
public ComplexTypeSegment(String aAlias, Class<T> aType, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegment
from the givenClass
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
- TheEndianess
to be used for (length) values.aCharset
- TheCharset
to be used for encoding and decodingString
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 theComplexTypeSegment
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 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
- TheEndianess
to be used for (length) values.aCharset
- TheCharset
to be used for encoding and decodingString
instances.
-
ComplexTypeSegment
public ComplexTypeSegment(String aAlias, T aValue, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aAttributes) Constructs theComplexTypeSegment
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
- TheEndianess
to be used for (length) values.aCharset
- TheCharset
to be used for encoding and decodingString
instances.aAttributes
- The attributes or null if all attributes are to be processed in alphabetical order.
-
-
Method Details
-
getType
- Specified by:
getType
in 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:
getLengthWidth
in interfaceLengthWidthAccessor
- 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 interfaceorg.refcodes.numerical.EndianessAccessor
-
getEncoding
- Specified by:
getEncoding
in interfaceorg.refcodes.mixin.EncodingAccessor<T>
-
fromTransmission
(Re-)initializes this instance with the the givenSequence
data.- Specified by:
fromTransmission
in interfaceSegment
- Overrides:
fromTransmission
in classSegmentComposite<Segment>
- Parameters:
aSequence
- TheSequence
data 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
Sequence
processed by this method. - Throws:
TransmissionException
- thrown in case a givenSequence
cannot be processed.
-
receiveFrom
(Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
. Implementations providing error correction methods use the provided feedbackOutputStream
to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.- Specified by:
receiveFrom
in interfaceSegment
- Specified by:
receiveFrom
in interfaceSegment.SegmentMixin
- Overrides:
receiveFrom
in classSegmentComposite<Segment>
- Parameters:
aInputStream
- TheInputStream
from which to read the instance's (re-)initializationSequence
from.aReturnStream
- AnOutputStream
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 theInputStream
caused problems.TransmissionException
- thrown in case a given transmission cannot be processed.
-
getPayload
- Specified by:
getPayload
in interfaceorg.refcodes.mixin.PayloadAccessor<T>
-
withPayload
- Specified by:
withPayload
in interfaceorg.refcodes.mixin.PayloadAccessor.PayloadBuilder<T,
PayloadTransmission<T>>
-
setPayload
- Specified by:
setPayload
in interfaceorg.refcodes.mixin.PayloadAccessor.PayloadMutator<T>
-
getAlias
- Specified by:
getAlias
in interfaceorg.refcodes.mixin.AliasAccessor
-
toString
- Overrides:
toString
in classSegmentComposite<Segment>
-