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 InputStreamReceiver<DATA extends Serializable> extends Object implements DatagramsReceiver<DATA>
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
Constructor | Description |
---|---|
InputStreamReceiver(InputStream aInputStream) |
Instantiates a new input stream receiver impl.
|
Modifier and Type | Method | Description |
---|---|---|
int |
available() |
Determines the number of available datagram from a
DatagramTransmitter . |
void |
close() |
|
org.refcodes.component.ConnectionStatus |
getConnectionStatus() |
|
boolean |
isClosable() |
|
boolean |
isClosed() |
|
boolean |
isOpened() |
|
DATA |
receive() |
Reads (receives) the next datagram passed from a
DatagramTransmitter counterpart. |
DATA[] |
receiveAll() |
Reads (receives) the all currently available data.
|
hasAvailable
closeIn, closeQuietly, closeUnchecked
receive
receive
public InputStreamReceiver(InputStream aInputStream) throws IOException
aInputStream
- the input streamIOException
- the open exceptionpublic boolean isClosed()
isClosed
in interface org.refcodes.component.ClosedAccessor
public boolean isOpened()
isOpened
in interface org.refcodes.component.ConnectionStatusAccessor
isOpened
in interface org.refcodes.component.OpenedAccessor
public int available() throws IOException
DatagramTransmitter
. Use the DatagramDestination
extenison's DatagramDestination.receive()
method for retrieving
available datagrams.available
in interface Availability
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>
DatagramsTransmitter
or DatagramReceiver
counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public org.refcodes.component.ConnectionStatus getConnectionStatus()
getConnectionStatus
in interface org.refcodes.component.ConnectionStatusAccessor
public void close() throws IOException
close
in interface org.refcodes.component.Closable
IOException
public 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>
DatagramTransmitter
counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public boolean isClosable()
isClosable
in interface org.refcodes.component.Closable.CloseAutomaton
Copyright © 2021. All rights reserved.