public void testSplitAnnotations() throws OperationException { AnnotationTree<Object> tree = new AnnotationTree<Object>(new Object(), new Object(), null); tree.begin(); tree.startAnnotation("a", "1"); tree.insert(1); tree.startAnnotation("a", "2"); tree.insert(5); tree.startAnnotation("a", "1"); tree.insert(1); tree.endAnnotation("a"); tree.finish(); tree.checkSomeInvariants(); tree.begin(); tree.skip(2); tree.startAnnotation("a", "3"); tree.skip(4); tree.endAnnotation("a"); tree.finish(); tree.checkSomeInvariants(); tree.begin(); tree.skip(2); tree.startAnnotation("a", "4"); tree.skip(3); tree.endAnnotation("a"); tree.finish(); tree.checkSomeInvariants();
t.begin(); t.startAnnotation("a", "1"); t.insert(10); t.endAnnotation("a"); t.finish(); assertEquals(1, t.knownKeys().countEntries()); t.begin(); t.startAnnotation("a", null); t.skip(10); t.endAnnotation("a"); t.finish(); assertEquals(0, t.knownKeys().countEntries()); t.begin(); t.startAnnotation("a", null); t.skip(4); t.endAnnotation("a"); t.finish(); assertEquals(0, t.knownKeys().countEntries()); t.begin(); t.startAnnotation("a", "1"); t.insert(10); t.startAnnotation("a", "2"); t.skip(10);
private ObservableIndexedDocument( DocumentHandler<N, E, T> handler, RawDocument<N, E, T> substrate, AnnotationTree<Object> annotations, DocumentSchema schema) { super(substrate, annotations, schema); AnnotationSetListener<Object> listener = new AnnotationSetListener<Object>() { @Override public void onAnnotationChange(int start, int end, String key, Object newValue) { event(new AnnotationChanged<N, E, T>(start, end, key, (String) newValue)); } }; annotations.setListener(listener); this.handler = handler; }
public void testOffBalance() throws OperationException { AnnotationTree<Object> tree = new AnnotationTree<Object>(new Object(), new Object(), null); final int size = 15; insert(tree, 0, size); for (int i = 0; i < size - 1; i++) { setAnnotation(tree, i, i + 1, "a", "" + i); tree.checkSomeInvariants(); } }
public void testRangedAnnotationIteratorWithNonStrings() throws OperationException { AnnotationTree<Object> annotations = new AnnotationTree<Object>( "a", "b", null); IndexedDocumentImpl<Node, Element, Text, ?> doc = annotations.begin(); annotations.skip(1); String c = Annotations.makeLocal("c"); annotations.startAnnotation(c, new Object()); annotations.skip(2); annotations.endAnnotation(c); annotations.finish();
@Override protected AnnotationTree<Object> getNewSet() { return new AnnotationTree<Object>("a", "b", null); } }
public void testRangedAnnotationIteratorWithNonStrings() throws OperationException { AnnotationTree<Object> annotations = new AnnotationTree<Object>( "a", "b", null); IndexedDocumentImpl<Node, Element, Text, ?> doc = annotations.begin(); annotations.skip(1); String c = Annotations.makeLocal("c"); annotations.startAnnotation(c, new Object()); annotations.skip(2); annotations.endAnnotation(c); annotations.finish();
/** * Adapts a raw-document substrate as an indexed document (factory method). * * @param substrate raw document to adapt */ private IndexedDocument<N, E, T> adapt(D substrate, DocumentSchema schema) { AnnotationTree<Object> annotations = new AnnotationTree<Object>(ONE_OBJECT, ANOTHER_OBJECT, null); IndexedDocumentImpl<N, E, T, ?> doc = new IndexedDocumentImpl<N, E, T, Void>(substrate, annotations, schema); return doc; }
public void testOffBalance() throws OperationException { AnnotationTree<Object> tree = new AnnotationTree<Object>(new Object(), new Object(), null); final int size = 15; insert(tree, 0, size); for (int i = 0; i < size - 1; i++) { setAnnotation(tree, i, i + 1, "a", "" + i); tree.checkSomeInvariants(); } }
public void testSplitAnnotations() throws OperationException { AnnotationTree<Object> tree = new AnnotationTree<Object>(new Object(), new Object(), null); tree.begin(); tree.startAnnotation("a", "1"); tree.insert(1); tree.startAnnotation("a", "2"); tree.insert(5); tree.startAnnotation("a", "1"); tree.insert(1); tree.endAnnotation("a"); tree.finish(); tree.checkSomeInvariants(); tree.begin(); tree.skip(2); tree.startAnnotation("a", "3"); tree.skip(4); tree.endAnnotation("a"); tree.finish(); tree.checkSomeInvariants(); tree.begin(); tree.skip(2); tree.startAnnotation("a", "4"); tree.skip(3); tree.endAnnotation("a"); tree.finish(); tree.checkSomeInvariants();
t.begin(); t.startAnnotation("a", "1"); t.insert(10); t.endAnnotation("a"); t.finish(); assertEquals(1, t.knownKeys().countEntries()); t.begin(); t.startAnnotation("a", null); t.skip(10); t.endAnnotation("a"); t.finish(); assertEquals(0, t.knownKeys().countEntries()); t.begin(); t.startAnnotation("a", null); t.skip(4); t.endAnnotation("a"); t.finish(); assertEquals(0, t.knownKeys().countEntries()); t.begin(); t.startAnnotation("a", "1"); t.insert(10); t.startAnnotation("a", "2"); t.skip(10);
@Override protected AnnotationTree<Object> getNewSet() { return new AnnotationTree<Object>("a", "b", null); } }
@Override protected AnnotationTree<Object> getNewSet() { return new AnnotationTree<Object>("a", "b", null); } }
@Override protected AnnotationTree<Object> getNewSet() { return new AnnotationTree<Object>("a", "b", null); } }
@Override protected AnnotationTree<Object> getNewSet(AnnotationSetListener<Object> listener) { return new AnnotationTree<Object>(new Object(), new Object(), listener); }
@Override protected AnnotationTree<Object> getNewSet(AnnotationSetListener<Object> listener) { return new AnnotationTree<Object>(new Object(), new Object(), listener); }
public void testConstructorChecksArguments() { try { new AnnotationTree<String>(null, "a", null); fail(); } catch (NullPointerException e) { // ok } try { new AnnotationTree<String>("a", null, null); fail(); } catch (NullPointerException e) { // ok } try { new AnnotationTree<String>("a", "a", null); fail(); } catch (IllegalArgumentException e) { // ok } try { new AnnotationTree<String>("b", "b", null); fail(); } catch (IllegalArgumentException e) { // ok } // Should not throw. new AnnotationTree<String>("a", "b", null); }
public void testConstructorChecksArguments() { try { new AnnotationTree<String>(null, "a", null); fail(); } catch (NullPointerException e) { // ok } try { new AnnotationTree<String>("a", null, null); fail(); } catch (NullPointerException e) { // ok } try { new AnnotationTree<String>("a", "a", null); fail(); } catch (IllegalArgumentException e) { // ok } try { new AnnotationTree<String>("b", "b", null); fail(); } catch (IllegalArgumentException e) { // ok } // Should not throw. new AnnotationTree<String>("a", "b", null); }
@Override public IndexedDocument<N, E, T> build(DocInitialization operation, DocumentSchema schema) { AnnotationTree<Object> annotations = new AnnotationTree<Object>(ONE_OBJECT, ANOTHER_OBJECT, null); IndexedDocumentImpl<N, E, T, ?> doc = new IndexedDocumentImpl<N, E, T, Void>( substrateProvider.create("doc", Attributes.EMPTY_MAP), annotations, schema); try { doc.consume(operation); } catch (OperationException e) { throw new OperationRuntimeException("Invalid initialization", e); } return doc; }
public void testRemoveAll() throws OperationException { AnnotationTree<Object> tree = new AnnotationTree<Object>(new Object(), new Object(), null); insert(tree, 0, 1); setAnnotation(tree, 0, 1, "a", "0"); setAnnotation(tree, 0, 1, "a", null); delete(tree, 0, 1); }