cas.getIndexRepository().addFS(cas.createAnnotation(tokenType, 14, 15));
cas.getIndexRepository().addFS(cas.createAnnotation(sentenceType, 0, 15));
// create filtered iterator over Tokens only
FSIterator it = cas.getAnnotationIndex().iterator();
FSTypeConstraint constraint = cas.getConstraintFactory().createTypeConstraint();
constraint.add(tokenType);
it = cas.createFilteredIterator(it, constraint);
// do iteration
while (it.isValid()) {
AnnotationFS a = (AnnotationFS) it.get();
assertTrue(a.getType().equals(tokenType));
// System.out.println("Annotation type: " + a.getType().getName());
// System.out.println("Covered text: " + a.getCoveredText());
it.moveToNext();
}
// Count number of annotations.
it = cas.getAnnotationIndex().iterator();
int countAll = 0;
for (it.moveToFirst(); it.isValid(); it.moveToNext()) {
++countAll;
}
// create filtered iterator over annotations
it = cas.getAnnotationIndex().iterator();
constraint = cas.getConstraintFactory().createTypeConstraint();
constraint.add(annotationType);
it = cas.createFilteredIterator(it, constraint);
// do iteration
int countFiltered = 0;
while (it.isValid()) {