kg.apc.emulators.SelectorEmul Maven / Gradle / Ivy
package kg.apc.emulators;
import java.io.IOException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.spi.AbstractSelectableChannel;
import java.nio.channels.spi.AbstractSelector;
import java.util.Set;
public class SelectorEmul extends AbstractSelector {
private Set selectedKeys;
public SelectorEmul() {
super(null);
}
@Override
public Set keys() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set selectedKeys() {
return getSelectedKeys();
}
@Override
public int selectNow() throws IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int select(long timeout) throws IOException {
try {
Thread.sleep(timeout / 10);
} catch (InterruptedException ex) {
throw new IOException("", ex);
}
return 1;
}
@Override
public int select() throws IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Selector wakeup() {
throw new UnsupportedOperationException("Not supported yet.");
}
/**
* @return the selectedKeys
*/
public Set getSelectedKeys() {
return selectedKeys;
}
/**
* @param selectedKeys the selectedKeys to set
*/
public void setSelectedKeys(Set selectedKeys) {
this.selectedKeys = selectedKeys;
}
@Override
protected void implCloseSelector() throws IOException {
}
@Override
protected SelectionKey register(AbstractSelectableChannel ch, int ops, Object att) {
return new SelectionKeyEmul();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy