public void testOpenDuringInsertionThenUpdate() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("<q><r/></q>abcdefghijkl"); Nindo.Builder b; b = new Nindo.Builder(); b.startAnnotation("a", "1"); b.skip(7); b.endAnnotation("a"); checkApply(doc, b.build()); b = new Nindo.Builder(); b.elementStart("p", Attributes.EMPTY_MAP); b.startAnnotation("a", null); b.elementEnd(); b.updateAttributes(Collections.singletonMap("u", "v")); b.replaceAttributes(new AttributesImpl("v", "u")); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testInsertionThenDeletionWithAnnotations() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "2"); b.skip(2); b.endAnnotation("a"); checkApply(doc, b.build()); b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", null); b.characters("x"); b.deleteCharacters(1); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testInsertionThenDeletionWithAnnotations() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "2"); b.skip(2); b.endAnnotation("a"); checkApply(doc, b.build()); b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", null); b.characters("x"); b.deleteCharacters(1); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testAnnotationThroughInsertionEndingInDeletion() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "2"); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "1"); b.characters("x"); b.deleteCharacters(1); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testAnnotationThroughInsertionFollowedByDeletion() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "2"); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "1"); b.characters("x"); b.endAnnotation("a"); b.deleteCharacters(1); checkApply(doc, b.build()); }
public void testAnnotationThroughInsertionEndingInDeletion() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "2"); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "1"); b.characters("x"); b.deleteCharacters(1); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testAnnotationThroughInsertionFollowedByDeletion() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "2"); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "1"); b.characters("x"); b.endAnnotation("a"); b.deleteCharacters(1); checkApply(doc, b.build()); }
public void testEndBeforeAndStartAfterDeletionThenInsertion() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", null); b.skip(1); b.endAnnotation("a"); b.deleteCharacters(1); b.startAnnotation("a", "1"); b.characters("x"); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testEndBeforeAndStartAfterDeletion() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", null); b.skip(1); b.endAnnotation("a"); b.deleteCharacters(1); b.startAnnotation("a", "1"); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testEndBeforeAndStartAfterDeletion() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", null); b.skip(1); b.endAnnotation("a"); b.deleteCharacters(1); b.startAnnotation("a", "1"); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testChangeBetweenInsertionAndDeletion() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "1"); b.characters("x"); b.startAnnotation("a", "2"); b.deleteCharacters(1); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testChangeBetweenInsertionAndDeletion() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "1"); b.characters("x"); b.startAnnotation("a", "2"); b.deleteCharacters(1); b.skip(1); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testOpenClose() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "1"); b.startAnnotation("b", "2"); b.startAnnotation("c", "3"); b.endAnnotation("a"); b.endAnnotation("c"); b.endAnnotation("b"); checkApply(doc, b.build()); }
public void testOpenClose() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "1"); b.startAnnotation("b", "2"); b.startAnnotation("c", "3"); b.endAnnotation("a"); b.endAnnotation("c"); b.endAnnotation("b"); checkApply(doc, b.build()); }
public void testDeletionResets() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefghijkl"); Nindo.Builder b; b = new Nindo.Builder(); b.startAnnotation("a", "1"); b.skip(3); b.deleteCharacters(3); b.skip(3); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testOpenInsertOpenClose() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "1"); b.characters("xyz"); b.startAnnotation("a", "1"); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testOpenInsertOpenClose() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", "1"); b.characters("xyz"); b.startAnnotation("a", "1"); b.endAnnotation("a"); checkApply(doc, b.build()); }
@Override public void annotationBoundary(AnnotationBoundaryMap map) { for (int i = 0; i < map.endSize(); i++) { b.endAnnotation(map.getEndKey(i)); } for (int i = 0; i < map.changeSize(); i++) { b.startAnnotation(map.getChangeKey(i), map.getNewValue(i)); } }
public void testDeletionResets() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefghijkl"); Nindo.Builder b; b = new Nindo.Builder(); b.startAnnotation("a", "1"); b.skip(3); b.deleteCharacters(3); b.skip(3); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testEndBeforeAndStartAfterDeletionThenInsertion() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdefg"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(1); b.startAnnotation("a", null); b.skip(1); b.endAnnotation("a"); b.deleteCharacters(1); b.startAnnotation("a", "1"); b.characters("x"); b.endAnnotation("a"); checkApply(doc, b.build()); }