当前位置: 首页>>代码示例>>Java>>正文


Java IllegalSelectorException类代码示例

本文整理汇总了Java中java.nio.channels.IllegalSelectorException的典型用法代码示例。如果您正苦于以下问题:Java IllegalSelectorException类的具体用法?Java IllegalSelectorException怎么用?Java IllegalSelectorException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IllegalSelectorException类属于java.nio.channels包,在下文中一共展示了IllegalSelectorException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compress

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
public static void compress(String file, String output) {
    BinaryOut out = new BinaryOut(output);
    Node root = buildTrie(new BinaryIn(file));
    writeTrie(root, out);
    out.write(root.frequency);
    BinaryIn in = new BinaryIn(file);                
    Map<Character, String> huffmanCode = new HashMap<Character, String>(); 
    getHuffmanCode(root, huffmanCode, new StringBuilder());
    while(!in.isEmpty()) {
        char c = in.readChar();
        String code = huffmanCode.get(c);
        for (int i = 0; i < code.length(); i++) {
            if (code.charAt(i) == '0') {
                out.write(false);
                //System.out.println('0');
            } else if (code.charAt(i) == '1') {
                out.write(true);
                //System.out.println('1');
            } else 
                throw new IllegalSelectorException();
        }
    }
    out.close();
}
 
开发者ID:yunfeiguo,项目名称:bioinfo_toolbox,代码行数:25,代码来源:Huffman2.java

示例2: throwRandomRuntimeException

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
public static void throwRandomRuntimeException() {
    String random = "planb:" + UUID.randomUUID().toString();
    RuntimeException[] exceptions = new RuntimeException[]{
            new IllegalStateException("This is a test exception because the sate " + random),
            new IllegalArgumentException("Wrong argument test exception" + random),
            new RuntimeException("This is a test exception " + random),
            new IllegalSelectorException(),
            new IndexOutOfBoundsException("A test index exception " + random),
            new ClassCastException("A test class cast exception " + random),
            new NoSuchElementException("A test no such element exception " + random),
            new MalformedParameterizedTypeException(),
            new BufferOverflowException(),
            new EmptyStackException(),
            new NullPointerException("This is not a real nullpointer " + random),
            new SecurityException("This is not a real security exception " + random),
            new ArithmeticException("This is not a real arithmetic exception " + random),
            new IllegalThreadStateException("This is a test exception with threads " + random),
            new IllegalCharsetNameException("Charset is wrong test exception " + random),
            new IllegalMonitorStateException("This is a test exception with illegal monitor " + random)};

    throw exceptions[new Random().nextInt(exceptions.length)];
}
 
开发者ID:patrickfav,项目名称:planb-android,代码行数:23,代码来源:DemoAppUtil.java

示例3: createMax1Option

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
/**
 * As sometimes , make sure the result has one rows.
 * @param queryObj
 * @return
 */
public static QueryOption createMax1Option(ConditionQuery queryObj){
	int queryTimeout=queryObj.getQueryTimeout();
	String tableName=null;
	if(queryObj instanceof JoinElement){
		tableName=(String)((JoinElement)queryObj).getAttribute(JoinElement.CUSTOM_TABLE_NAME);	
	}
	if(queryTimeout>0 || tableName!=null){
		QueryOption op;
		try {
			op = (QueryOption) DEFAULT_MAX1.clone();
		} catch (CloneNotSupportedException e) {
			throw new IllegalSelectorException();//never happens
		}
		op.queryTimeout=queryTimeout;
		return op;
	}else{
		return DEFAULT_MAX1;
	}
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:25,代码来源:QueryOption.java

示例4: testSerializationSelf

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationSelf",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "IllegalSelectorException",
        args = {}
    )
})
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new IllegalSelectorException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:IllegalSelectorExceptionTest.java

示例5: testSerializationCompatibility

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility with RI.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationGolden",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "IllegalSelectorException",
        args = {}
    )
})
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new IllegalSelectorException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:IllegalSelectorExceptionTest.java

示例6: register

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
protected SelectionKey register(AbstractSelectableChannel channel,
        int operations, Object attachment) {
    if (!provider().equals(channel.provider())) {
        throw new IllegalSelectorException();
    }
    synchronized (this) {
        synchronized (keysSet) {

            // System.out.println("Registering channel");
            // create the key
            SelectionKey sk = new EpollSelectionKeyImpl(channel,
                    operations, attachment, this);

            int index = addKey(sk);
            ((EpollSelectionKeyImpl) sk).setIndex(index);

            // System.out.println(" channel registered with index = " +
            // index);
            return sk;
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:EpollSelectorImpl.java

示例7: register

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
/**
 * @see java.nio.channels.spi.AbstractSelector#register(java.nio.channels.spi.AbstractSelectableChannel,
 *      int, java.lang.Object)
 */
@Override
protected SelectionKey register(AbstractSelectableChannel channel,
        int operations, Object attachment) {
    if (!provider().equals(channel.provider())) {
        throw new IllegalSelectorException();
    }
    synchronized (this) {
        synchronized (unmodifiableKeys) {
            // create the key
            SelectionKeyImpl selectionKey = new SelectionKeyImpl(
                    channel, operations, attachment, this);
            addKey(selectionKey);
            mutableKeys.add(selectionKey);
            return selectionKey;
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:SelectorImpl.java

示例8: getOpenedEditors

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
public static HashSet<MPart> getOpenedEditors(){
	
	EModelService modelService = CloudscaleContext.getGlobalContext().get(EModelService.class);
	MApplication app = CloudscaleContext.getGlobalContext().get(MApplication.class);

	if(modelService == null){
		throw new IllegalSelectorException();
	}
	if(app == null){
		throw new IllegalSelectorException();
	}
	
	HashSet<MPart> out = new HashSet<MPart>();
	MPartStack stack = (MPartStack)modelService.find("org.eclipse.e4.primaryDataStack", app);
	
	for(MStackElement el : stack.getChildren()){
		if(el instanceof MPart){
			MPart part = (MPart)el;
			if(part.getContext() != null){
				out.add(part);
			}
		}
	}
	return out;
}
 
开发者ID:CloudScale-Project,项目名称:Environment,代码行数:26,代码来源:ExplorerUtils.java

示例9: register

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
protected final SelectionKey register(AbstractSelectableChannel ch,
                                      int ops,
                                      Object attachment)
{
    if (!(ch instanceof SelChImpl))
        throw new IllegalSelectorException();
    SelectionKeyImpl k = new SelectionKeyImpl((SelChImpl)ch, this);
    k.attach(attachment);
    synchronized (publicKeys) {
        implRegister(k);
    }
    k.interestOps(ops);
    return k;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:SelectorImpl.java

示例10: register

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
/** 
 */
@Override
protected SelectionKey register( //
		final AbstractSelectableChannel channel, //
		final int interestOps, //
		final Object attachment //
) {

	if (registeredKeyMap.size() >= maximimSelectorSize) {
		throw new IllegalSelectorException();
	}

	if (!(channel instanceof ChannelUDT)) {
		throw new IllegalSelectorException();
	}

	final ChannelUDT channelUDT = (ChannelUDT) channel;

	final Integer socketId = channelUDT.socketUDT().id();

	SelectionKeyUDT keyUDT = registeredKeyMap.get(socketId);

	if (keyUDT == null) {
		keyUDT = new SelectionKeyUDT(this, channelUDT, attachment);
		registeredKeyMap.putIfAbsent(socketId, keyUDT);
		keyUDT = registeredKeyMap.get(socketId);
	}

	keyUDT.interestOps(interestOps);

	return keyUDT;

}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:35,代码来源:SelectorUDT.java

示例11: park

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
@Override
public void park(char carType) {
	if (!isFree()) {
		throw new IllegalSelectorException();
	}
	this.carType = carType;
}
 
开发者ID:victorrentea,项目名称:training,代码行数:8,代码来源:NormalSlot.java

示例12: register

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
@Override protected SelectionKey register(AbstractSelectableChannel channel,
        int operations, Object attachment) {
    if (!provider().equals(channel.provider())) {
        throw new IllegalSelectorException();
    }
    synchronized (this) {
        synchronized (unmodifiableKeys) {
            SelectionKeyImpl selectionKey = new SelectionKeyImpl(channel, operations,
                    attachment, this);
            mutableKeys.add(selectionKey);
            ensurePollFdsCapacity();
            return selectionKey;
        }
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:16,代码来源:SelectorImpl.java

示例13: register

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
/**
 * Registers this channel with the specified selector for the specified
 * interest set. If the channel is already registered with the selector, the
 * {@link SelectionKey interest set} is updated to {@code interestSet} and
 * the corresponding selection key is returned. If the channel is not yet
 * registered, this method calls the {@code register} method of
 * {@code selector} and adds the selection key to this channel's key set.
 *
 * @param selector
 *            the selector with which to register this channel.
 * @param interestSet
 *            this channel's {@link SelectionKey interest set}.
 * @param attachment
 *            the object to attach, can be {@code null}.
 * @return the selection key for this registration.
 * @throws CancelledKeyException
 *             if this channel is registered but its key has been canceled.
 * @throws ClosedChannelException
 *             if this channel is closed.
 * @throws IllegalArgumentException
 *             if {@code interestSet} is not supported by this channel.
 * @throws IllegalBlockingModeException
 *             if this channel is in blocking mode.
 * @throws IllegalSelectorException
 *             if this channel does not have the same provider as the given
 *             selector.
 */
@Override
public final SelectionKey register(Selector selector, int interestSet,
        Object attachment) throws ClosedChannelException {
    if (!isOpen()) {
        throw new ClosedChannelException();
    }
    if (!((interestSet & ~validOps()) == 0)) {
        throw new IllegalArgumentException("no valid ops in interest set: " + interestSet);
    }

    synchronized (blockingLock) {
        if (isBlocking) {
            throw new IllegalBlockingModeException();
        }
        if (!selector.isOpen()) {
            if (interestSet == 0) {
                // throw ISE exactly to keep consistency
                throw new IllegalSelectorException();
            }
            // throw NPE exactly to keep consistency
            throw new NullPointerException("selector not open");
        }
        SelectionKey key = keyFor(selector);
        if (key == null) {
            key = ((AbstractSelector) selector).register(this, interestSet, attachment);
            keyList.add(key);
        } else {
            if (!key.isValid()) {
                throw new CancelledKeyException();
            }
            key.interestOps(interestSet);
            key.attach(attachment);
        }
        return key;
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:64,代码来源:AbstractSelectableChannel.java

示例14: createOption

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
public static QueryOption createOption(){
	try {
		return (QueryOption) DEFAULT.clone();
	} catch (CloneNotSupportedException e) {
		throw new IllegalSelectorException();//never happens
	}
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:8,代码来源:QueryOption.java

示例15: register

import java.nio.channels.IllegalSelectorException; //导入依赖的package包/类
/**
 * Registers this channel with the specified selector for the specified
 * interest set. If the channel is already registered with the selector, the
 * {@link SelectionKey interest set} is updated to {@code interestSet} and
 * the corresponding selection key is returned. If the channel is not yet
 * registered, this method calls the {@code register} method of
 * {@code selector} and adds the selection key to this channel's key set.
 *
 * @param selector
 *            the selector with which to register this channel.
 * @param interestSet
 *            this channel's {@link SelectionKey interest set}.
 * @param attachment
 *            the object to attach, can be {@code null}.
 * @return the selection key for this registration.
 * @throws CancelledKeyException
 *             if this channel is registered but its key has been canceled.
 * @throws ClosedChannelException
 *             if this channel is closed.
 * @throws IllegalArgumentException
 *             if {@code interestSet} is not supported by this channel.
 * @throws IllegalBlockingModeException
 *             if this channel is in blocking mode.
 * @throws IllegalSelectorException
 *             if this channel does not have the same provider as the given
 *             selector.
 */
@Override
public final SelectionKey register(Selector selector, int interestSet,
        Object attachment) throws ClosedChannelException {
    if (!isOpen()) {
        throw new ClosedChannelException();
    }
    if (!((interestSet & ~validOps()) == 0)) {
        throw new IllegalArgumentException();
    }

    synchronized (blockingLock) {
        if (isBlocking) {
            throw new IllegalBlockingModeException();
        }
        if (!selector.isOpen()) {
            if (0 == interestSet) {
                // throw ISE exactly to keep consistency
                throw new IllegalSelectorException();
            }
            // throw NPE exactly to keep consistency
            throw new NullPointerException();
        }
        SelectionKey key = keyFor(selector);
        if (null == key) {
            key = ((AbstractSelector) selector).register(this, interestSet,
                    attachment);
            keyList.add(key);
        } else {
            if (!key.isValid()) {
                throw new CancelledKeyException();
            }
            key.interestOps(interestSet);
            key.attach(attachment);
        }
        return key;
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:65,代码来源:AbstractSelectableChannel.java


注:本文中的java.nio.channels.IllegalSelectorException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。