Object[] trans = step.getTransitList().toArray();
// non-determinism candidates
Set nonDeterm = new LinkedHashSet();
for (int i = 0; i < trans.length; i++) {
Transition t = (Transition) trans[i];
TransitionTarget tsrc = t.getParent();
for (int j = i + 1; j < trans.length; j++) {
Transition t2 = (Transition) trans[j];
TransitionTarget t2src = t2.getParent();
if (SCXMLHelper.isDescendant(t2src, tsrc)) {
//t2 takes precedence over t
removeList.add(t);
break; //it makes no sense to waste cycles with t
} else if (SCXMLHelper.isDescendant(tsrc, t2src)) {
//t takes precendence over t2
removeList.add(t2);
} else {
//add both to the non-determinism candidates
nonDeterm.add(t);
nonDeterm.add(t2);
}
}
}
// check if all non-deterministic situations have been resolved
nonDeterm.removeAll(removeList);
if (nonDeterm.size() > 0) {
// if not, first one in each state / region (which is also
// first in document order) wins
Set regions = new HashSet();
Iterator iter = nonDeterm.iterator();
while (iter.hasNext()) {
Transition t = (Transition) iter.next();
TransitionTarget parent = t.getParent();
if (regions.contains(parent)) {
removeList.add(t);
} else {
regions.add(parent);
}