Interface SegmentReceiver

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

public interface SegmentReceiver extends SegmentDestination, org.refcodes.io.Receivable
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.ClosedProperty

    Nested classes/interfaces inherited from interface org.refcodes.component.ConnectableComponent

    org.refcodes.component.ConnectableComponent.ConnectableAutomaton

    Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor

    org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty

    Nested classes/interfaces inherited from interface org.refcodes.component.OpenedAccessor

    org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty
  • Method Summary

    Modifier and Type
    Method
    Description
    <SEGMENT extends Segment>
    SegmentResult<SEGMENT>
    onReceiveSegment(SEGMENT aSegment)
    Asynchronously receives a Segment's Sequence data (does not block this thread) and updates the Segment by invoking Segment.fromTransmission(Sequence).
    <SEGMENT extends Segment>
    void
    onReceiveSegment(SEGMENT aSegment, SegmentConsumer<SEGMENT> aSegmentConsumer)
    Asynchronously receives a Segment's Sequence data (does not block this thread) and updates the Segment by invoking Segment.fromTransmission(Sequence), passing the result to the callback SegmentConsumer.onSegment(Segment).
    <SEGMENT extends Segment>
    void
    receiveSegmentWithin(long aTimeoutMillis, SEGMENT aSegment)
    Receives a Segment (and blocks this thread) till all it's Sequence data has been received and updates the Segment by invoking Segment.fromTransmission(Sequence).

    Methods inherited from interface org.refcodes.io.Availability

    available, hasAvailable

    Methods inherited from interface org.refcodes.component.Closable

    close, closeIn, closeQuietly, closeUnchecked

    Methods inherited from interface org.refcodes.component.Closable.CloseAutomaton

    isClosable

    Methods inherited from interface org.refcodes.component.ClosedAccessor

    isClosed

    Methods inherited from interface org.refcodes.component.ConnectionStatusAccessor

    getConnectionStatus, isOpened

    Methods inherited from interface org.refcodes.serial.SegmentDestination

    receiveSegment
  • Method Details

    • receiveSegmentWithin

      <SEGMENT extends Segment> void receiveSegmentWithin(long aTimeoutMillis, SEGMENT aSegment) throws TransmissionException, IOException
      Receives a Segment (and blocks this thread) till all it's Sequence data has been received and updates the Segment by invoking Segment.fromTransmission(Sequence). This method blocks till all bytes are read or the timeout has been reached.
      Type Parameters:
      SEGMENT - The Segment type describing the Segment subclass of implementing Segment types.
      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 - The Segment to be (re-)initialized with the received data.
      Throws:
      TransmissionException - Thrown in case the received data cannot be used to (re-)initialize the given Segment.
      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 a Segment's Sequence data (does not block this thread) and updates the Segment by invoking Segment.fromTransmission(Sequence), passing the result to the callback SegmentConsumer.onSegment(Segment).
      Type Parameters:
      SEGMENT - The Segment type describing the Segment subclass of implementing Segment types.
      Parameters:
      aSegment - The Segment to be (re-)initialized with the received data.
      aSegmentConsumer - The callback asynchronously invoked upon having received the Segment.
      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 a Segment's Sequence data (does not block this thread) and updates the Segment by invoking Segment.fromTransmission(Sequence). The result is provided by the returned SegmentResult instance providing the (asynchronously) (re-)initialized provided Segment instance.
      Type Parameters:
      SEGMENT - The Segment type describing the Segment subclass used.
      Parameters:
      aSegment - The Segment to be (re-)initialized with the received data.
      Returns:
      The SegmentResult which provides the result (asynchronously).
      Throws:
      IOException - thrown in case of I/O issues (e.g. a closed connection) while receiving.