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
,org.refcodes.mixin.Schemable<SerialSchema>
,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:
-
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
ConstructorDescriptionSegmentComposite
(CHILD... aSegments) SegmentComposite
(Collection<CHILD> aSegments) -
Method Summary
Modifier and TypeMethodDescriptionboolean
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
.toSchema()
Retrieves theSerialSchema
representing theTransmission
.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 org.refcodes.mixin.ChildrenAccessor
getChildren
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, toSequence, toSimpleTypeMap
-
Constructor Details
-
SegmentComposite
-
SegmentComposite
-
-
Method Details
-
fromTransmission
(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
Retrieves theSerialSchema
representing theTransmission
. Retrieving aSerialSchema
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 interfaceorg.refcodes.mixin.Schemable<CHILD extends Segment>
- Specified by:
toSchema
in interfaceTransmission
- Specified by:
toSchema
in interfaceTransmissionComposite<CHILD extends Segment>
- Returns:
- The
SerialSchema
representation of the implementing type for debugging and verification (or documentation) purposes.
-
hashCode
public int hashCode() -
equals
-
toString
- Overrides:
toString
in classAbstractTransmissionComposite<CHILD extends Segment>
-