this.tokens = new LinkedList<Token>();
return iter;
}
public void collect(String word, int offset, int end) {
Token c = candidate != null ? candidate : last;
if (c == null) {
candidate = new Token(word, offset, end);
} else if (offset == c.startOffset()) {
if (end > c.endOffset()) {
candidate = new Token(word, offset, end);
}
} else if (offset > c.startOffset()) {
if (candidate != null) {
select(candidate);
}
if (end > c.endOffset()) {
candidate = new Token(word, offset, end);
} else {
candidate = null;
}
} else if (end >= c.endOffset()) {
if (last != null && last.startOffset() >= offset
&& last.endOffset() <= end) {
for (Iterator iter = tokens.iterator(); iter.hasNext();) {
last = (Token) iter.next();
if (last.startOffset() >= offset && last.endOffset() <= end) {
iter.remove();
}
}
}
last = null;
candidate = new Token(word, offset, end);
}
}