Methods Summary |
---|
public final java.lang.Object | attach(java.lang.Object anObject)Attaches an object to this key. It is acceptable to attach {@code null},
this discards the old attachment.
Object oldAttachment = attachment;
attachment = anObject;
return oldAttachment;
|
public final java.lang.Object | attachment()Gets the attached object.
return attachment;
|
public abstract void | cancel()Cancels this key.
A key that has been canceled is no longer valid. Calling this method on
an already canceled key does nothing.
Calling this method is safe at any time. The call might block until
another ongoing call to a method of this selector has finished. The
reason is that it is synchronizing on the key set of the selector. After
this call finishes, the key will have been added to the selectors
canceled-keys set and will not be included in any future selects of this
selector.
|
public abstract java.nio.channels.SelectableChannel | channel()Gets the channel of this key.
|
public abstract int | interestOps()Gets this key's {@link SelectionKey interest set}. The returned set has
only those bits set that are valid for this key's channel.
|
public abstract java.nio.channels.SelectionKey | interestOps(int operations)Sets the {@link SelectionKey interest set} for this key.
|
public final boolean | isAcceptable()Indicates whether this key's channel is interested in the accept
operation and is ready to accept new connections. A call to this method
is equal to executing {@code (readyOps() & OP_ACCEPT) == OP_ACCEPT}.
return (readyOps() & OP_ACCEPT) == OP_ACCEPT;
|
public final boolean | isConnectable()Indicates whether this key's channel is interested in the connect
operation and is ready to connect. A call to this method is equal to
executing {@code (readyOps() & OP_CONNECT) == OP_CONNECT}.
return (readyOps() & OP_CONNECT) == OP_CONNECT;
|
public final boolean | isReadable()Indicates whether this key's channel is interested in the read operation
and is ready to read. A call to this method is equal to executing
{@code (readyOps() & OP_READ) == OP_READ}.
return (readyOps() & OP_READ) == OP_READ;
|
public abstract boolean | isValid()Indicates whether this key is valid. A key is valid as long as it has not
been canceled.
|
public final boolean | isWritable()Indicates whether this key's channel is interested in the write operation
and is ready to write. A call to this method is equal to executing
{@code (readyOps() & OP_WRITE) == OP_WRITE}.
return (readyOps() & OP_WRITE) == OP_WRITE;
|
public abstract int | readyOps()Gets the set of operations that are ready. The returned set has only
those bits set that are valid for this key's channel.
|
public abstract java.nio.channels.Selector | selector()Gets the selector for which this key's channel is registered.
|