BaseToken token = (BaseToken) tokens.get(i);
Iterator machineItr = iv_machineSet.iterator();
while (machineItr.hasNext())
{
Machine m = (Machine) machineItr.next();
m.input(token);
State currentState = m.getCurrentState();
if (currentState.getStartStateFlag())
{
tokenStartMap.put(m, new Integer(i));
}
if (currentState.getEndStateFlag())
{
Object o = tokenStartMap.get(m);
int tokenStartIndex;
if (o == null)
{
// By default, all machines start with
// token zero.
tokenStartIndex = 0;
}
else
{
tokenStartIndex = ((Integer) o).intValue();
// skip ahead over single token we don't want
tokenStartIndex++;
}
BaseToken endToken = null;
if (currentState instanceof NonTerminalEndState)
{
endToken = (BaseToken) tokens.get(i - 1);
}
else
{
endToken = token;
}
BaseToken startToken = (BaseToken) tokens
.get(tokenStartIndex);
StatusIndicator si = null;
if (m.equals(iv_historyMachine))
{
si = new StatusIndicator(
startToken.getStartOffset(),
endToken.getEndOffset(),
StatusIndicator.HISTORY_STATUS);
}
else if (m.equals(iv_probableMachine) || (m.equals(iv_probableMachineNoTerm)))
{
si = new StatusIndicator(
startToken.getStartOffset(),
endToken.getEndOffset(),
StatusIndicator.PROBABLE_STATUS);
}
else if (m.equals(iv_familyHistoryMachine))
{
si = new StatusIndicator(
startToken.getStartOffset(),
endToken.getEndOffset(),
StatusIndicator.FAMILY_HISTORY_STATUS);
}
outSet.add(si);
m.reset();
}
}
}
// TODO resolve conflict between history & family history
// cleanup
tokenStartMap.clear();
// reset machines
Iterator itr = iv_machineSet.iterator();
while (itr.hasNext())
{
Machine m = (Machine) itr.next();
m.reset();
}
return outSet;
}