org.apache.uima.fit.pipeline

## Class JCasIterator

- java.lang.Object
- - org.apache.uima.fit.pipeline.JCasIterator

- All Implemented Interfaces:
    Iterator<JCas>

      public class JCasIterator
      extends Object
      implements Iterator<JCas>

  A class implementing iteration over a the documents of a collection. Each element in the Iterable is a JCas containing a single document. The documents have been loaded by the CollectionReader and processed by the AnalysisEngine (if any).

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JCasIterator(CollectionReader aReader, AnalysisEngine... aEngines)` Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each one before yielding them.
    `JCasIterator(CollectionReaderDescription aReader, AnalysisEngineDescription... aEngines)` Iterate over the documents loaded by the given reader, running the analysis engines on each one before yielding them.
    `JCasIterator(CollectionReader aReader, TypeSystemDescription aTypeSystemDescription)` Iterate over the documents loaded by the CollectionReader.
    `JCasIterator(ResourceManager aResMgr, CollectionReader aReader, AnalysisEngine... aEngines)` Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each one before yielding them.
    `JCasIterator(ResourceManager aResMgr, CollectionReaderDescription aReader, AnalysisEngineDescription... aEngines)` Iterate over the documents loaded by the given reader, running the analysis engines on each one before yielding them.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `collectionProcessComplete()` Notify analysis engines that the collection process is complete.
    `void` | `destroy()` Close and destroy all components.s
    `boolean` | `hasNext()`
    `boolean` | `isSelfComplete()` Get whether `collectionProcessComplete()` is automatically called.
    `boolean` | `isSelfDestroy()` Get whether `destroy()` is automatically called.
    `JCas` | `next()`
    `void` | `remove()`
    `void` | `setSelfComplete(boolean aSelfComplete)` Send a `collectionProcessComplete()` call to analysis engines when the reader has no further CASes to produce.
    `void` | `setSelfDestroy(boolean aSelfDestroy)` Send a destroy call to analysis engines when the reader has no further CASes to produce or if an error occurs.

    - ### 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`

- - ### Constructor Detail

    - #### JCasIterator

          public JCasIterator(CollectionReaderDescription aReader,
                              AnalysisEngineDescription... aEngines)
                       throws CASException,
                              ResourceInitializationException

      Iterate over the documents loaded by the given reader, running the analysis engines on each one before yielding them. By default, components DO get life-cycle events, such as collectionProcessComplete or destroy when this constructor is used.
      Parameters:
        `aReader` - The CollectionReader for loading documents.
        `aEngines` - The AnalysisEngines for processing documents.
      Throws:
        `ResourceInitializationException` - if a failure occurs during initialization of the components
        `CASException` - if the JCas could not be initialized

    - #### JCasIterator

          public JCasIterator(ResourceManager aResMgr,
                              CollectionReaderDescription aReader,
                              AnalysisEngineDescription... aEngines)
                       throws CASException,
                              ResourceInitializationException

      Iterate over the documents loaded by the given reader, running the analysis engines on each one before yielding them. By default, components DO get life-cycle events, such as collectionProcessComplete or destroy when this constructor is used.
      Parameters:
        `aResMgr` - The `ResourceManager` used to create the components and the JCas. If this parameter is `null` then `ResourceManagerFactory.newResourceManager()` will be used to obtain a resource manager. If a new resource manager was internally created, it is destroyed at the end of the pipeline (if `isSelfDestroy()`).
        `aReader` - The CollectionReader for loading documents.
        `aEngines` - The AnalysisEngines for processing documents.
      Throws:
        `ResourceInitializationException` - if a failure occurs during initialization of the components
        `CASException` - if the JCas could not be initialized

    - #### JCasIterator

          public JCasIterator(CollectionReader aReader,
                              AnalysisEngine... aEngines)
                       throws CASException,
                              ResourceInitializationException

      Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each one before yielding them. By default, components do NOT get life-cycle events, such as collectionProcessComplete or destroy when this constructor is used.
      Parameters:
        `aReader` - The CollectionReader for loading documents.
        `aEngines` - The AnalysisEngines for processing documents.
      Throws:
        `ResourceInitializationException` - if a failure occurs during initialization of the components
        `CASException` - if the JCas could not be initialized

    - #### JCasIterator

          public JCasIterator(CollectionReader aReader,
                              TypeSystemDescription aTypeSystemDescription)
                       throws CASException,
                              ResourceInitializationException

      Iterate over the documents loaded by the CollectionReader. (Uses an JCasAnnotatorAdapter to create the document JCas.) By default, components do NOT get life-cycle events, such as collectionProcessComplete or destroy when this constructor is used.
      Parameters:
        `aReader` - The CollectionReader for loading documents.
        `aTypeSystemDescription` - a type system description
      Throws:
        `ResourceInitializationException` - if a failure occurs during initialization of the components
        `CASException` - if the JCas could not be initialized

    - #### JCasIterator

          public JCasIterator(ResourceManager aResMgr,
                              CollectionReader aReader,
                              AnalysisEngine... aEngines)
                       throws CASException,
                              ResourceInitializationException

      Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each one before yielding them. By default, components do NOT get life-cycle events, such as collectionProcessComplete or destroy when this constructor is used.
      Parameters:
        `aResMgr` - The `ResourceManager` used to create the JCas. Should be the one also used by the CollectionReader and the AnalysisEngines. If this parameter is `null` then `ResourceManagerFactory.newResourceManager()` will be used to obtain a resource manager. If a new resource manager was internally created, it is destroyed at the end of the pipeline (if `isSelfDestroy()`).
        `aReader` - The CollectionReader for loading documents.
        `aEngines` - The AnalysisEngines for processing documents.
      Throws:
        `ResourceInitializationException` - if a failure occurs during initialization of the components
        `CASException` - if the JCas could not be initialized

  - ### Method Detail

    - #### hasNext

          public boolean hasNext()

      Specified by:
        `hasNext` in interface `Iterator<JCas>`

    - #### next

          public JCas next()

      Specified by:
        `next` in interface `Iterator<JCas>`

    - #### remove

          public void remove()

      Specified by:
        `remove` in interface `Iterator<JCas>`

    - #### collectionProcessComplete

          public void collectionProcessComplete()
                                         throws AnalysisEngineProcessException

      Notify analysis engines that the collection process is complete.
      Throws:
        `AnalysisEngineProcessException` - if there was a problem completing the process

    - #### destroy

          public void destroy()

      Close and destroy all components.s

    - #### isSelfComplete

          public boolean isSelfComplete()

      Get whether `collectionProcessComplete()` is automatically called.
      Returns:
        whether `collectionProcessComplete()` is automatically called.

    - #### setSelfComplete

          public void setSelfComplete(boolean aSelfComplete)

      Send a `collectionProcessComplete()` call to analysis engines when the reader has no further CASes to produce.
      Parameters:
        `aSelfComplete` - whether to enable the automatic call to `collectionProcessComplete()`

    - #### isSelfDestroy

          public boolean isSelfDestroy()

      Get whether `destroy()` is automatically called.
      Returns:
        whether `destroy()` is automatically called.

    - #### setSelfDestroy

          public void setSelfDestroy(boolean aSelfDestroy)

      Send a destroy call to analysis engines when the reader has no further CASes to produce or if an error occurs.
      Parameters:
        `aSelfDestroy` - whether to enable the automatic call to `Resource.destroy()`

Copyright © 2012–2021 The Apache Software Foundation. All rights reserved.