@Override public void deleteCharacters(String chars) { b.deleteCharacters(chars.length()); }
private Builder emptyElement(E element, Builder builder) { for (N node = doc.getFirstChild(element); node != null; node = doc.getNextSibling(node)) { E elChild = doc.asElement(node); if (elChild != null) { deleteElement(elChild, builder); } else { builder.deleteCharacters(doc.getData(doc.asText(node)).length()); } } return builder; }
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()); }
/** * Creates an operation to delete the XML fragment * "<a href=\"http://www.google.com/\">google</a>". * * @param location The start of the range where the fragment to be deleted * resides. * @return The operation. */ private static Nindo structuralDeletionSample5(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.deleteElementStart(); builder.deleteCharacters(6); builder.deleteElementEnd(); return builder.build(); }
/** * Creates an operation to delete the XML fragment "12<u>34</u>56". * * @param location The start of the range where the fragment to be deleted * resides. * @return The operation. */ private static Nindo structuralDeletionSample1(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.deleteCharacters(2); builder.deleteElementStart(); builder.deleteCharacters(2); builder.deleteElementEnd(); builder.deleteCharacters(2); return builder.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()); }
/** * Creates an operation to delete the XML fragment * "<a href=\"http://www.google.com/\">google</a>". * * @param location The start of the range where the fragment to be deleted * resides. * @return The operation. */ private static Nindo structuralDeletionSample5(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.deleteElementStart(); builder.deleteCharacters(6); builder.deleteElementEnd(); return builder.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 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()); }
private static Nindo createDeletion(int... deletionBoundaries) { Nindo.Builder builder = new Nindo.Builder(); int location = 0; for (int i = 0; i < deletionBoundaries.length; i += 2) { builder.skip(deletionBoundaries[i] - location); int deletionSize = deletionBoundaries[i+1] - deletionBoundaries[i]; builder.deleteCharacters(deletionSize); location = deletionBoundaries[i+1]; } return builder.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 testBug1() throws OperationException { IndexedDocumentImpl<Node, Element, Text, ?> d = nindoDocumentParser.parseDocument( "<a>a</a>"); Nindo.Builder b = new Nindo.Builder(); b.skip(1); b.deleteCharacters(1); checkApply(d, b.build()); }
private static Nindo createDeletion(int... deletionBoundaries) { Nindo.Builder builder = new Nindo.Builder(); int location = 0; for (int i = 0; i < deletionBoundaries.length; i += 2) { builder.skip(deletionBoundaries[i] - location); int deletionSize = deletionBoundaries[i+1] - deletionBoundaries[i]; builder.deleteCharacters(deletionSize); location = deletionBoundaries[i+1]; } return builder.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 testBug1() throws OperationException { IndexedDocumentImpl<Node, Element, Text, ?> d = nindoDocumentParser.parseDocument( "<a>a</a>"); Nindo.Builder b = new Nindo.Builder(); b.skip(1); b.deleteCharacters(1); checkApply(d, 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()); }