- All Superinterfaces:
org.refcodes.mixin.LengthAccessor
,org.refcodes.mixin.Schemable
,Serializable
,Transmission
- All Known Subinterfaces:
ArraySection<ARRAY>
,DecoratorSection<DECORATEE>
,PayloadSection<T>
,Section.SectionMixin
- All Known Implementing Classes:
AbstractPayloadSection
,AbstractSectionDecorator
,AssertMagicBytesSectionDecorator
,BooleanArraySection
,BreakerSectionDecorator
,ByteArraySection
,CharArraySection
,CharSection
,CipherSectionDecorator
,CrcSectionDecorator
,DoubleArraySection
,DynamicTypeSection
,FileSection
,FixedSegmentArraySection
,FloatArraySection
,IntArraySection
,InvertibleSectionDecorator
,LongArraySection
,MagicBytesSectionDecorator
,MagicBytesSectionMultiplexer
,PropertiesSection
,ReadyToReceiveSectionDecorator
,ReadyToSendSectionDecorator
,SectionComposite
,SegmentArraySection
,SequenceSection
,ShortArraySection
,StopAndWaitPacketStreamSectionDecorator
,StopAndWaitSectionDecorator
,StringArraySection
,StringSection
The
Section
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, int, OutputStream)
. A Section
does
not have a predictable length and it cannot (by itself) determine itself's
length from a provided InputStream
or Sequence
, therefore a
length has to be provided alongside an InputStream
or
Sequence
.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Default implementation of theSection
interface providing an implementation of theSection.SectionMixin.receiveFrom(InputStream, int, OutputStream)
method using thefromTransmission(Sequence, int)
method or thefromTransmission(Sequence, int, 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 void
fromTransmission
(byte[] aChunk, int aLength) (Re-)initializes this instance with the the given byte array data.default void
fromTransmission
(byte[] aChunk, int aOffset, int aLength) (Re-)initializes this instance with the the given byte array data.default void
fromTransmission
(Sequence aSequence, int aLength) (Re-)initializes this instance with the the givenSequence
data.void
fromTransmission
(Sequence aSequence, int aOffset, int aLength) (Re-)initializes this instance with the the givenSequence
data.default void
receiveFrom
(InputStream aInputStream, int aLength) (Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.void
receiveFrom
(InputStream aInputStream, int aLength, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.default void
receiveFrom
(SerialTransceiver aSerialTransceiver, int aLength) (Re-)initializes this instance by receiving the accordingSequence
from the givenSerialTransceiver
'sInputStream
.Methods inherited from interface org.refcodes.serial.Transmission
getLength, 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.aLength
- The length of data assigned by the byte array.- 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.aLength
- The length of data assigned by theSequence
.- 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.aLength
- The length of data assigned by the byte array.- 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
.aLength
- The length of data assigned by theSequence
.- Throws:
TransmissionException
- thrown in case a givenSequence
cannot be processed.
-
receiveFrom
default void receiveFrom(SerialTransceiver aSerialTransceiver, int aLength) throws IOException, TransmissionException (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, int, OutputStream)
method is invoked). OverridereceiveFrom(InputStream, int, 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".aLength
- The length of data assigned by the byte array.- Throws:
IOException
- thrown in case reading data from theInputStream
caused problems.TransmissionException
- thrown in case a givenInputStream
bytes cannot be processed.
-
receiveFrom
default void receiveFrom(InputStream aInputStream, int aLength) throws IOException, TransmissionException (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, int, OutputStream)
method is invoked withnull
for the feedbackOutputStream
). OverridereceiveFrom(InputStream, int, OutputStream)
for your custom receiving functionality.- Parameters:
aInputStream
- TheInputStream
from which to read the instance's (re-)initializationSequence
from.aLength
- The length of data assigned by the byte array.- Throws:
IOException
- thrown in case reading data from theInputStream
caused problems.TransmissionException
- thrown in case a givenInputStream
bytes cannot be processed.
-
receiveFrom
void receiveFrom(InputStream aInputStream, int aLength, 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.- Parameters:
aInputStream
- TheInputStream
from which to read the instance's (re-)initializationSequence
from.aLength
- The length of data assigned by the byte array.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 givenInputStream
bytes cannot be processed.
-