Package org.apache.uima.fit.factory
Class JCasBuilder
java.lang.Object
org.apache.uima.fit.factory.JCasBuilder
Allows to add types and text to a CAS easily piece by piece.
-
Constructor Summary
ConstructorDescriptionJCasBuilder
(org.apache.uima.jcas.JCas aJCas) Create a new JCas builder working on the specified JCas. -
Method Summary
Modifier and TypeMethodDescription<T> T
Add an annotation starting at the specified position and ending at the current end of the text.void
Append a text.<T> T
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
Get the current "cursor" position (current text length).
-
Constructor Details
-
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 Details
-
add
Append a text.- Parameters:
aText
- the text to append.
-
add
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 textaClass
- annotation type- Returns:
- annotation instance - can be used to set features or determine offsets
-
add
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.
-