OP_NONE, OP_READ, OP_READ_WRITE, OP_WRITE
限定符 | 构造器和说明 |
---|---|
protected |
AbstractChannel(Channel parent,
ChannelFactory factory,
ChannelPipeline pipeline,
ChannelSink sink)
Creates a new instance.
|
protected |
AbstractChannel(java.lang.Integer id,
Channel parent,
ChannelFactory factory,
ChannelPipeline pipeline,
ChannelSink sink)
(Internal use only) Creates a new temporary instance with the specified
ID.
|
限定符和类型 | 方法和说明 |
---|---|
ChannelFuture |
bind(java.net.SocketAddress localAddress)
Binds this channel to the specified local address asynchronously.
|
ChannelFuture |
close()
Closes this channel asynchronously.
|
int |
compareTo(Channel o)
Compares the ID of the two channels.
|
ChannelFuture |
connect(java.net.SocketAddress remoteAddress)
Connects this channel to the specified remote address asynchronously.
|
ChannelFuture |
disconnect()
Disconnects this channel from the current remote address asynchronously.
|
boolean |
equals(java.lang.Object o)
Returns
true if and only if the specified object is identical
with this channel (i.e: this == o ). |
java.lang.Object |
getAttachment()
|
ChannelFuture |
getCloseFuture()
Returns the
ChannelFuture which will be notified when this
channel is closed. |
ChannelFactory |
getFactory()
Returns the
ChannelFactory which created this channel. |
java.lang.Integer |
getId()
Returns the unique integer ID of this channel.
|
int |
getInterestOps()
Returns the current
interestOps of this channel. |
protected int |
getInternalInterestOps() |
Channel |
getParent()
Returns the parent of this channel.
|
ChannelPipeline |
getPipeline()
Returns the
ChannelPipeline which handles ChannelEvent s
associated with this channel. |
protected ChannelFuture |
getSucceededFuture()
Returns the cached
SucceededChannelFuture instance. |
protected ChannelFuture |
getUnsupportedOperationFuture()
Returns the
FailedChannelFuture whose cause is an
UnsupportedOperationException . |
boolean |
getUserDefinedWritability(int index)
Returns
true if and only if the user-defined writability flag at the specified index is set to
true . |
int |
hashCode()
Returns the ID of this channel.
|
boolean |
isOpen()
Returns
true if and only if this channel is open. |
boolean |
isReadable()
Returns
true if and only if the I/O thread will read a message
from this channel. |
boolean |
isWritable()
Returns
true if and only if the I/O thread will perform the
requested write operation immediately. |
void |
setAttachment(java.lang.Object attachment)
Attaches an object to this
Channel to store a stateful
information |
protected boolean |
setClosed()
Marks this channel as closed.
|
ChannelFuture |
setInterestOps(int interestOps)
Changes the
interestOps of this channel asynchronously. |
protected void |
setInternalInterestOps(int interestOps)
Sets the
interestOps property of this channel
immediately. |
ChannelFuture |
setReadable(boolean readable)
Suspends or resumes the read operation of the I/O thread asynchronously.
|
protected boolean |
setUnwritable() |
void |
setUserDefinedWritability(int index,
boolean writable)
Sets a user-defined writability flag at the specified index.
|
protected boolean |
setWritable() |
java.lang.String |
toString()
Returns the
String representation of this channel. |
ChannelFuture |
unbind()
Unbinds this channel from the current local address asynchronously.
|
ChannelFuture |
write(java.lang.Object message)
Sends a message to this channel asynchronously.
|
ChannelFuture |
write(java.lang.Object message,
java.net.SocketAddress remoteAddress)
Sends a message to this channel asynchronously.
|
getConfig, getLocalAddress, getRemoteAddress, isBound, isConnected
protected AbstractChannel(Channel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink)
parent
- the parent of this channel. null
if there's no parent.factory
- the factory which created this channelpipeline
- the pipeline which is going to be attached to this channelsink
- the sink which will receive downstream events from the pipeline
and send upstream events to the pipelineprotected AbstractChannel(java.lang.Integer id, Channel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink)
parent
- the parent of this channel. null
if there's no parent.factory
- the factory which created this channelpipeline
- the pipeline which is going to be attached to this channelsink
- the sink which will receive downstream events from the pipeline
and send upstream events to the pipelinepublic final java.lang.Integer getId()
Channel
public ChannelFactory getFactory()
Channel
ChannelFactory
which created this channel.getFactory
在接口中 Channel
public ChannelPipeline getPipeline()
Channel
ChannelPipeline
which handles ChannelEvent
s
associated with this channel.getPipeline
在接口中 Channel
protected ChannelFuture getSucceededFuture()
SucceededChannelFuture
instance.protected ChannelFuture getUnsupportedOperationFuture()
FailedChannelFuture
whose cause is an
UnsupportedOperationException
.public final int hashCode()
hashCode
在类中 java.lang.Object
public final boolean equals(java.lang.Object o)
true
if and only if the specified object is identical
with this channel (i.e: this == o
).equals
在类中 java.lang.Object
public final int compareTo(Channel o)
compareTo
在接口中 java.lang.Comparable<Channel>
public boolean isOpen()
Channel
true
if and only if this channel is open.protected boolean setClosed()
true
if and only if this channel was not marked as
closed yetpublic ChannelFuture bind(java.net.SocketAddress localAddress)
Channel
bind
在接口中 Channel
localAddress
- where to bindChannelFuture
which will be notified when the
bind request succeeds or failspublic ChannelFuture unbind()
Channel
unbind
在接口中 Channel
ChannelFuture
which will be notified when the
unbind request succeeds or failspublic ChannelFuture close()
Channel
close
在接口中 Channel
ChannelFuture
which will be notified when the
close request succeeds or failspublic ChannelFuture getCloseFuture()
Channel
ChannelFuture
which will be notified when this
channel is closed. This method always returns the same future instance.getCloseFuture
在接口中 Channel
public ChannelFuture connect(java.net.SocketAddress remoteAddress)
Channel
connect
在接口中 Channel
remoteAddress
- where to connectChannelFuture
which will be notified when the
connection request succeeds or failspublic ChannelFuture disconnect()
Channel
disconnect
在接口中 Channel
ChannelFuture
which will be notified when the
disconnection request succeeds or failspublic int getInterestOps()
Channel
interestOps
of this channel.getInterestOps
在接口中 Channel
Channel.OP_NONE
, Channel.OP_READ
, Channel.OP_WRITE
, or
Channel.OP_READ_WRITE
public ChannelFuture setInterestOps(int interestOps)
Channel
interestOps
of this channel asynchronously.setInterestOps
在接口中 Channel
interestOps
- the new interestOps
ChannelFuture
which will be notified when the
interestOps
change request succeeds or failsprotected int getInternalInterestOps()
protected void setInternalInterestOps(int interestOps)
interestOps
property of this channel
immediately. This method is intended to be called by an internal
component - please do not call it unless you know what you are doing.public boolean isReadable()
Channel
true
if and only if the I/O thread will read a message
from this channel. This method is a shortcut to the following code:
return (getInterestOps() & OP_READ) != 0;
isReadable
在接口中 Channel
public boolean isWritable()
Channel
true
if and only if the I/O thread will perform the
requested write operation immediately. Any write requests made when
this method returns false
are queued until the I/O thread is
ready to process the queued write requests. This method is a shortcut
to the following code:
return (getInterestOps() & OP_WRITE) == 0;
isWritable
在接口中 Channel
public final boolean getUserDefinedWritability(int index)
Channel
true
if and only if the user-defined writability flag at the specified index is set to
true
.getUserDefinedWritability
在接口中 Channel
public final void setUserDefinedWritability(int index, boolean writable)
Channel
setUserDefinedWritability
在接口中 Channel
protected boolean setWritable()
protected boolean setUnwritable()
public ChannelFuture setReadable(boolean readable)
Channel
int interestOps = getInterestOps(); if (readable) { setInterestOps(interestOps | OP_READ); } else { setInterestOps(interestOps & ~OP_READ); }
setReadable
在接口中 Channel
readable
- true
to resume the read operation and
false
to suspend the read operationChannelFuture
which will be notified when the
interestOps
change request succeeds or failspublic ChannelFuture write(java.lang.Object message)
Channel
DatagramChannel
)
and is not connected yet, you have to call Channel.write(Object, SocketAddress)
instead. Otherwise, the write request will fail with
NotYetConnectedException
and an 'exceptionCaught'
event
will be triggered.write
在接口中 Channel
message
- the message to writeChannelFuture
which will be notified when the
write request succeeds or failspublic ChannelFuture write(java.lang.Object message, java.net.SocketAddress remoteAddress)
Channel
DatagramChannel
)
and is not connected yet, you must specify non-null address. Otherwise,
the write request will fail with NotYetConnectedException
and
an 'exceptionCaught'
event will be triggered.write
在接口中 Channel
message
- the message to writeremoteAddress
- where to send the specified message.
This method is identical to Channel.write(Object)
if null
is specified here.ChannelFuture
which will be notified when the
write request succeeds or failspublic java.lang.Object getAttachment()
Channel
getAttachment
在接口中 Channel
null
if no object was attached or null
was
attachedpublic void setAttachment(java.lang.Object attachment)
Channel
Channel
to store a stateful
informationsetAttachment
在接口中 Channel
public java.lang.String toString()
String
representation of this channel. The returned
string contains the ID, local address,
and remote address of this channel for
easier identification.toString
在类中 java.lang.Object