corda/classpath/java/nio/channels/SelectionKey.java
Joel Dice 87b02eb949 update copyright years
Previously, I used a shell script to extract modification date ranges
from the Git history, but that was complicated and unreliable, so now
every file just gets the same year range in its copyright header.  If
someone needs to know when a specific file was modified and by whom,
they can look at the Git history themselves; no need to include it
redundantly in the header.
2013-07-02 20:52:38 -06:00

84 lines
1.8 KiB
Java

/* Copyright (c) 2008-2013, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package java.nio.channels;
public class SelectionKey {
public static final int OP_READ = 1 << 0;
public static final int OP_WRITE = 1 << 2;
public static final int OP_CONNECT = 1 << 3;
public static final int OP_ACCEPT = 1 << 4;
private final SelectableChannel channel;
private final Selector selector;
private int interestOps;
private int readyOps;
private final Object attachment;
public SelectionKey(SelectableChannel channel, Selector selector,
int interestOps, Object attachment)
{
this.channel = channel;
this.selector = selector;
this.interestOps = interestOps;
this.attachment = attachment;
this.readyOps = 0;
}
public int interestOps() {
return interestOps;
}
public SelectionKey interestOps(int v) {
this.interestOps = v;
return this;
}
public int readyOps() {
return readyOps;
}
public void readyOps(int v) {
this.readyOps = v;
}
public boolean isReadable() {
return (readyOps & OP_READ) != 0;
}
public boolean isWritable() {
return (readyOps & OP_WRITE) != 0;
}
public boolean isConnectable() {
return (readyOps & OP_CONNECT) != 0;
}
public boolean isAcceptable() {
return (readyOps & OP_ACCEPT) != 0;
}
public boolean isValid() {
return channel.isOpen() && selector.isOpen();
}
public SelectableChannel channel() {
return channel;
}
public Selector selector() {
return selector;
}
public Object attachment() {
return attachment;
}
}