@Test public void testBuild() throws UIMAException { JCas jCas = JCasSingleton.getJCasInstance(); JCasBuilder builder = new JCasBuilder(jCas); assertSame(jCas, builder.getJCas()); int s = builder.getCurrentOffset(); assertEquals(s, 0); builder.addText("Hello"); int e = builder.getCurrentOffset(); assertEquals(e, "Hello".length()); builder.addAnnotations(Arrays.asList(new Entity(jCas), new Paragraph(jCas)), s, e, 6); builder.build(); assertEquals(jCas.getDocumentText(), "Hello"); Collection<Base> entities = JCasUtil.select(jCas, Base.class); assertEquals(entities.size(), 2); Iterator<Base> iterator = entities.iterator(); Annotation a = iterator.next(); Annotation b = iterator.next(); Entity entity; Paragraph paragraph; if (a instanceof Entity) { entity = (Entity) a; paragraph = (Paragraph) b; } else { entity = (Entity) b; paragraph = (Paragraph) a; } assertEquals(entity.getBegin(), 0); assertEquals(entity.getEnd(), 5); assertEquals(paragraph.getBegin(), 0); assertEquals(paragraph.getEnd(), 5); assertEquals(paragraph.getDepth(), 6); }
public void build() { jCas.setDocumentText(documentText.toString()); for (Annotation a : annotations) { a.addToIndexes(jCas); } }
JCasBuilder { public void build() { jCas.setDocumentText(documentText.toString()); for (Annotation a : annotations) { a.addToIndexes(jCas); } } }
JCasBuilder { public void build() { jCas.setDocumentText(documentText.toString()); for (Annotation a : annotations) { a.addToIndexes(jCas); } } JCasBuilder(JCas jCas); }
JCasBuilder { public void build() { jCas.setDocumentText(documentText.toString()); for (Annotation a : annotations) { a.addToIndexes(jCas); } } JCasBuilder(JCas jCas); JCas getJCas(); int getCurrentOffset(); void addText(String text); void addAnnotations(Collection<Annotation> collection, int begin, int end, int depth); void build(); }
JCasBuilder { public void build() { jCas.setDocumentText(documentText.toString()); for (Annotation a : annotations) { a.addToIndexes(jCas); } } JCasBuilder(JCas jCas); JCas getJCas(); int getCurrentOffset(); void addText(String text); void addAnnotations(Collection<Annotation> collection, int begin, int end, int depth); void build();  }