BaseToken token = (BaseToken) tokens.get(i);
Iterator<Machine>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);
IllnessDxIndicator si = null;
if (m.equals(iv_brainDxMachine))
{
si = new IllnessDxIndicator(
startToken.getStartOffset(),
endToken.getEndOffset(),
IllnessDxIndicator.BRAIN_STATUS);
}
else if (m.equals(iv_breastDxMachine))
{
si = new IllnessDxIndicator(
startToken.getStartOffset(),
endToken.getEndOffset(),
IllnessDxIndicator.BREAST_STATUS);
}
else if (m.equals(iv_colonDxMachine))
{
si = new IllnessDxIndicator(
startToken.getStartOffset(),
endToken.getEndOffset(),
IllnessDxIndicator.COLON_STATUS);
}
else if (m.equals(iv_padDxMachine))
{
si = new IllnessDxIndicator(
startToken.getStartOffset(),
endToken.getEndOffset(),
IllnessDxIndicator.PAD_STATUS);
}
outSet.add(si);
m.reset();
}
}
}
// cleanup
tokenStartMap.clear();
// reset machines
Iterator<Machine>itr = iv_machineSet.iterator();
while (itr.hasNext())
{
Machine m = (Machine) itr.next();
m.reset();
}
return outSet;
}