public class BaseDelegatingSocketChannel<T extends SocketChannel> extends SocketChannel
SocketChannel
which delegates (its method calls) to
another SocketChannel
. In other words, the former wraps the latter.Modifier and Type | Field and Description |
---|---|
protected T |
delegate
The
SocketChannel this instance delegates (its method calls) to. |
private Socket |
socket
The
Socket to be reported by this instance. |
private Object |
socketSyncRoot
The Object which synchronizes the access to
socket . |
Constructor and Description |
---|
BaseDelegatingSocketChannel(T delegate)
Initializes a new
BaseDelegatingSocketChannel instance which is
to delegate (its method calls) to a specific SocketChannel . |
Modifier and Type | Method and Description |
---|---|
SocketChannel |
bind(SocketAddress local)
Forwards to
delegate and returns this . |
boolean |
connect(SocketAddress remote)
Forwards to
delegate . |
boolean |
finishConnect()
Forwards to
delegate . |
SocketAddress |
getLocalAddress()
Forwards to
delegate . |
<U> U |
getOption(SocketOption<U> name)
Forwards to
delegate . |
SocketAddress |
getRemoteAddress()
Forwards to
delegate . |
protected void |
implCloseSelectableChannel()
Forwards to
delegate . |
protected void |
implConfigureBlocking(boolean block)
Forwards to
delegate . |
protected Socket |
implSocket(Socket socket)
Allows extenders to optionally configure (e.g.
|
boolean |
isConnected()
Forwards to
delegate . |
boolean |
isConnectionPending()
Forwards to
delegate . |
int |
read(ByteBuffer dst)
Forwards to
delegate . |
long |
read(ByteBuffer[] dsts,
int offset,
int length)
Forwards to
delegate . |
<U> SocketChannel |
setOption(SocketOption<U> name,
U value)
Forwards to
delegate and returns this . |
SocketChannel |
shutdownInput()
Forwards to
delegate and returns this . |
SocketChannel |
shutdownOutput()
Forwards to
delegate and returns this . |
Socket |
socket()
Allows wrapping the
socket of delegate . |
Set<SocketOption<?>> |
supportedOptions()
Forwards to
delegate . |
int |
write(ByteBuffer src)
Forwards to
delegate . |
long |
write(ByteBuffer[] srcs,
int offset,
int length)
Forwards to
delegate . |
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, register
register
begin, close, end, isOpen
protected final T extends SocketChannel delegate
SocketChannel
this instance delegates (its method calls) to.private Socket socket
Socket
to be reported by this instance.public BaseDelegatingSocketChannel(T delegate)
BaseDelegatingSocketChannel
instance which is
to delegate (its method calls) to a specific SocketChannel
.delegate
- the SocketChannel
the new instance is to delegate
(its method calls) topublic SocketChannel bind(SocketAddress local) throws IOException
delegate
and returns this
.bind
in interface NetworkChannel
bind
in class SocketChannel
IOException
public boolean connect(SocketAddress remote) throws IOException
delegate
.connect
in class SocketChannel
IOException
public boolean finishConnect() throws IOException
delegate
.finishConnect
in class SocketChannel
IOException
public SocketAddress getLocalAddress() throws IOException
delegate
.getLocalAddress
in interface NetworkChannel
getLocalAddress
in class SocketChannel
IOException
public <U> U getOption(SocketOption<U> name) throws IOException
delegate
.IOException
public SocketAddress getRemoteAddress() throws IOException
delegate
.getRemoteAddress
in class SocketChannel
IOException
protected void implCloseSelectableChannel() throws IOException
delegate
.implCloseSelectableChannel
in class AbstractSelectableChannel
IOException
protected void implConfigureBlocking(boolean block) throws IOException
delegate
.implConfigureBlocking
in class AbstractSelectableChannel
IOException
protected Socket implSocket(Socket socket) throws IOException
Socket
of delegate
and before it is returned by socket()
.socket
- the Socket
of delegate
Socket
to be returned by socket()
(in place
of socket
)IOException
- if an I/O error occurspublic boolean isConnected()
delegate
.isConnected
in class SocketChannel
public boolean isConnectionPending()
delegate
.isConnectionPending
in class SocketChannel
public int read(ByteBuffer dst) throws IOException
delegate
.read
in interface ReadableByteChannel
read
in class SocketChannel
IOException
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException
delegate
.read
in interface ScatteringByteChannel
read
in class SocketChannel
IOException
public <U> SocketChannel setOption(SocketOption<U> name, U value) throws IOException
delegate
and returns this
.setOption
in interface NetworkChannel
setOption
in class SocketChannel
IOException
public SocketChannel shutdownInput() throws IOException
delegate
and returns this
.shutdownInput
in class SocketChannel
IOException
public SocketChannel shutdownOutput() throws IOException
delegate
and returns this
.shutdownOutput
in class SocketChannel
IOException
public Socket socket()
socket
of delegate
.socket
in class SocketChannel
public Set<SocketOption<?>> supportedOptions()
delegate
.public int write(ByteBuffer src) throws IOException
delegate
.write
in interface WritableByteChannel
write
in class SocketChannel
IOException
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
delegate
.write
in interface GatheringByteChannel
write
in class SocketChannel
IOException
Copyright © 2018. All rights reserved.