in uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java [663:745]
public void moveToLastNoReinit() {
if (isEmpty) {
return;
}
if (isUnambiguous && !isListForm) {
convertToListForm();
}
if (isListForm) {
pos = list.size() - 1;
} else {
switch (boundsUse) {
case coveredBy:
moveToJustPastBoundsAndBackup(boundEnd + 1, MAX_VALUE,
// continue backing up if:
a -> a.getBegin() > boundEnd || (!isIncludesAnnotationsStartingAtEndPosition
&& a.getBegin() < a.getEnd() && a.getBegin() == boundEnd) ||
// back up if the item type < bound type to get to the maximal type
(a.getBegin() == boundEnd && a.getEnd() == boundEnd && lto != null
&& lto.lessThan(boundType, a._getTypeImpl())));
// adjust for strict, and check if hit bound
if (isStrict) {
while (it.isValid() && it.getNvc().getEnd() > boundEnd) {
maybeMoveToPrevBounded();
}
}
// skip over original bound if found
while (it.isValid() && equalToBounds(it.getNvc())) {
maybeMoveToPrevBounded();
}
break;
case covering:
moveToJustPastBoundsAndBackup(boundBegin + 1, MAX_VALUE, a -> a.getBegin() > boundBegin || // keep
// backing
// up
// while
// a.begin
// too
// big
(a.getBegin() == boundBegin && a.getEnd() < boundEnd) || // keep backing up while
// a.begin ==, but end is
// too small
(a.getBegin() == boundBegin && a.getEnd() == boundEnd && // if begin/end ==, check
// type order if exists.
lto != null && lto.lessThan(boundType, a._getTypeImpl())));
// skip over equal bounds
while (it.isValid() && equalToBounds(it.getNvc())) {
maybeMoveToPrevBounded();
}
// handle skipping cases where the end is < boundEnd
while (it.isValid() && it.getNvc().getEnd() < boundEnd) {
maybeMoveToPrevBounded();
}
break;
case sameBeginEnd:
moveToJustPastBoundsAndBackup(boundBegin + 1, MAX_VALUE,
// keep moving backwards if begin too large, or
// is ==, but end is too small, or
// is ==, and end is ==, but end type is too large.
a -> a.getBegin() > boundBegin || (a.getBegin() == boundBegin
&& (a.getEnd() < boundEnd || a.getEnd() == boundEnd && lto != null
&& lto.lessThan(boundType, a._getTypeImpl()))));
// skip over original bound if found
while (it.isValid() && equalToBounds(it.getNvc())) {
maybeMoveToPrevBounded();
}
break;
case notBounded:
default:
Misc.internalError(); // never happen, because should always be bounded here
break;
}
}
}