// record active CASes in case we encounter an exception and need to release them
activeCASes.add(cas);
// get next CAS Processor to route to
Step nextStep = flow.next();
// repeat until we reach a FinalStep
while (!(nextStep instanceof FinalStep)) {
if (nextStep instanceof SimpleStep) {
String nextAeKey = ((SimpleStep) nextStep).getAnalysisEngineKey();
AnalysisEngine nextAe = (AnalysisEngine) mComponentAnalysisEngineMap.get(nextAeKey);
if (nextAe != null) {
// invoke next AE in flow
CasIterator casIter;
casIter = nextAe.processAndOutputNewCASes(cas);
if (casIter.hasNext()) // new CASes are output
{
// get the first output CAS
CAS outputCas = casIter.next();
// push the CasIterator, original CAS, and Flow onto a stack so we
// can get the other output CASes and the original CAS later
casIteratorStack.push(new StackFrame(casIter, cas, flow, nextAeKey));
// compute Flow for the output CAS
flow = flow.newCasProduced(outputCas, nextAeKey);
// now route the output CAS through the flow
cas = outputCas;
activeCASes.add(cas);
} else {
// no new CASes are output; this cas is done being processed
// by that AnalysisEngine so clear the componentInfo
cas.setCurrentComponentInfo(null);
}
} else {
throw new AnalysisEngineProcessException(
AnalysisEngineProcessException.UNKNOWN_ID_IN_SEQUENCE,
new Object[] { nextAeKey });
}
} else {
throw new AnalysisEngineProcessException(
AnalysisEngineProcessException.UNSUPPORTED_STEP_TYPE, new Object[] { nextStep
.getClass() });
}
nextStep = flow.next();
}
// FinalStep was returned from FlowController.