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 Details

    • JCasIterator

      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

      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 Details

    • 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()