in uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java [983:1006]
public static List<AnnotationFS> selectOverlapping(CAS aCas, Type aType, int aSelBegin,
int aSelEnd) {
requireAnnotationType(aCas, aType);
List<AnnotationFS> annotations = new ArrayList<>();
for (AnnotationFS t : aCas.getAnnotationIndex(aType)) {
int begin = t.getBegin();
int end = t.getEnd();
// Annotation is fully right of selection (not overlapping)
if (aSelBegin != begin && begin >= aSelEnd) {
break;
}
// not yet there
if (aSelBegin != begin && end <= aSelBegin) {
continue;
}
annotations.add(t);
}
return annotations;
}