b.replaceAttributes(attrs); b.elementStart("x", attrs("a", "1")); b.characters("hello");
b.replaceAttributes(attrs); b.elementStart("x", attrs("a", "1")); b.characters("hello");
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()); }
@SuppressWarnings("unchecked") public void doTestInserts() throws OperationException { String a = "<p>abc<b>def</b></p>"; create(a); Element firstEl = (Element) doc.getFirstChild(doc.getDocumentElement()); Builder b = at(0); Attributes attrs = attrs("x", "1", "y", "2"); b.replaceAttributes(attrs); b.elementStart("x", attrs("a", "1")); b.characters("hello"); b.elementStart("y", attrs("b", "2", "c", "3")); b.characters("yeah"); b.elementEnd(); b.elementEnd(); String moreText = "more text"; b.characters(moreText); consumeNindo(b.build()); checkEvents( am(firstEl, pairs("x", null, "y", null), attrs), ci(doc.asElement(firstEl.getFirstChild())), ti(14, moreText)); }
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()); }
@SuppressWarnings("unchecked") public void doTestInserts() throws OperationException { String a = "<p>abc<b>def</b></p>"; create(a); Element firstEl = (Element) doc.getFirstChild(doc.getDocumentElement()); Builder b = at(0); Attributes attrs = attrs("x", "1", "y", "2"); b.replaceAttributes(attrs); b.elementStart("x", attrs("a", "1")); b.characters("hello"); b.elementStart("y", attrs("b", "2", "c", "3")); b.characters("yeah"); b.elementEnd(); b.elementEnd(); String moreText = "more text"; b.characters(moreText); consumeNindo(b.build()); checkEvents( am(firstEl, pairs("x", null, "y", null), attrs), ci(doc.asElement(firstEl.getFirstChild())), ti(14, moreText)); }
private Builder setAttributes(Attributes attrs, Builder builder) { builder.replaceAttributes(attrs); return builder; }
@Override public void replaceAttributes(Attributes oldAttrs, Attributes newAttrs) { b.replaceAttributes(newAttrs); }