Module org.refcodes.serial
Package org.refcodes.serial
Class SegmentComposite<CHILD extends Segment>
- java.lang.Object
-
- org.refcodes.serial.AbstractTransmissionComposite<CHILD>
-
- org.refcodes.serial.SegmentComposite<CHILD>
-
- Type Parameters:
CHILD
- The type of the child elements to be contained in this instance.
- All Implemented Interfaces:
Serializable
,Iterable<CHILD>
,org.refcodes.mixin.ChildrenAccessor<CHILD[]>
,org.refcodes.mixin.LengthAccessor
,Segment
,Segment.SegmentMixin
,Transmission
,Transmission.TransmissionMixin
,TransmissionComposite<CHILD>
- Direct Known Subclasses:
ComplexTypeSegment
public class SegmentComposite<CHILD extends Segment> extends AbstractTransmissionComposite<CHILD> implements Segment, Segment.SegmentMixin, TransmissionComposite<CHILD>
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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.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.Segment
Segment.SegmentMixin
-
Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin
-
-
Field Summary
-
Fields inherited from class org.refcodes.serial.AbstractTransmissionComposite
_children
-
-
Constructor Summary
Constructors Constructor Description SegmentComposite(CHILD... aSegments)
SegmentComposite(Collection<CHILD> aSegments)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
int
fromTransmission(Sequence aSequence, int aOffset)
(Re-)initializes this instance with the the givenSequence
data.int
hashCode()
void
receiveFrom(InputStream aInputStream, OutputStream aReturnStream)
(Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.Schema
toSchema()
Retrieves theSchema
representing theTransmission
.String
toString()
-
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.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, toSimpleTypeMap, toTransmission
-
-
-
-
Constructor Detail
-
SegmentComposite
public SegmentComposite(Collection<CHILD> aSegments)
-
SegmentComposite
@SafeVarargs public SegmentComposite(CHILD... aSegments)
-
-
Method Detail
-
fromTransmission
public int fromTransmission(Sequence aSequence, int aOffset) throws TransmissionException
(Re-)initializes this instance with the the givenSequence
data.- Specified by:
fromTransmission
in interfaceSegment
- 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
public void receiveFrom(InputStream aInputStream, OutputStream aReturnStream) throws IOException, TransmissionException
(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
- 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.
-
toSchema
public Schema toSchema()
Retrieves theSchema
representing theTransmission
. Retrieving aSchema
is useful when analyzing and debugging data structures such as aAllocSectionDecoratorSegment
instance to help document, learn and verify on the structure (as well as the content) of that veryAllocSectionDecoratorSegment
.- Specified by:
toSchema
in interfaceTransmission
- Specified by:
toSchema
in interfaceTransmissionComposite<CHILD extends Segment>
- Returns:
- The
Schema
representation of the implementing type for debugging and verification (or documentation) purposes.
-
toString
public String toString()
- Overrides:
toString
in classAbstractTransmissionComposite<CHILD extends Segment>
-
-