@Override protected AnnotationTree<Object> getNewSet() { return new AnnotationTree<Object>("a", "b", null); } }
/** * 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; }
@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); } }
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; }
@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 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 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(); } }
@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); }
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); }
void testPerformance1(Random random) { RawAnnotationSet<Object> a = new SimpleAnnotationSet(null); RawAnnotationSet<Object> b = new AnnotationTree<Object>(new Object(), new Object(), null); String[] keys = new String[NUM_KEYS]; for (int i = 0; i < keys.length; i++) { keys[i] = "k" + i; } String[] values = new String[NUM_KEYS]; for (int i = 0; i < values.length; i++) { values[i] = "v" + i; } int maxLength = 0; RawAnnotationSet<Object> c = b; for (int i = 0; i < NUM_UPDATES; i++) { applyRandomOperation(null, c, keys, values, random); maxLength = Math.max(maxLength, c.size()); for (int j = 0; j < QUERIES_PER_UPDATE; j++) { performRandomQuery(c, keys, random); } } System.err.println("final length=" + c.size() + ", max length=" + maxLength); }
void testPerformance1(Random random) { RawAnnotationSet<Object> a = new SimpleAnnotationSet(null); RawAnnotationSet<Object> b = new AnnotationTree<Object>(new Object(), new Object(), null); String[] keys = new String[NUM_KEYS]; for (int i = 0; i < keys.length; i++) { keys[i] = "k" + i; } String[] values = new String[NUM_KEYS]; for (int i = 0; i < values.length; i++) { values[i] = "v" + i; } int maxLength = 0; RawAnnotationSet<Object> c = b; for (int i = 0; i < NUM_UPDATES; i++) { applyRandomOperation(null, c, keys, values, random); maxLength = Math.max(maxLength, c.size()); for (int j = 0; j < QUERIES_PER_UPDATE; j++) { performRandomQuery(c, keys, random); } } System.err.println("final length=" + c.size() + ", max length=" + maxLength); }
public void testEraseMergeDuringSetAnnotation() throws OperationException { { AnnotationTree<Object> tree = new AnnotationTree<Object>(new Object(), new Object(), null); insert(tree, 0, 3); setAnnotation(tree, 0, 1, "a", "1"); setAnnotation(tree, 1, 2, "a", "2"); setAnnotation(tree, 2, 3, "a", "3"); setAnnotation(tree, 0, 2, "a", "5"); } { AnnotationTree<Object> tree = new AnnotationTree<Object>(new Object(), new Object(), null); insert(tree, 0, 3); setAnnotation(tree, 0, 1, "a", "1"); setAnnotation(tree, 1, 2, "a", "2"); setAnnotation(tree, 2, 3, "a", "3"); setAnnotation(tree, 1, 3, "a", "5"); } }
public void testEraseMergeDuringSetAnnotation() throws OperationException { { AnnotationTree<Object> tree = new AnnotationTree<Object>(new Object(), new Object(), null); insert(tree, 0, 3); setAnnotation(tree, 0, 1, "a", "1"); setAnnotation(tree, 1, 2, "a", "2"); setAnnotation(tree, 2, 3, "a", "3"); setAnnotation(tree, 0, 2, "a", "5"); } { AnnotationTree<Object> tree = new AnnotationTree<Object>(new Object(), new Object(), null); insert(tree, 0, 3); setAnnotation(tree, 0, 1, "a", "1"); setAnnotation(tree, 1, 2, "a", "2"); setAnnotation(tree, 2, 3, "a", "3"); setAnnotation(tree, 1, 3, "a", "5"); } }
public void testCantGetLocationOfInvalidNode() throws OperationException { AnnotationTree<Object> annotations = new AnnotationTree<Object>( "a", "b", null); RawDocumentImpl rawDoc = RawDocumentImpl.PROVIDER.parse("<doc><p></p></doc>");
public void testCantGetLocationOfInvalidNode() throws OperationException { AnnotationTree<Object> annotations = new AnnotationTree<Object>( "a", "b", null); RawDocumentImpl rawDoc = RawDocumentImpl.PROVIDER.parse("<doc><p></p></doc>");