org.apache.uima.fit.factory

## 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 and Description
    `JCasBuilder(org.apache.uima.jcas.JCas aJCas)` Create a new JCas builder working on the specified JCas.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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` | `close()` Complete the building process by writing the text into the CAS.
    `org.apache.uima.jcas.JCas` | `getJCas()` Get the JCas.
    `int` | `getPosition()` 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 Detail

    - #### JCasBuilder

          public JCasBuilder(org.apache.uima.jcas.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 Detail

    - #### 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 org.apache.uima.jcas.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.

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