E
- the type of the target entry for I/O
operations.@Immutable public abstract class AbstractOutputSocket<E extends Entry> extends AbstractIoSocket<E> implements OutputSocket<E>
Subclasses should be immutable.
AbstractInputSocket
Constructor and Description |
---|
AbstractOutputSocket() |
Modifier and Type | Method and Description |
---|---|
SeekableByteChannel |
channel(InputSocket<? extends Entry> peer)
Optional operation: Returns a new seekable byte channel for
writing bytes.
|
OutputStream |
stream(InputSocket<? extends Entry> peer)
Returns a new output stream for writing bytes.
|
protected static <E extends Entry> |
target(InputSocket<E> peer)
Returns the target of the given nullable peer socket or null.
|
toString
equals, hashCode
public SeekableByteChannel channel(InputSocket<? extends Entry> peer) throws IOException
Because the intention of this interface is output, the returned channel
may not be able to position the file pointer or read data and any
attempt to do so may fail with a NonReadableChannelException
.
channel
in interface OutputSocket<E extends Entry>
peer
- the nullable peer socket for copying entry contents.UnsupportedOperationException
- the implementation in the class
OutputSocket
always throws an exception of
this type.IOException
- on any I/O error.public OutputStream stream(InputSocket<? extends Entry> peer) throws IOException
The implementation in the class OutputSocket
calls
channel(net.java.truecommons.cio.InputSocket<? extends net.java.truecommons.cio.Entry>)
and wraps the result in a
ChannelOutputStream
adapter.
Note that this violates the contract for this method unless you
override either this method or channel(net.java.truecommons.cio.InputSocket<? extends net.java.truecommons.cio.Entry>)
with a valid
implementation.
stream
in interface OutputSocket<E extends Entry>
peer
- the nullable peer socket for copying entry contents.IOException
- on any I/O error.@Nullable protected static <E extends Entry> E target(@Nullable InputSocket<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.