BratAnnotatorUtility { public static CAS clearAnnotations(CAS aCas) throws IOException { CAS target; try { target = CasFactory.createCas((TypeSystemDescription) null); } catch (UIMAException e) { throw new IOException(e); } CASCompleteSerializer serializer = serializeCASComplete((CASImpl) getRealCas(aCas)); deserializeCASComplete(serializer, (CASImpl) getRealCas(target)); target.reset(); if (exists(aCas, getType(aCas, DocumentMetaData.class))) { copyDocumentMetadata(aCas, target); } else { WebAnnoCasUtil.createDocumentMetadata(aCas); } target.setDocumentLanguage(aCas.getDocumentLanguage()); target.setDocumentText(aCas.getDocumentText()); for (AnnotationFS t : selectTokens(aCas)) { target.addFsToIndexes(createToken(target, t.getBegin(), t.getEnd())); } for (AnnotationFS s : selectSentences(aCas)) { target.addFsToIndexes(createSentence(target, s.getBegin(), s.getEnd())); } return target; }  static boolean isDocumentFinished(DocumentService aRepository,
            AnnotatorState aBratAnnotatorModel); static CAS clearAnnotations(CAS aCas);  }
@Test public void testClearJCasWithoutDocumentMetadata() throws Exception { CAS jcas = JCasFactory.createJCas().getCas(); BratAnnotatorUtility.clearAnnotations(jcas); }