@Override protected void onDeleteCharacters(int location, String characters) { if (depth == 0) { // TODO(danilatos): Drop the TextDeleted event altogether. event(new TextDeleted<N, E, T>(location, characters)); } if (deletion != null) { deletion.addText(characters); } }
private void beginChange() { beforeBegin(); inconsistent = true; resetLocation(); annotations.begin(); }
@Override protected void onCharacters(int location, String characters) { if (depth == 0) { event(new TextInserted<N, E, T>(location, characters)); } }
@Override protected RawAnnotationSet<Object> getNewSet() { SimpleAnnotationSet set = new SimpleAnnotationSet(null); // Just to make sure we are in fact testing the generic annotation cursor assertTrue(set.annotationCursor(0, 0, strs()) instanceof GenericAnnotationCursor); return set; }
/** * 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 void onElementStart(E element) { if (depth == 0) { event(new ContentInserted<N, E, T>(element)); } // Remember the element just inserted, to include in event. inserted(element); depth++; }
/** * {@inheritDoc} */ public AnnotationCursor annotationCursor(int start, int end, ReadableStringSet keys) { if (keys == null) { keys = knownKeys(); } else { checkValidPersistentKeys(keys); } return annotations.annotationCursor(start, end, keys); }
@Override protected void onDeleteElementStart(int location, E element) { assert (deletion == null) == (depth == 0); if (depth == 0) { deletion = new ContentDeleted.Builder<N, E, T>(location, element); } depth++; // Save the element about to be deleted. deleted(element); deletion.addElementStart(getTagName(element), getAttributes(element)); }
<D extends NindoSink & ModifiableDocument> void run(DocumentParser<D> parser) { D document = parser.parseDocument(initialDocument); for (TestComponent component : testComponents) { component.run(document, parser); } } }
@Override protected void onModifyAttributes(E element, AttributesUpdate update) { event(new AttributesModified<N, E, T>(element, update)); }
@Override public void endAnnotation(String key) { assert currentChanges.containsKey(key); maybeNoteChange(key); currentChanges.remove(key); }
@Override protected void onDeleteElementEnd() { assert deletion != null; deletion.addElementEnd(); depth--; if (depth == 0) { event(deletion.build()); deletion = null; } }
private void deleted(E element) { currentEvent().addDeletedElement(element); }
@Override protected RawAnnotationSet<Object> getNewSet() { SimpleAnnotationSet set = new SimpleAnnotationSet(null); // Just to make sure we are in fact testing the generic annotation cursor assertTrue(set.annotationCursor(0, 0, strs()) instanceof GenericAnnotationCursor); return set; }
<D extends NindoSink & ModifiableDocument> void run(DocumentParser<D> parser) { D document = parser.parseDocument(initialDocument); for (TestComponent component : testComponents) { component.run(document, parser); } } }
@Override protected void onModifyAttributes(E element, Attributes oldAttributes, Attributes newAttributes) { event(new AttributesModified<N, E, T>(element, oldAttributes, newAttributes)); }