Package org.apache.uima.cas.impl
Class Subiterator<T extends AnnotationFS>
java.lang.Object
org.apache.uima.cas.impl.FSIteratorImplBase<T>
org.apache.uima.cas.impl.Subiterator<T>
- All Implemented Interfaces:
Iterator<T>
,FSIterator<T>
Subiterator implementation.
There are two bounding styles and 2 underlying forms.
The 2nd form is produced lazily when needed, and
is made by a one-time forward traversal to compute unambigious subsets and store them into a list.
- The 2nd form is needed only for unambiguous style if backwards or moveto(fs) operation.
The 1st form uses the underlying iterator directly, and does skipping as needed, while iterating
- going forward:
skip if unambigious and start is within prev span
skip if strict and end lies outside of scope span
- going backward:
if unambiguous - convert to form 2
skip if strict and end lies outside of scope span
- going to particular fs (left most match)
if unambiguous - convert to form 2
skip (forward) if strict and end lies outside of scope span
- going to first:
unambiguous - no testing needed, no prior span
skip if strict and end lies outside of scope span
- going to last:
unambigious - convert to 2nd form
skip backwards if strict and end lies outside of scope span
There are two styles of the bounding information.
- the traditional one uses the standard comparator for annotations: begin (ascending), end (descending) and
type priority ordering
- the 2nd style uses just a begin value and an end value, no type priority ordering.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final AnnotationFS
private final int
private final int
private final FSIndexRepositoryImpl
private final boolean
private final boolean
private boolean
private final FSIteratorImplBase<T>
private int
private int
private final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionSubiterator
(FSIterator<T> it, AnnotationFS boundingAnnotation, int boundingBegin, int boundingEnd, boolean ambiguous, boolean strict, boolean isBounded, FSIndexRepositoryImpl fsIndexRepo) Constructor called with annot == null and boundingBegin and boundingEnd specified, or called with annot != null (boundingBegin/End ignored) if annot == null, then this implies the comparisons should use just begin and end (not type priorities) and the range is inclusive with the begin/ end boundaries != null, then this implies the comparisons use the normal Annotation compare and the range is exclusive on the left with the boundaries. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Called for begin/end compare, after moveTo(fs) to eliminate the effect of the type order comparison before any adjustment for strict.private void
private void
For strict mode, advance iterator until the end is within the bounding endprivate void
Converting to list form - called for unambiguous iterator going backwards, unambiguous iterator doing a moveTo(fs) operation iterator doing a moveToLast() operationcopy()
Copy this iterator.get()
Get the structure the iterator is pointing at.(package private) static Comparator<AnnotationFS>
getAnnotationBeginEndComparator
(int boundingBegin, int boundingEnd) private Comparator<AnnotationFS>
boolean
isValid()
Check if this iterator is valid.private void
For subiterators bounded by Annotations, the starting place is the item past the elements that are equal to the the bounding annot, adjusted for strict exclusionsprivate void
For unambiguous, going forwards(package private) <TT extends AnnotationFS>
voidmoveTo
(int begin, int end) A special version of moveTo for subtypes of AnnotationFS, which moves to a particular begin/end (no type priority).void
Move the iterator to the first Feature Structure that is equal tofs
.private void
moveToExact
(FeatureStructureImpl targetAnnotation) void
Move the iterator to the first element.void
Move the iterator to the last element.void
Advance the iterator.void
Move the iterator one element back.private void
Move to the starting position of the sub iterator Annotation bounding: move to the annotation, then move forwards until you're at an element not equal to the annot.private void
Methods inherited from class org.apache.uima.cas.impl.FSIteratorImplBase
getBegin, getEnd, hasNext, next, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
list
-
pos
private int pos -
it
-
fsIndexRepo
-
boundingAnnotation
-
boundingBegin
private final int boundingBegin -
boundingEnd
private final int boundingEnd -
prevEnd
private int prevEnd -
ambiguous
private final boolean ambiguous -
strict
private final boolean strict -
isBounded
private final boolean isBounded -
isListForm
private boolean isListForm -
isBeginEndCompare
private final boolean isBeginEndCompare
-
-
Constructor Details
-
Subiterator
Subiterator(FSIterator<T> it, AnnotationFS boundingAnnotation, int boundingBegin, int boundingEnd, boolean ambiguous, boolean strict, boolean isBounded, FSIndexRepositoryImpl fsIndexRepo) Constructor called with annot == null and boundingBegin and boundingEnd specified, or called with annot != null (boundingBegin/End ignored) if annot == null, then this implies the comparisons should use just begin and end (not type priorities) and the range is inclusive with the begin/ end boundaries != null, then this implies the comparisons use the normal Annotation compare and the range is exclusive on the left with the boundaries.- Parameters:
it
- the iterator to useboundingAnnotation
- null or the bounding annotationboundingBegin
- if boundingAnnotation is null, this is used as the bounding begin (inclusive); ignored if boundingAnnotation is not nullboundingEnd
- if annot is null, this is used as the bounding end (inclusive); ignored if boundingAnnotation is not nullambiguous
- true means normal iteration, false means to skip annotations whose begin lies between previous begin (inclusive) and end (exclusive)strict
- true means to skip annotations whose end is greater than the bounding end position (ignoring type priorities)isBounded
- false means its an unambiguous iterator with no bounds narrowing; ambiguous taken to be falsefsIndexRepo
- the index repository for this iterator
-
-
Method Details
-
convertToListForm
private void convertToListForm()Converting to list form - called for unambiguous iterator going backwards, unambiguous iterator doing a moveTo(fs) operation iterator doing a moveToLast() operation -
moveToExact
-
moveToStart
private void moveToStart()Move to the starting position of the sub iterator Annotation bounding: move to the annotation, then move forwards until you're at an element not equal to the annot. (by definition of the iterator) and adjust for strict -
setPrevEnd
private void setPrevEnd() -
movePastAnnot
private void movePastAnnot()For subiterators bounded by Annotations, the starting place is the item past the elements that are equal to the the bounding annot, adjusted for strict exclusions -
getAnnotationComparator
-
adjustAfterMoveToForBeginEndComparator
Called for begin/end compare, after moveTo(fs) to eliminate the effect of the type order comparison before any adjustment for strict. Move backwards while equal with begin/end iterator. -
adjustForStrictForward
private void adjustForStrictForward()For strict mode, advance iterator until the end is within the bounding end -
movePastPrevAnnotation
private void movePastPrevAnnotation()For unambiguous, going forwards -
adjustForStrictBackward
private void adjustForStrictBackward() -
isValid
public boolean isValid()Description copied from interface:FSIterator
Check if this iterator is valid.- Returns:
true
if the iterator is valid.
-
get
Description copied from interface:FSIterator
Get the structure the iterator is pointing at.- Returns:
- The structure the iterator is pointing at.
- Throws:
NoSuchElementException
- If the iterator is not valid.
-
moveToNext
public void moveToNext()Description copied from interface:FSIterator
Advance the iterator. This may invalidate the iterator. -
moveToPrevious
public void moveToPrevious()Description copied from interface:FSIterator
Move the iterator one element back. This may invalidate the iterator. -
moveToFirst
public void moveToFirst()Description copied from interface:FSIterator
Move the iterator to the first element. The iterator will be valid iff the underlying collection is non-empty. Allowed even if the underlying indexes being iterated over were modified. -
moveToLast
public void moveToLast()Description copied from interface:FSIterator
Move the iterator to the last element. The iterator will be valid iff the underlying collection is non-empty. Allowed even if the underlying indexes being iterated over were modified. -
getAnnotationBeginEndComparator
-
moveTo
Description copied from interface:FSIterator
Move the iterator to the first Feature Structure that is equal tofs
. First means the earliest one occurring in the index, in case multiple FSs that are "equal" to fs are in the index. If no such feature structure exists in the underlying collection, set the iterator to the "insertion point" forfs
, i.e., to a point where the current feature structure is greater thanfs
, and the previous one is less thanfs
.If the fs is greater than all of the entries in the index, the moveTo cannot set the iterator to an insertion point where the current feature structure is greater than fs, so it marks the iterator "invalid".
If the underlying index is a bag index, no ordering is present, and the moveTo operation moves to the fs which is the same identical fs as the key. If no such fs is in the index, the iterator is marked invalid.
- Parameters:
fs
- The feature structure the iterator that supplies the comparison information. It must be of type T or a subtype of T.
-
moveTo
Description copied from class:FSIteratorImplBase
A special version of moveTo for subtypes of AnnotationFS, which moves to a particular begin/end (no type priority).- Overrides:
moveTo
in classFSIteratorImplBase<T extends AnnotationFS>
- Parameters:
begin
- the starting point (inclusive)end
- the ending point (inclusive)
-
copy
Description copied from interface:FSIterator
Copy this iterator.- Returns:
- A copy of this iterator, pointing at the same element.
-