Class JCasIterator

java.lang.Object
org.apache.uima.fit.pipeline.JCasIterator
All Implemented Interfaces:
Iterator<org.apache.uima.jcas.JCas>

public class JCasIterator extends Object implements Iterator<org.apache.uima.jcas.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
    Description
    JCasIterator(org.apache.uima.collection.CollectionReaderDescription aReader, org.apache.uima.analysis_engine.AnalysisEngineDescription... aEngines)
    Iterate over the documents loaded by the given reader, running the analysis engines on each one before yielding them.
    JCasIterator(org.apache.uima.collection.CollectionReader aReader, org.apache.uima.analysis_engine.AnalysisEngine... aEngines)
    Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each one before yielding them.
    JCasIterator(org.apache.uima.collection.CollectionReader aReader, org.apache.uima.resource.metadata.TypeSystemDescription aTypeSystemDescription)
    Iterate over the documents loaded by the CollectionReader.
    JCasIterator(org.apache.uima.resource.ResourceManager aResMgr, org.apache.uima.collection.CollectionReaderDescription aReader, org.apache.uima.analysis_engine.AnalysisEngineDescription... aEngines)
    Iterate over the documents loaded by the given reader, running the analysis engines on each one before yielding them.
    JCasIterator(org.apache.uima.resource.ResourceManager aResMgr, org.apache.uima.collection.CollectionReader aReader, org.apache.uima.analysis_engine.AnalysisEngine... aEngines)
    Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each one before yielding them.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Notify analysis engines that the collection process is complete.
    void
    Close and destroy all components.s
    boolean
     
    boolean
    Get whether collectionProcessComplete() is automatically called.
    boolean
    Get whether destroy() is automatically called.
    org.apache.uima.jcas.JCas
     
    void
     
    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 Details

    • JCasIterator

      public JCasIterator(org.apache.uima.collection.CollectionReaderDescription aReader, org.apache.uima.analysis_engine.AnalysisEngineDescription... aEngines) throws org.apache.uima.cas.CASException, org.apache.uima.resource.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:
      org.apache.uima.resource.ResourceInitializationException - if a failure occurs during initialization of the components
      org.apache.uima.cas.CASException - if the JCas could not be initialized
    • JCasIterator

      public JCasIterator(org.apache.uima.resource.ResourceManager aResMgr, org.apache.uima.collection.CollectionReaderDescription aReader, org.apache.uima.analysis_engine.AnalysisEngineDescription... aEngines) throws org.apache.uima.cas.CASException, org.apache.uima.resource.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:
      org.apache.uima.resource.ResourceInitializationException - if a failure occurs during initialization of the components
      org.apache.uima.cas.CASException - if the JCas could not be initialized
    • JCasIterator

      public JCasIterator(org.apache.uima.collection.CollectionReader aReader, org.apache.uima.analysis_engine.AnalysisEngine... aEngines) throws org.apache.uima.cas.CASException, org.apache.uima.resource.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:
      org.apache.uima.resource.ResourceInitializationException - if a failure occurs during initialization of the components
      org.apache.uima.cas.CASException - if the JCas could not be initialized
    • JCasIterator

      public JCasIterator(org.apache.uima.collection.CollectionReader aReader, org.apache.uima.resource.metadata.TypeSystemDescription aTypeSystemDescription) throws org.apache.uima.cas.CASException, org.apache.uima.resource.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:
      org.apache.uima.resource.ResourceInitializationException - if a failure occurs during initialization of the components
      org.apache.uima.cas.CASException - if the JCas could not be initialized
    • JCasIterator

      public JCasIterator(org.apache.uima.resource.ResourceManager aResMgr, org.apache.uima.collection.CollectionReader aReader, org.apache.uima.analysis_engine.AnalysisEngine... aEngines) throws org.apache.uima.cas.CASException, org.apache.uima.resource.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:
      org.apache.uima.resource.ResourceInitializationException - if a failure occurs during initialization of the components
      org.apache.uima.cas.CASException - if the JCas could not be initialized
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<org.apache.uima.jcas.JCas>
    • next

      public org.apache.uima.jcas.JCas next()
      Specified by:
      next in interface Iterator<org.apache.uima.jcas.JCas>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<org.apache.uima.jcas.JCas>
    • collectionProcessComplete

      public void collectionProcessComplete() throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
      Notify analysis engines that the collection process is complete.
      Throws:
      org.apache.uima.analysis_engine.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()