Interface Segment
- All Superinterfaces:
Diagnosable, LengthAccessor, Resetable, Schemable<DiagnosticOptions>, 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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceDefault implementation of theSegmentinterface 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 LengthAccessor
LengthAccessor.LengthBuilder<B>, LengthAccessor.LengthMutator, LengthAccessor.LengthPropertyNested classes/interfaces inherited from interface Transmission
Transmission.TransmissionMixin -
Method Summary
Modifier and TypeMethodDescriptiondefault intfromTransmission(byte[] aChunk) (Re-)initializes this instance with the the given byte array data.default intfromTransmission(byte[] aChunk, int aOffset) (Re-)initializes this instance with the the given byte array data.default intfromTransmission(Sequence aSequence) (Re-)initializes this instance with the the givenSequencedata.intfromTransmission(Sequence aSequence, int aOffset) (Re-)initializes this instance with the the givenSequencedata.default voidreceiveFrom(InputStream aInputStream) (Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream.voidreceiveFrom(InputStream aInputStream, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream.default voidreceiveFrom(SerialTransceiver aSerialTransceiver) (Re-)initializes this instance by receiving the accordingSequencefrom the givenSerialTransceiver'sInputStream.Methods inherited from interface Transmission
getLength, reset, toSequence, toSimpleTypeTable, 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 givenSequencecannot be processed.
-
fromTransmission
(Re-)initializes this instance with the the givenSequencedata.- Parameters:
aSequence- TheSequencedata from which to (re-)initialize this instance.- Returns:
- The index after the last offset into the given
Sequenceprocessed by this method. - Throws:
TransmissionException- thrown in case a givenSequencecannot 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 givenSequencecannot be processed.
-
fromTransmission
(Re-)initializes this instance with the the givenSequencedata.- Parameters:
aSequence- TheSequencedata 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
Sequenceprocessed by this method. - Throws:
TransmissionException- thrown in case a givenSequencecannot be processed.
-
receiveFrom
(Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream. This is a convenience method in case there is no feedbackOutputStreamavailable (actually thereceiveFrom(InputStream, OutputStream)method is invoked withnullfor the feedbackOutputStream). OverridereceiveFrom(InputStream, OutputStream)for your custom receiving functionality.- Parameters:
aInputStream- TheInputStreamfrom which to read the instance's (re-)initializationSequencefrom.- Throws:
IOException- thrown in case reading data from theInputStreamcaused problems.
-
receiveFrom
(Re-)initializes this instance by receiving the accordingSequencefrom the givenSerialTransceiver'sInputStream. Implementations providing error correction methods use the providedSerialTransceiver's feedbackOutputStreamto 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- TheSerialTransceiverproviding theInputStreamwhere to read this instance'sSequencefrom and providing theOutputStreambeing the feedback channel to handle "stop-and-wait ARQ".- Throws:
IOException- thrown in case reading data from theInputStreamcaused problems.
-
receiveFrom
(Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream. Implementations providing error correction methods use the provided feedbackOutputStreamto do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.- Parameters:
aInputStream- TheInputStreamfrom which to read the instance's (re-)initializationSequencefrom.aReturnStream- AnOutputStreambeing 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 theInputStreamcaused problems.
-