private Builder setAttribute(String name, String value, Builder builder) { builder.updateAttributes(Collections.singletonMap(name, value)); return builder; }
@Override public void updateAttributes(AttributesUpdate attrUpdate) { Map<String, String> updates = new HashMap<String, String>(); for (int i = 0; i < attrUpdate.changeSize(); i++) { updates.put(attrUpdate.getChangeKey(i), attrUpdate.getNewValue(i)); } b.updateAttributes(updates); }
public void testOpenDuringInsertionThenUpdate2() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdef<q><r/></q>ghijkl"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(8); b.startAnnotation("a", "1"); b.skip(5); b.endAnnotation("a"); checkApply(doc, b.build()); b = new Nindo.Builder(); b.startAnnotation("a", "1"); b.skip(7); b.updateAttributes(Collections.singletonMap("u", "v")); //b.replaceAttributes(new AttributesImpl("v", "u")); b.skip(3); b.endAnnotation("a"); checkApply(doc, b.build()); }
public void testOpenDuringInsertionThenUpdate2() throws OperationException { IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse("abcdef<q><r/></q>ghijkl"); Nindo.Builder b; b = new Nindo.Builder(); b.skip(8); b.startAnnotation("a", "1"); b.skip(5); b.endAnnotation("a"); checkApply(doc, b.build()); b = new Nindo.Builder(); b.startAnnotation("a", "1"); b.skip(7); b.updateAttributes(Collections.singletonMap("u", "v")); //b.replaceAttributes(new AttributesImpl("v", "u")); b.skip(3); b.endAnnotation("a"); checkApply(doc, b.build()); }
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 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()); }
private Builder updateAttributes(Map<String, String> attrs, Builder builder) { builder.updateAttributes(attrs); return builder; }