@Override public void setAnnotation(int start, int end, String key, Object value) { Preconditions.checkPositionIndexes(start, end, fullAnnotationSet.size()); checkLocalKey(key); if (end - start > 0) { fullAnnotationSet.begin(); if (start > 0) { fullAnnotationSet.skip(start); } fullAnnotationSet.startAnnotation(key, value); if (end - start > 0) { fullAnnotationSet.skip(end - start); } fullAnnotationSet.endAnnotation(key); fullAnnotationSet.finish(); } }
@Override public void resetAnnotation(int start, int end, String key, Object value) { Preconditions.checkPositionIndexes(start, end, fullAnnotationSet.size()); checkLocalKey(key); if (end - start > 0) { fullAnnotationSet.begin(); fullAnnotationSet.startAnnotation(key, null); if (start > 0) { fullAnnotationSet.skip(start); } fullAnnotationSet.startAnnotation(key, value); fullAnnotationSet.skip(end - start); fullAnnotationSet.startAnnotation(key, null); if (size() - end > 0) { fullAnnotationSet.skip(size() - end); } fullAnnotationSet.endAnnotation(key); fullAnnotationSet.finish(); } } @Override
void insert(RawAnnotationSet<Object> a, int firstShiftedIndex, int length) throws OperationException { a.begin(); if (firstShiftedIndex > 0) { a.skip(firstShiftedIndex); } if (length > 0) { a.insert(length); } a.finish(); }
void insert(RawAnnotationSet<Object> a, int firstShiftedIndex, int length) throws OperationException { a.begin(); if (firstShiftedIndex > 0) { a.skip(firstShiftedIndex); } if (length > 0) { a.insert(length); } a.finish(); }
void insert(RawAnnotationSet<Object> a, int firstShiftedIndex, int length) throws OperationException { a.begin(); if (firstShiftedIndex > 0) { a.skip(firstShiftedIndex); } if (length > 0) { a.insert(length); } a.finish(); }
void insert(RawAnnotationSet<Object> a, int firstShiftedIndex, int length) throws OperationException { a.begin(); if (firstShiftedIndex > 0) { a.skip(firstShiftedIndex); } if (length > 0) { a.insert(length); } a.finish(); }
void delete(RawAnnotationSet<Object> a, int start, int length) throws OperationException { a.begin(); if (start > 0) { a.skip(start); } if (length > 0) { a.delete(length); } a.finish(); }
void delete(RawAnnotationSet<Object> a, int start, int length) throws OperationException { a.begin(); if (start > 0) { a.skip(start); } if (length > 0) { a.delete(length); } a.finish(); }
void delete(RawAnnotationSet<Object> a, int start, int length) throws OperationException { a.begin(); if (start > 0) { a.skip(start); } if (length > 0) { a.delete(length); } a.finish(); }
void delete(RawAnnotationSet<Object> a, int start, int length) throws OperationException { a.begin(); if (start > 0) { a.skip(start); } if (length > 0) { a.delete(length); } a.finish(); }
protected RawAnnotationSet<Object> fancySet() { RawAnnotationSet<Object> m = getNewSet(); m.begin(); m.insert(100); m.finish(); m.begin(); m.skip(10); m.startAnnotation("a", "1"); m.skip(10); m.startAnnotation("b", "2"); m.skip(10); m.startAnnotation("c", "3"); m.startAnnotation("a", "3"); m.startAnnotation("d", "3"); m.skip(10); m.endAnnotation("c"); m.endAnnotation("d"); m.startAnnotation("b", "4"); m.skip(10); m.endAnnotation("b"); m.skip(10); m.endAnnotation("a"); m.finish(); return m; }
public void testOverlappingInOneGo() throws OperationException { RawAnnotationSet<Object> m = getNew(); m.begin(); m.insert(100); m.finish(); m.begin(); m.skip(11); m.startAnnotation("a", "1"); m.skip(20); m.startAnnotation("b", "1"); m.skip(10); m.endAnnotation("a"); m.skip(15); m.endAnnotation("b"); m.finish(); // 0-11: {} // 11-31: {a=1} // 31-41: {a=1, b=1} // 31-56: {b=1} // 56-100: {} assertEquals(11, m.firstAnnotationChange(0, 100, "a", null)); assertEquals(41, m.firstAnnotationChange(11, 100, "a", "1")); assertEquals(31, m.firstAnnotationChange(0, 100, "b", null)); assertEquals(56, m.firstAnnotationChange(31, 100, "b", "1")); }
@SuppressWarnings("unchecked") public void testListenerForInsertion() throws OperationException { final AnnotationSetListener<Object> listener = mock(AnnotationSetListener.class); RawAnnotationSet<Object> m = getNewSet(listener); m.begin(); m.startAnnotation("a", "1"); m.insert(1); m.endAnnotation("a"); m.finish(); verify(listener).onAnnotationChange(0, 1, "a", "1"); m.begin(); m.skip(1); m.insert(1); m.finish(); }
@SuppressWarnings("unchecked") public void testListenerForInsertion() throws OperationException { final AnnotationSetListener<Object> listener = mock(AnnotationSetListener.class); RawAnnotationSet<Object> m = getNewSet(listener); m.begin(); m.startAnnotation("a", "1"); m.insert(1); m.endAnnotation("a"); m.finish(); verify(listener).onAnnotationChange(0, 1, "a", "1"); m.begin(); m.skip(1); m.insert(1); m.finish(); }
public void testInitialStartLocation() { RawAnnotationSet<Object> m = getNewSet(); m.begin(); m.insert(100); m.finish(); // -1 if no hasNext() AnnotationCursor c = m.annotationCursor(40, 80, strs("a")); assertEquals(-1, c.currentLocation()); m.begin(); m.skip(50); m.startAnnotation("a", "1"); m.skip(10); m.endAnnotation("a"); m.finish(); // start value, if hasNext(); c = m.annotationCursor(40, 80, strs("a")); assertEquals(40, c.currentLocation()); }
public void testInitialStartLocation() { RawAnnotationSet<Object> m = getNewSet(); m.begin(); m.insert(100); m.finish(); // -1 if no hasNext() AnnotationCursor c = m.annotationCursor(40, 80, strs("a")); assertEquals(-1, c.currentLocation()); m.begin(); m.skip(50); m.startAnnotation("a", "1"); m.skip(10); m.endAnnotation("a"); m.finish(); // start value, if hasNext(); c = m.annotationCursor(40, 80, strs("a")); assertEquals(40, c.currentLocation()); }