Class Subiterator<T extends AnnotationFS>

java.lang.Object
org.apache.uima.cas.impl.Subiterator<T>
All Implemented Interfaces:
Iterator<T>, ListIterator<T>, FSIterator<T>, LowLevelIterator<T>

public class Subiterator<T extends AnnotationFS> extends Object implements LowLevelIterator<T>
Subiterator implementation. There are 2 underlying forms. The 2nd form is produced lazily when needed, and is made by a one-time forward traversal to compute unambiguous subsets and store them into a list. - The 2nd form is needed only for unambiguous style if backwards or moveTo(fs), or moveToLast operations. The 1st form uses the underlying iterator directly, and does skipping as needed, while iterating - going forward: skip if unambiguous (noBound or coveredBy only) and start is within prev span skip if strict (coveredBy only) and end lies outside of scope span - going backward: if unambiguous - convert to form 2 skip if strict (coveredBy only) and end lies outside of scope span - going to particular fs (left most match) if unambiguous - convert to form 2 skip (forward) if strict (coveredBy only) 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: unambiguous - 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. Interaction with copy-on-write concurrent modification avoidance As with other iterators, the moveToFirst/Last/feature-structure-position "resets" the underlying iterators to match their current indexes. This implementation maintains local data: the list form and the isEmpty flag. These would also need recomputing for the above operations, if isIndexesHaveBeenUpdated() is true.
  • Method Details

    • isValid

      public boolean isValid()
      Description copied from interface: FSIterator
      Check if this iterator is valid.
      Specified by:
      isValid in interface FSIterator<T extends AnnotationFS>
      Returns:
      true if the iterator is valid.
    • getNvc

      public T getNvc()
      Description copied from interface: FSIterator
      Get the structure the iterator is pointing at. Throws various unchecked exceptions, if the iterator is not valid
      Specified by:
      getNvc in interface FSIterator<T extends AnnotationFS>
      Returns:
      The structure the iterator is pointing at.
    • moveToNextNvc

      public void moveToNextNvc()
      Description copied from interface: FSIterator
      version of moveToNext which bypasses the isValid check - call only if you've just done this check yourself
      Specified by:
      moveToNextNvc in interface FSIterator<T extends AnnotationFS>
    • moveToPreviousNvc

      public void moveToPreviousNvc()
      Description copied from interface: FSIterator
      version of moveToPrevious which bypasses the isValid check - call only if you've just done this check yourself
      Specified by:
      moveToPreviousNvc in interface FSIterator<T extends AnnotationFS>
    • moveToFirstNoReinit

      public void moveToFirstNoReinit()
      Description copied from interface: LowLevelIterator
      Internal use same as moveToFirst, but won't reset to use current contents of index if index has changed
      Specified by:
      moveToFirstNoReinit in interface LowLevelIterator<T extends AnnotationFS>
    • moveToLastNoReinit

      public void moveToLastNoReinit()
      Description copied from interface: LowLevelIterator
      Internal use same as moveToLast, but won't reset to use current contents of index if index has changed
      Specified by:
      moveToLastNoReinit in interface LowLevelIterator<T extends AnnotationFS>
    • moveToNoReinit

      public void moveToNoReinit(FeatureStructure fs)
      Description copied from interface: LowLevelIterator
      Internal use same as moveTo(fs), but won't reset to use current contents of index if index has changed
      Specified by:
      moveToNoReinit in interface LowLevelIterator<T extends AnnotationFS>
      Parameters:
      fs - the fs to use as the template identifying the place to move to
    • copy

      public FSIterator<T> copy()
      Description copied from interface: FSIterator
      Copy this iterator.
      Specified by:
      copy in interface FSIterator<T extends AnnotationFS>
      Returns:
      A copy of this iterator, pointing at the same element.
    • ll_indexSizeMaybeNotCurrent

      public int ll_indexSizeMaybeNotCurrent()
      This is unsupported because its expensive to compute in many cases, and may not be needed.
      Specified by:
      ll_indexSizeMaybeNotCurrent in interface LowLevelIterator<T extends AnnotationFS>
      Returns:
      The size of the index. In case of copy-on-write, this returns the size of the index at the time the iterator was created, or at the last moveTo, moveToFirst, or moveToLast. To get the current index size, use ll_getIndex().getSize()
    • ll_maxAnnotSpan

      public int ll_maxAnnotSpan()
      Specified by:
      ll_maxAnnotSpan in interface LowLevelIterator<T extends AnnotationFS>
      Returns:
      an estimate of the maximum span over all annotations (end - begin)
    • ll_getIndex

      public LowLevelIndex<T> ll_getIndex()
      Description copied from interface: LowLevelIterator
      Get the index for just the top most type of this iterator (excludes subtypes).
      Specified by:
      ll_getIndex in interface LowLevelIterator<T extends AnnotationFS>
      Returns:
      The index.
    • isIndexesHaveBeenUpdated

      public boolean isIndexesHaveBeenUpdated()
      Used to determine when some precomputed things (e.g. listform) need to be recalculated
      Specified by:
      isIndexesHaveBeenUpdated in interface LowLevelIterator<T extends AnnotationFS>
      Returns:
      true if one or more of the underlying indexes of the underlying iterator have been updated
    • maybeReinitIterator

      public boolean maybeReinitIterator()
      Description copied from interface: LowLevelIterator
      Internal use
      Specified by:
      maybeReinitIterator in interface LowLevelIterator<T extends AnnotationFS>
      Returns:
      true if the iterator was refreshed to match the current index
    • getComparator

      public Comparator<TOP> getComparator()
      Specified by:
      getComparator in interface LowLevelIterator<T extends AnnotationFS>
      Returns:
      the comparator used by this iterator. It is always a withoutID style, and may be either a withType or NoType style.