DATA
- the generic typeorg.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
, Availability
, DatagramDestination<DATA>
, DatagramReceiver<DATA>
, DatagramsDestination<DATA>
, DatagramsReceiver<DATA>
, Receivable
public class DatagramsReceiverDecorator<DATA extends Serializable> extends AbstractDatagramsReceiver<DATA> implements DatagramsReceiver<DATA>
DatagramsReceiverDecorator
decorates a
DatagramsDestination
with the additional methods of a
DatagramsReceiver
making it easy to use a
DatagramsDestination
wherever a DatagramsReceiver
is
expected.org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
org.refcodes.component.ClosedAccessor.ClosedMutator, org.refcodes.component.ClosedAccessor.ClosedProperty
org.refcodes.component.ConnectableComponent.ConnectableAutomaton
DATAGRAM_QUEUE_SIZE
Constructor | Description |
---|---|
DatagramsReceiverDecorator(DatagramsDestination<DATA> aProvider) |
Instantiates a new receiver decorator.
|
Modifier and Type | Method | Description |
---|---|---|
int |
available() |
Determines the number of available datagram from a
DatagramTransmitter . |
void |
close() |
|
DATA |
receive() |
Reads (receives) the next datagram passed from a
DatagramTransmitter counterpart. |
DATA[] |
receive(int aMaxSize) |
Similar to
DatagramsDestination.receiveAll() though at maximum the amount of data as
provided returned. |
DATA[] |
receiveAll() |
Reads (receives) the all currently available data.
|
getConnectionStatus, isClosable, isClosed, isOpenable, isOpened, open, setConnectionStatus
pushDatagram, pushDatagrams, pushDatagrams
hasAvailable
closeIn, closeQuietly, closeUnchecked
getConnectionStatus, isOpened
receive
public DatagramsReceiverDecorator(DatagramsDestination<DATA> aProvider)
aProvider
- the providerpublic DATA receive() throws IOException
DatagramTransmitter
counterpart. In case none datagram is
available, then this method blocks until one is available. To prevent
blocking, use the DatagramReceiver
extension's
Availability.available()
method to test beforehand whether a
byte is available (in a multi-threaded usage scenario,
Availability.available()
is not a reliable indicator whether
this method will block or not). When a Thread
is waiting for a
datagram to be read and Thread.interrupt()
is being called, then
the operation is aborted and an InterruptedException
is thrown.receive
in interface DatagramDestination<DATA extends Serializable>
receive
in interface DatagramsDestination<DATA extends Serializable>
receive
in class AbstractDatagramsReceiver<DATA extends Serializable>
DatagramTransmitter
counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public int available() throws IOException
DatagramTransmitter
. Use the DatagramDestination
extenison's DatagramDestination.receive()
method for retrieving
available datagrams.available
in interface Availability
available
in class AbstractDatagramsReceiver<DATA extends Serializable>
IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public DATA[] receiveAll() throws IOException
receiveAll
in interface DatagramsDestination<DATA extends Serializable>
receiveAll
in interface DatagramsReceiver<DATA extends Serializable>
receiveAll
in class AbstractDatagramsReceiver<DATA extends Serializable>
DatagramsTransmitter
or DatagramReceiver
counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public DATA[] receive(int aMaxSize) throws IOException
DatagramsDestination.receiveAll()
though at maximum the amount of data as
provided returned.receive
in interface DatagramsDestination<DATA extends Serializable>
receive
in interface DatagramsReceiver<DATA extends Serializable>
aMaxSize
- the a block sizeDatagramsTransmitter
or DatagramReceiver
counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public void close() throws IOException
close
in interface org.refcodes.component.Closable
close
in class AbstractDatagramsReceiver<DATA extends Serializable>
IOException
Copyright © 2021. All rights reserved.