- All Superinterfaces:
org.refcodes.io.Availability,org.refcodes.component.Closable,org.refcodes.component.Closable.CloseAutomaton,org.refcodes.component.ClosedAccessor,org.refcodes.component.ConnectableComponent,org.refcodes.component.ConnectableComponent.ConnectableAutomaton,org.refcodes.component.ConnectionStatusAccessor,org.refcodes.component.OpenedAccessor,org.refcodes.io.Receivable,SegmentDestination
- All Known Subinterfaces:
Port<PM>,SegmentTransceiver,SerialReceiver,SerialTransceiver
- All Known Implementing Classes:
AbstractPort,AbstractPortDecorator,CrossoverLoopbackPort,LoopbackPort
The
SegmentReceiver is used to receive Segment instances in a
unified way.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.component.Closable
org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>Nested classes/interfaces inherited from interface org.refcodes.component.ClosedAccessor
org.refcodes.component.ClosedAccessor.ClosedMutator, org.refcodes.component.ClosedAccessor.ClosedPropertyNested classes/interfaces inherited from interface org.refcodes.component.ConnectableComponent
org.refcodes.component.ConnectableComponent.ConnectableAutomatonNested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor
org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusPropertyNested classes/interfaces inherited from interface org.refcodes.component.OpenedAccessor
org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty -
Method Summary
Modifier and TypeMethodDescription<SEGMENT extends Segment>
SegmentResult<SEGMENT>onReceiveSegment(SEGMENT aSegment) Asynchronously receives aSegment'sSequencedata (does not block this thread) and updates theSegmentby invokingSegment.fromTransmission(Sequence).<SEGMENT extends Segment>
voidonReceiveSegment(SEGMENT aSegment, SegmentConsumer<SEGMENT> aSegmentConsumer) Asynchronously receives aSegment'sSequencedata (does not block this thread) and updates theSegmentby invokingSegment.fromTransmission(Sequence), passing the result to the callbackSegmentConsumer.onSegment(Segment).<SEGMENT extends Segment>
voidreceiveSegmentWithin(long aTimeoutMillis, SEGMENT aSegment) Receives aSegment(and blocks this thread) till all it'sSequencedata has been received and updates theSegmentby invokingSegment.fromTransmission(Sequence).Methods inherited from interface org.refcodes.io.Availability
available, hasAvailableMethods inherited from interface org.refcodes.component.Closable
close, closeIn, closeQuietly, closeUncheckedMethods inherited from interface org.refcodes.component.Closable.CloseAutomaton
isClosableMethods inherited from interface org.refcodes.component.ClosedAccessor
isClosedMethods inherited from interface org.refcodes.component.ConnectionStatusAccessor
getConnectionStatus, isOpenedMethods inherited from interface org.refcodes.serial.SegmentDestination
receiveSegment
-
Method Details
-
receiveSegmentWithin
<SEGMENT extends Segment> void receiveSegmentWithin(long aTimeoutMillis, SEGMENT aSegment) throws IOException Receives aSegment(and blocks this thread) till all it'sSequencedata has been received and updates theSegmentby invokingSegment.fromTransmission(Sequence). This method blocks till all bytes are read or the timeout has been reached.- Type Parameters:
SEGMENT- TheSegmenttype describing theSegmentsubclass of implementingSegmenttypes.- Parameters:
aTimeoutMillis- The default timeout for read operations not explicitly called with a timeout argument. With a value of -1 timeout handling is disabled (blocking mode) or a technical timeout occurs (implementation depended).aSegment- TheSegmentto be (re-)initialized with the received data.- Throws:
TransmissionException- Thrown in case the received data cannot be used to (re-)initialize the givenSegment.IOException- thrown in case of I/O issues (e.g. a timeout) while receiving.
-
onReceiveSegment
<SEGMENT extends Segment> void onReceiveSegment(SEGMENT aSegment, SegmentConsumer<SEGMENT> aSegmentConsumer) throws IOException Asynchronously receives aSegment'sSequencedata (does not block this thread) and updates theSegmentby invokingSegment.fromTransmission(Sequence), passing the result to the callbackSegmentConsumer.onSegment(Segment).- Type Parameters:
SEGMENT- TheSegmenttype describing theSegmentsubclass of implementingSegmenttypes.- Parameters:
aSegment- TheSegmentto be (re-)initialized with the received data.aSegmentConsumer- The callback asynchronously invoked upon having received theSegment.- Throws:
IOException- thrown in case of I/O issues (e.g. a closed connection) while receiving.
-
onReceiveSegment
<SEGMENT extends Segment> SegmentResult<SEGMENT> onReceiveSegment(SEGMENT aSegment) throws IOException Asynchronously receives aSegment'sSequencedata (does not block this thread) and updates theSegmentby invokingSegment.fromTransmission(Sequence). The result is provided by the returnedSegmentResultinstance providing the (asynchronously) (re-)initialized providedSegmentinstance.- Type Parameters:
SEGMENT- TheSegmenttype describing theSegmentsubclass used.- Parameters:
aSegment- TheSegmentto be (re-)initialized with the received data.- Returns:
- The
SegmentResultwhich provides the result (asynchronously). - Throws:
IOException- thrown in case of I/O issues (e.g. a closed connection) while receiving.
-