parallelitem.java
来自「SRI international 发布的OAA框架软件」· Java 代码 · 共 85 行
JAVA
85 行
/*
#=========================================================================
# Copyright 2003 SRI International. All rights reserved.
#
# The material contained in this file is confidential and proprietary to SRI
# International and may not be reproduced, published, or disclosed to others
# without authorization from SRI International.
#
# DISCLAIMER OF WARRANTIES
#
# SRI International MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
# SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SRI International SHALL NOT BE
# LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
# OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
#=========================================================================
*/
package com.sri.oaa2.tools.oaatest;
import java.util.*;
/** Look for a number of events in parallel. Add a separate RecvItem object for
* each event.
*/
class ParallelItem extends MatchEventsItem {
/* Create ParallelItem w/ no child RecvItems.
* @param timeout value in milliseconds. Actual timeout
* value used will be maximum of this timeout and that of all child RecvItems. */
protected ParallelItem(int timeout) {
super(timeout);
}
protected void describe(MatchEventsItem.DescribeCallback cb) {
Iterator iter = recvItems.iterator();
while (iter.hasNext()) {
((FacItem)iter.next()).describe(cb);
}
}
void addTriggerEvents(TestItem.EventAdder adder) {
Iterator iter = recvItems.iterator();
while (iter.hasNext()) {
((FacItem)iter.next()).addTriggerEvents(adder);
}
}
void addFacItem(FacItem item) {
if (item.getTimeout() > getTimeout()) {
setTimeout(item.getTimeout());
}
recvItems.add(item);
}
// Increase visibility to "public" so SelfTest can get to it.
public boolean matchEvent(Event event) {
// Remove each RecvItem when it matches.
Iterator iter = recvItems.iterator();
while (iter.hasNext()) {
FacItem item = (FacItem)iter.next();
if (item.matchEvent(event)) {
iter.remove();
break;
}
}
// If all have matched, then the RecvItem has matched.
if (recvItems.size() == 0) {
return true;
}
else {
return false;
}
}
/** Number of recvItems. */
int size() {
return recvItems.size();
}
// Package-visible so SelfTest can get to it.
List recvItems = new ArrayList();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?