@Test public void thatInnerWhitespaceIsRemoved1() { cas.setDocumentText(" a b "); AnnotationFS ann = cas.createAnnotation(cas.getAnnotationType(), 0, 2); ann.trim(); assertThat(ann) .extracting(AnnotationFS::getBegin, AnnotationFS::getEnd, AnnotationFS::getCoveredText) .containsExactly(1, 2, "a"); }
@Override public void trim(IntPredicate aIsTrimChar) { int begin = getBegin(); int end = getEnd(); String text = _casView.getDocumentText(); if (begin == end || text == null) { return; } final int saved_begin = begin; final int saved_end = end; int backwardsSeekingCodepoint; while ( (end > 0) && end > begin && aIsTrimChar.test(backwardsSeekingCodepoint = text.codePointBefore(end)) ) { end -= Character.charCount(backwardsSeekingCodepoint); } int forwardSeekingCodepoint; while ( (begin < (text.length() - 1)) && begin < end && aIsTrimChar.test(forwardSeekingCodepoint = text.codePointAt(begin)) ) { begin += Character.charCount(forwardSeekingCodepoint); } if (saved_begin != begin || saved_end != end) { int final_begin = begin; int final_end = end; _casView.protectIndexes(() -> { setBegin(final_begin); setEnd(final_end); }); } }
Annotation extends AnnotationBase implements AnnotationImpl { @Override public void trim(IntPredicate aIsTrimChar) { int begin = getBegin(); int end = getEnd(); String text = _casView.getDocumentText(); if (begin == end || text == null) { return; } final int saved_begin = begin; final int saved_end = end; int backwardsSeekingCodepoint; while ( (end > 0) && end > begin && aIsTrimChar.test(backwardsSeekingCodepoint = text.codePointBefore(end)) ) { end -= Character.charCount(backwardsSeekingCodepoint); } int forwardSeekingCodepoint; while ( (begin < (text.length() - 1)) && begin < end && aIsTrimChar.test(forwardSeekingCodepoint = text.codePointAt(begin)) ) { begin += Character.charCount(forwardSeekingCodepoint); } if (saved_begin != begin || saved_end != end) { int final_begin = begin; int final_end = end; _casView.protectIndexes(() -> { setBegin(final_begin); setEnd(final_end); }); } } }
Annotation extends AnnotationBase implements AnnotationImpl { @Override public void trim(IntPredicate aIsTrimChar) { int begin = getBegin(); int end = getEnd(); String text = _casView.getDocumentText(); if (begin == end || text == null) { return; } final int saved_begin = begin; final int saved_end = end; int backwardsSeekingCodepoint; while ( (end > 0) && end > begin && aIsTrimChar.test(backwardsSeekingCodepoint = text.codePointBefore(end)) ) { end -= Character.charCount(backwardsSeekingCodepoint); } int forwardSeekingCodepoint; while ( (begin < (text.length() - 1)) && begin < end && aIsTrimChar.test(forwardSeekingCodepoint = text.codePointAt(begin)) ) { begin += Character.charCount(forwardSeekingCodepoint); } if (saved_begin != begin || saved_end != end) { int final_begin = begin; int final_end = end; _casView.protectIndexes(() -> { setBegin(final_begin); setEnd(final_end); }); } } @Deprecated @SuppressWarnings("deprecation") protected  Annotation();  Annotation(JCas jcas);  Annotation(TypeImpl t, CASImpl c);  Annotation(JCas jcas, int begin, int end); }
Annotation extends AnnotationBase implements AnnotationImpl { @Override public void trim(IntPredicate aIsTrimChar) { int begin = getBegin(); int end = getEnd(); String text = _casView.getDocumentText(); if (begin == end || text == null) { return; } final int saved_begin = begin; final int saved_end = end; int backwardsSeekingCodepoint; while ( (end > 0) && end > begin && aIsTrimChar.test(backwardsSeekingCodepoint = text.codePointBefore(end)) ) { end -= Character.charCount(backwardsSeekingCodepoint); } int forwardSeekingCodepoint; while ( (begin < (text.length() - 1)) && begin < end && aIsTrimChar.test(forwardSeekingCodepoint = text.codePointAt(begin)) ) { begin += Character.charCount(forwardSeekingCodepoint); } if (saved_begin != begin || saved_end != end) { int final_begin = begin; int final_end = end; _casView.protectIndexes(() -> { setBegin(final_begin); setEnd(final_end); }); } } @Deprecated @SuppressWarnings("deprecation") protected  Annotation();  Annotation(JCas jcas);  Annotation(TypeImpl t, CASImpl c);  Annotation(JCas jcas, int begin, int end); int getTypeIndexID(); final int getBegin(); final void setBegin(int v); final int getEnd(); final void setEnd(int v); String getCoveredText(); @Deprecated int getStart(); final int compareAnnotation(Annotation other); final int compareAnnotation(Annotation other, LinearTypeOrder lto); final int compareAnnotationWithId(Annotation other); final int compareAnnotationWithId(Annotation other, LinearTypeOrder lto); @Override void trim(IntPredicate aIsTrimChar); }
Annotation extends AnnotationBase implements AnnotationImpl { @Override public void trim(IntPredicate aIsTrimChar) { int begin = getBegin(); int end = getEnd(); String text = _casView.getDocumentText(); if (begin == end || text == null) { return; } final int saved_begin = begin; final int saved_end = end; int backwardsSeekingCodepoint; while ( (end > 0) && end > begin && aIsTrimChar.test(backwardsSeekingCodepoint = text.codePointBefore(end)) ) { end -= Character.charCount(backwardsSeekingCodepoint); } int forwardSeekingCodepoint; while ( (begin < (text.length() - 1)) && begin < end && aIsTrimChar.test(forwardSeekingCodepoint = text.codePointAt(begin)) ) { begin += Character.charCount(forwardSeekingCodepoint); } if (saved_begin != begin || saved_end != end) { int final_begin = begin; int final_end = end; _casView.protectIndexes(() -> { setBegin(final_begin); setEnd(final_end); }); } } @Deprecated @SuppressWarnings("deprecation") protected  Annotation();  Annotation(JCas jcas);  Annotation(TypeImpl t, CASImpl c);  Annotation(JCas jcas, int begin, int end); int getTypeIndexID(); final int getBegin(); final void setBegin(int v); final int getEnd(); final void setEnd(int v); String getCoveredText(); @Deprecated int getStart(); final int compareAnnotation(Annotation other); final int compareAnnotation(Annotation other, LinearTypeOrder lto); final int compareAnnotationWithId(Annotation other); final int compareAnnotationWithId(Annotation other, LinearTypeOrder lto); @Override void trim(IntPredicate aIsTrimChar); final static String _TypeName; final static String _FeatName_begin; final static String _FeatName_end; final static int typeIndexID; final static int type; }