- All Superinterfaces:
org.refcodes.mixin.LengthAccessor
,org.refcodes.mixin.Resetable
,org.refcodes.mixin.Schemable
,Serializable
,Transmission
- All Known Subinterfaces:
ArraySegment<SEGMENT>
,DecoratorSegment<DECORATEE>
,PayloadSegment<T>
,Segment.SegmentMixin
- All Known Implementing Classes:
AbstractLengthDecoratorSegment
,AbstractPayloadSegment
,AbstractReferenceeLengthSegment
,AbstractSegmentDecorator
,AllocSectionDecoratorSegment
,AllocSegmentBody
,AllocSegmentHead
,AsciizArraySegment
,AsciizSegment
,AssertMagicBytesSegment
,AssertMagicBytesSegmentDecorator
,BooleanSegment
,BreakerSegmentDecorator
,ByteSegment
,CipherSegmentDecorator
,ComplexTypeSegment
,CrcSegmentDecorator
,DoubleSegment
,DynamicTypeSegment
,EnumSegment
,FixedLengthSequenceSegment
,FloatSegment
,IntSegment
,InvertibleSegmentDecorator
,LengthSegment
,LengthSegmentDecoratorSegment
,LongSegment
,MagicBytesSegment
,MagicBytesSegmentDecorator
,MagicBytesSegmentMultiplexer
,NullSegment
,NumberSegment
,ReadyToReceiveSegmentDecorator
,ReadyToSendSegmentDecorator
,SegmentComposite
,SequenceNumberSegment
,ShortSegment
,StopAndWaitPacketStreamSegmentDecorator
,StopAndWaitSegmentDecorator
,StringSegment
The
Segment
interface enables an implementing type to provide a
Sequence
representation of itself or to transmit its Sequence
representation through an OutputStream
(with an optional feedback
InputStream
) as of Transmission.transmitTo(OutputStream, InputStream)
and
to initialize with a Sequence
representation for itself or to receive
a Sequence
representation for itself through an InputStream
(with an optional feedback OutputStream
) as of
receiveFrom(InputStream, OutputStream)
. A Segment
has a
predictable length or it can (by itself) determine itself's length.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Default implementation of theSegment
interface providing an implementation of theSegment.SegmentMixin.receiveFrom(InputStream, OutputStream)
method using thefromTransmission(Sequence)
method or thefromTransmission(Sequence, int)
method.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.Transmission
Transmission.TransmissionMixin
-
Method Summary
Modifier and TypeMethodDescriptiondefault int
fromTransmission
(byte[] aChunk) (Re-)initializes this instance with the the given byte array data.default int
fromTransmission
(byte[] aChunk, int aOffset) (Re-)initializes this instance with the the given byte array data.default int
fromTransmission
(Sequence aSequence) (Re-)initializes this instance with the the givenSequence
data.int
fromTransmission
(Sequence aSequence, int aOffset) (Re-)initializes this instance with the the givenSequence
data.default void
receiveFrom
(InputStream aInputStream) (Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.void
receiveFrom
(InputStream aInputStream, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.default void
receiveFrom
(SerialTransceiver aSerialTransceiver) (Re-)initializes this instance by receiving the accordingSequence
from the givenSerialTransceiver
'sInputStream
.Methods inherited from interface org.refcodes.serial.Transmission
getLength, reset, toSchema, toSequence, toSimpleTypeMap, transmitTo, transmitTo, transmitTo
-
Method Details
-
fromTransmission
(Re-)initializes this instance with the the given byte array data.- Parameters:
aChunk
- The byte array data from which to (re-)initialize this instance.- Returns:
- The index after the last offset into the given byte array processed by this method.
- Throws:
TransmissionException
- thrown in case a givenSequence
cannot be processed.
-
fromTransmission
(Re-)initializes this instance with the the givenSequence
data.- Parameters:
aSequence
- TheSequence
data from which to (re-)initialize this instance.- 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.
-
fromTransmission
(Re-)initializes this instance with the the given byte array data.- Parameters:
aChunk
- The byte array data from which to (re-)initialize this instance.aOffset
- The offset where to start processing the provided byte array.- Returns:
- The index after the last offset into the given byte array processed by this method.
- Throws:
TransmissionException
- thrown in case a givenSequence
cannot be processed.
-
fromTransmission
(Re-)initializes this instance with the the givenSequence
data.- 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
. This is a convenience method in case there is no feedbackOutputStream
available (actually thereceiveFrom(InputStream, OutputStream)
method is invoked withnull
for the feedbackOutputStream
). OverridereceiveFrom(InputStream, OutputStream)
for your custom receiving functionality.- Parameters:
aInputStream
- TheInputStream
from which to read the instance's (re-)initializationSequence
from.- Throws:
IOException
- thrown in case reading data from theInputStream
caused problems.TransmissionException
- thrown in case a given transmission cannot be processed.
-
receiveFrom
(Re-)initializes this instance by receiving the accordingSequence
from the givenSerialTransceiver
'sInputStream
. Implementations providing error correction methods use the providedSerialTransceiver
's feedbackOutputStream
to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data. This is a convenience method (actually thereceiveFrom(InputStream, OutputStream)
method is invoked). OverridereceiveFrom(InputStream, OutputStream)
for your custom receiving functionality.- Parameters:
aSerialTransceiver
- TheSerialTransceiver
providing theInputStream
where to read this instance'sSequence
from and providing theOutputStream
being the feedback channel to handle "stop-and-wait ARQ".- Throws:
IOException
- thrown in case reading data from theInputStream
caused problems.TransmissionException
- thrown in case a given transmission 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.- 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.
-