private boolean adjustForStrictNvc_forward()

in uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java [1197:1263]


  private boolean adjustForStrictNvc_forward() {
    Annotation item = it.getNvc();

    boolean originalBoundZeroWidth = originalBoundBegin == originalBoundEnd;

    while (
    // following/preceding and bounds is zero-width and item is zero-width
    (boundsUse == notBounded && item.getBegin() == item.getEnd()
            && item.getBegin() == originalBoundBegin) ||
    // Bounds is zero-width at start
            (!isIncludeZeroWidthAtBegin && originalBoundZeroWidth
                    && item.getBegin() == originalBoundBegin)
            ||
            // Item is zero-width at end
            (!isIncludeZeroWidthAtEnd && originalBoundEnd == item.getBegin()
                    && item.getBegin() == item.getEnd())) {
      it.moveToNextNvc();
      if (!isValid()) {
        return false;
      }

      item = it.getNvc();
    }

    if (!isStrict) {
      if (isIncludesAnnotationsStartingAtEndPosition) {
        return true;
      }

      while ((item.getBegin() == boundEnd && item.getBegin() < item.getEnd()) || equalToBounds(item)
              || (isUnambiguous && overlapping(item, prevBegin, prevEnd))) {
        it.moveToNextNvc();
        if (!isValid()) {
          return false;
        }

        item = it.getNvc();
        if (item.getBegin() > boundEnd) { // not >= because could of 0 length annot at end
          makeInvalid();
          return false;
        }
      }
      return true;
    }

    while (item.getEnd() > boundEnd || equalToBounds(item)
            || (isUnambiguous && overlapping(item, prevBegin, prevEnd)) ||
            // Item is zero-width at end
            (!isIncludeZeroWidthAtEnd && boundEnd == item.getBegin()
                    && item.getBegin() == item.getEnd())
            ||
            // Bounds is zero-width at end
            (!isIncludeZeroWidthAtEnd && originalBoundZeroWidth
                    && item.getEnd() == originalBoundBegin)) {
      it.moveToNextNvc();
      if (!isValid()) {
        return false;
      }

      item = it.getNvc();
      if (item.getBegin() > boundEnd) { // not >= because could of 0 length annot at end
        makeInvalid();
        return false;
      }
    }
    return true;
  }