public static List selectAt()

in uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java [304:332]


  public static List<AnnotationFS> selectAt(final CAS aCas, final Type aType, int aBegin,
          int aEnd) {
    List<AnnotationFS> list = new ArrayList<AnnotationFS>();

    // withSnapshotIterators() not needed here since we copy the FSes to a list anyway
    FSIterator<AnnotationFS> it = aCas.getAnnotationIndex(aType).iterator();

    // Skip annotations whose start is before the start parameter.
    while (it.isValid() && (it.get()).getBegin() < aBegin) {
      it.moveToNext();
    }

    // Skip annotations whose end is after the end parameter.
    while (it.isValid() && (it.get()).getEnd() > aEnd) {
      it.moveToNext();
    }

    while (it.isValid()) {
      AnnotationFS a = it.get();
      // If the offsets do not match the specified offets, we're done
      if (a.getBegin() != aBegin || a.getEnd() != aEnd) {
        break;
      }
      it.moveToNext();
      list.add(a);
    }

    return list;
  }