-
- All Superinterfaces:
org.refcodes.mixin.LengthAccessor
,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
,MagicBytesSectionDispatcher
,PropertiesSection
,ReadyToReceiveSectionDecorator
,ReadyToSendSectionDecorator
,SectionComposite
,SegmentArraySection
,SequenceSection
,ShortArraySection
,StopAndWaitPacketStreamSectionDecorator
,StopAndWaitSectionDecorator
,StringArraySection
,StringSection
public interface Section extends Transmission
TheSection
interface enables an implementing type to provide aSequence
representation of itself or to transmit itsSequence
representation through anOutputStream
(with an optional feedbackInputStream
) as ofTransmission.transmitTo(OutputStream, InputStream)
and to initialize with aSequence
representation for itself or to receive aSequence
representation for itself through anInputStream
(with an optional feedbackOutputStream
) as ofreceiveFrom(InputStream, int, OutputStream)
. ASection
does not have a predictable length and it cannot (by itself) determine itself's length from a providedInputStream
orSequence
, therefore a length has to be provided alongside anInputStream
orSequence
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Section.SectionMixin
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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default 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, toSimpleTypeMap, toTransmission, transmitTo, transmitTo, transmitTo
-
-
-
-
Method Detail
-
fromTransmission
default void fromTransmission(byte[] aChunk, int aLength) throws TransmissionException
(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
default void fromTransmission(Sequence aSequence, int aLength) throws TransmissionException
(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
default void fromTransmission(byte[] aChunk, int aOffset, int aLength) throws TransmissionException
(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
void fromTransmission(Sequence aSequence, int aOffset, int aLength) throws TransmissionException
(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.
-
-