Class JCasBuilder

java.lang.Object
org.apache.uima.fit.factory.JCasBuilder

public class JCasBuilder extends Object
Allows to add types and text to a CAS easily piece by piece.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new JCas builder working on the specified JCas.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    add(int aBegin, Class<T> aClass)
    Add an annotation starting at the specified position and ending at the current end of the text.
    void
    add(String aText)
    Append a text.
    <T> T
    add(String aText, Class<T> aClass)
    Append a text annotated with the specified annotation.
    void
    Complete the building process by writing the text into the CAS.
    Get the JCas.
    int
    Get the current "cursor" position (current text length).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JCasBuilder

      public JCasBuilder(JCas aJCas)
      Create a new JCas builder working on the specified JCas. The JCas must not have any content yet.
      Parameters:
      aJCas - the working JCas.
  • Method Details

    • add

      public void add(String aText)
      Append a text.
      Parameters:
      aText - the text to append.
    • add

      public <T> T add(String aText, Class<T> aClass)
      Append a text annotated with the specified annotation. The created annotation is returned and further properties can be set on it. The annotation is already added to the indexes.
      Type Parameters:
      T - annotation type
      Parameters:
      aText - covered text
      aClass - annotation type
      Returns:
      annotation instance - can be used to set features or determine offsets
    • add

      public <T> T add(int aBegin, Class<T> aClass)
      Add an annotation starting at the specified position and ending at the current end of the text. The created annotation is returned and further properties can be set on it. The annotation is already added to the indexes.
      Type Parameters:
      T - annotation type
      Parameters:
      aBegin - begin offset.
      aClass - annotation type
      Returns:
      annotation instance - can be used to set features or determine offsets
    • getPosition

      public int getPosition()
      Get the current "cursor" position (current text length).
      Returns:
      current text length.
    • getJCas

      public JCas getJCas()
      Get the JCas.
      Returns:
      the JCas.
    • close

      public void close()
      Complete the building process by writing the text into the CAS. This can only be called once.