LineMultiplier extends JCasMultiplier_ImplBase { @Override public void process(final JCas aJCas) throws AnalysisEngineProcessException { Arrays.stream(aJCas.getDocumentText().split(System.getProperty("line.separator"))).filter(Predicate.not(String::isBlank)).forEach(lines::add); log.info("Got {} lines", lines.size()); }  @Override void initialize(UimaContext aContext); @Override void process(final JCas aJCas); @Override AbstractCas next(); @Override boolean hasNext(); static final String PARAM_NUM_LINES; }
@Test public void process() throws Exception { JCas jCas = JCasFactory.createJCas(); String ls = System.getProperty("line.separator"); jCas.setDocumentText("line1" + ls + "line2" + ls + ls + ls + "line3"); AnalysisEngine multiplier = AnalysisEngineFactory.createEngine(LineMultiplier.class); JCasIterator jCasIterator = multiplier.processAndOutputNewCASes(jCas); assertTrue(jCasIterator.hasNext()); List<String> casTexts = new ArrayList<>(); while (jCasIterator.hasNext()) { JCas newCas = jCasIterator.next(); casTexts.add(newCas.getDocumentText()); newCas.release(); } assertThat(casTexts).hasSize(3); assertThat(casTexts).containsExactly("line1", "line2", "line3"); }