DECORATEE
- The type of the Segment
decoratee.Serializable
, org.refcodes.mixin.LengthAccessor
, AllocLengthAccessor
, AllocLengthAccessor.AllocLengthMutator
, AllocLengthAccessor.AllocLengthProperty
, Segment
, Transmission
, Transmission.TransmissionMixin
public class AllocSegmentBody<DECORATEE extends Section> extends AbstractTransmissionDecorator<DECORATEE> implements Segment, AllocLengthAccessor.AllocLengthProperty
AllocSegmentBody
provides an Segment
with an allocation
length. An AllocSegmentHead
provides the allocation length for a
AllocSegmentBody
. Therefore the AllocSegmentHead
references a
AllocSegmentBody
. The AllocSegmentHead
manages the
Sequence
regarding the allocation length whereas the
AllocSegmentBody
manages the decorated Segment
by harnessing
the allocation length provided by the AllocSegmentHead
.AllocLengthAccessor.AllocLengthBuilder<B extends AllocLengthAccessor.AllocLengthBuilder<B>>, AllocLengthAccessor.AllocLengthMutator, AllocLengthAccessor.AllocLengthProperty
org.refcodes.mixin.DecorateeAccessor.DecorateeBuilder<DECORATEE extends Object,B extends org.refcodes.mixin.DecorateeAccessor.DecorateeBuilder<DECORATEE,B>>, org.refcodes.mixin.DecorateeAccessor.DecorateeMutator<DECORATEE extends Object>, org.refcodes.mixin.DecorateeAccessor.DecorateeProperty<DECORATEE extends Object>
org.refcodes.mixin.LengthAccessor.LengthBuilder<B extends org.refcodes.mixin.LengthAccessor.LengthBuilder<B>>, org.refcodes.mixin.LengthAccessor.LengthMutator, org.refcodes.mixin.LengthAccessor.LengthProperty
Segment.SegmentMixin
Transmission.TransmissionMixin
_decoratee
Constructor | Description |
---|---|
AllocSegmentBody(DECORATEE aDecoratee) |
Constructs the decorator with the given decoratee and a width of
TransmissionMetrics.DEFAULT_LENGTH_WIDTH bytes used to specify
the decoratee's length a TransmissionMetrics.DEFAULT_ENDIANESS
endian representation of the decoratee's length. |
Modifier and Type | Method | Description |
---|---|---|
int |
fromTransmission(Sequence aSequence,
int aOffset) |
(Re-)initializes this instance with the the given
Sequence data. |
int |
getAllocLength() |
Retrieves the allocated length.
|
void |
receiveFrom(InputStream aInputStream,
OutputStream aReturnStream) |
(Re-)initializes this instance by receiving the according
Sequence from the given InputStream . |
void |
setAllocLength(int aValue) |
Sets the allocated length.
|
Schema |
toSchema() |
Retrieves the
Schema representing the Transmission . |
equals, getDecoratee, getLength, hashCode, toSimpleTypeMap, toString, toTransmission
letAllocLength
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFrom
fromInputStream, getLength, toSimpleTypeMap, toTransmission, transmitTo, transmitTo, transmitTo
transmitTo
public AllocSegmentBody(DECORATEE aDecoratee)
TransmissionMetrics.DEFAULT_LENGTH_WIDTH
bytes used to specify
the decoratee's length a TransmissionMetrics.DEFAULT_ENDIANESS
endian representation of the decoratee's length.aDecoratee
- The decoratee used for this decorator.public int fromTransmission(Sequence aSequence, int aOffset) throws TransmissionException
Sequence
data.fromTransmission
in interface Segment
aSequence
- The Sequence
data from which to (re-)initialize
this instance.aOffset
- The offset where to start processing the provided
Sequence
.Sequence
processed by this method.TransmissionException
- thrown in case a given Sequence
cannot be processed.public void receiveFrom(InputStream aInputStream, OutputStream aReturnStream) throws IOException, TransmissionException
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.receiveFrom
in interface Segment
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.IOException
- thrown in case reading data from the
InputStream
caused problems.TransmissionException
- thrown in case a given transmission cannot
be processed.public int getAllocLength()
getAllocLength
in interface AllocLengthAccessor
public void setAllocLength(int aValue)
setAllocLength
in interface AllocLengthAccessor.AllocLengthMutator
aValue
- The allocated length.public Schema toSchema()
Schema
representing the Transmission
.
Retrieving a Schema
is useful when analyzing and debugging data
structures such as a AllocSectionDecoratorSegment
instance to help
document, learn and verify on the structure (as well as the content) of
that very AllocSectionDecoratorSegment
.toSchema
in interface Transmission
Schema
representation of the implementing type for
debugging and verification (or documentation) purposes.Copyright © 2021. All rights reserved.