E - the type of the local target
for I/O operations.@NotThreadSafe @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public abstract class InputSocket<E extends Entry> extends IOSocket<E,Entry>
Note that the entity relationship between input sockets and output sockets is n:1, i.e. any input socket can have at most one peer output socket, but it may be the peer of many other output sockets.
OutputSocket| Modifier and Type | Field and Description |
|---|---|
private OutputSocket<?> |
peer |
| Constructor and Description |
|---|
InputSocket() |
| Modifier and Type | Method and Description |
|---|---|
InputSocket<E> |
bind(InputSocket<?> to)
Binds this socket to given socket by inheriting its
peer target. |
(package private) InputSocket<E> |
connect(OutputSocket<?> newPeer)
Connects this input socket to the given peer output socket.
|
Entry |
getPeerTarget()
Returns the peer target for I/O operations.
|
InputStream |
newInputStream()
Returns a new input stream for reading bytes from the
local target. |
abstract ReadOnlyFile |
newReadOnlyFile()
Optional: Returns a new read only file for reading bytes from
the
local target in arbitrary order. |
SeekableByteChannel |
newSeekableByteChannel()
Optional: Returns a new seekable byte channel for reading bytes
from the
local target in arbitrary order. |
@CheckForNull private OutputSocket<?> peer
public final InputSocket<E> bind(@CheckForNull InputSocket<?> to)
peer target.
Note that this method does not change the state of the
given socket and does not connect this socket to the peer
socket, that is it does not set this socket as the peer of of the given
socket.to - the input socket with the peer target to inherit.thisfinal InputSocket<E> connect(@CheckForNull OutputSocket<?> newPeer)
newPeer - the nullable peer output socket to connect to.this@Nullable public Entry getPeerTarget() throws IOException
The same considerations as for IOSocket.getLocalTarget() apply here, too.
The peer target is null if and only if this socket is not
connect(de.schlichtherle.truezip.socket.OutputSocket<?>)ed to another socket.
getPeerTarget in class IOSocket<E extends Entry,Entry>IOExceptionpublic InputStream newInputStream() throws IOException
local target.
Implementations must enable calling this method any number of times.
Furthermore, the returned input stream should not be buffered.
Buffering should be addressed by the caller instead - see
IOSocket.copy(de.schlichtherle.truezip.socket.InputSocket<?>, de.schlichtherle.truezip.socket.OutputSocket<?>).
The implementation in the class InputSocket calls
newReadOnlyFile() and wraps the resulting object in a new
ReadOnlyFileInputStream as an adapter.
Note that this may violate the contract for this method because
newReadOnlyFile() is allowed to throw an
UnsupportedOperationException while this method is not!
IOException - on any I/O error.public abstract ReadOnlyFile newReadOnlyFile() throws IOException
local target in arbitrary order.
If this method is supported, implementations must enable calling it any number of times. Furthermore, the returned read only file should not be buffered. Buffering should be addressed by client applications instead.
UnsupportedOperationException - if this operation is not supported
by the implementation.IOException - on any I/O error.public SeekableByteChannel newSeekableByteChannel() throws IOException
local target in arbitrary order.
If this method is supported, implementations must enable calling it any number of times. Furthermore, the returned seekable byte channel should not be buffered. Buffering should be addressed by client applications instead.
UnsupportedOperationException - if this operation is not supported
by the implementation.IOException - on any I/O error.Copyright © 2004-2011 Schlichtherle IT Services. All Rights Reserved.