Mercurial > hg > RemoteEditor > Eclipse
view src/pathfinder/mergetest/channels2/SelectionKeySimulator.java @ 172:a913949a0dd9
channelsimulations version2
author | kent |
---|---|
date | Sat, 30 Aug 2008 01:55:16 +0900 |
parents | |
children |
line wrap: on
line source
package pathfinder.mergetest.channels2; public class SelectionKeySimulator { public static final int OP_READ = 0x01; public static final int OP_ACCEPT = 0x02; public static final int OP_WRITE = 0x04; private int interestOpt; private SelectableChannelSimulator channel; private Object attachment; public SelectionKeySimulator(SelectableChannelSimulator cs, int opt) { channel = cs; interestOpt = opt; } public boolean isAble() { if ( (interestOpt&OP_READ)!=0 && isReadable() ) return true; else if( (interestOpt&OP_ACCEPT)!=0 && isAcceptable() ) return true; else if( (interestOpt&OP_WRITE)!=0 && isWritable() ) return true; else return false; } public boolean isAcceptable() { return channel.isAcceptable(); } public boolean isReadable() { return channel.isReadable(); } public boolean isWritable() { return channel.isWritable(); } public SelectableChannelSimulator channel() { return channel; } public Object attachment() { return attachment; } public void attach(Object handler) { attachment = handler; } }