E
- the type of the target entry for I/O
operations.@Immutable public abstract class AbstractInputSocket<E extends Entry> extends AbstractIoSocket<E> implements InputSocket<E>
Subclasses should be immutable.
AbstractOutputSocket
Constructor and Description |
---|
AbstractInputSocket() |
Modifier and Type | Method and Description |
---|---|
SeekableByteChannel |
channel(OutputSocket<? extends Entry> peer)
Optional operation: Returns a new seekable byte channel for
reading bytes.
|
InputStream |
stream(OutputSocket<? extends Entry> peer)
Returns a new input stream for reading bytes.
|
protected static <E extends Entry> |
target(OutputSocket<E> peer)
Returns the target of the given nullable peer socket or null.
|
toString
equals, hashCode
public SeekableByteChannel channel(OutputSocket<? extends Entry> peer) throws IOException
Because the intention of this interface is input, the returned channel
may not be able to write data and any attempt to do so should fail with
a NonWritableChannelException
.
channel
in interface InputSocket<E extends Entry>
peer
- the nullable peer socket for copying entry contents.UnsupportedOperationException
- the implementation in the class
InputSocket
always throws an exception of
this type.IOException
- on any I/O error.public InputStream stream(OutputSocket<? extends Entry> peer) throws IOException
The implementation in the class InputSocket
calls
channel(net.java.truecommons.cio.OutputSocket<? extends net.java.truecommons.cio.Entry>)
and wraps the result in a
ChannelInputStream
adapter.
Note that this violates the contract for this method unless you
override either this method or channel(net.java.truecommons.cio.OutputSocket<? extends net.java.truecommons.cio.Entry>)
with a valid
implementation.
stream
in interface InputSocket<E extends Entry>
peer
- the nullable peer socket for copying entry contents.IOException
- on any I/O error.@CheckForNull protected static <E extends Entry> E target(@CheckForNull OutputSocket<E> peer) throws IOException
E
- the type of the peer socket's local target.peer
- the nullable peer socket.null
if the given reference is null or the target of the
given peer socket otherwise.IOException
- if resolving the peer's local target fails.Copyright © 2012–2018 Schlichtherle IT Services. All rights reserved.