break; case START_ELEMENT: builder.elementStart(parser.getTagName(), new AttributesImpl(CollectionUtils .newJavaMap(parser.getAttributes()))); break;
/** * Creates an operation to insert the XML fragment * "<a href=\"http://www.google.com/\">google</a>". * * @param location The location at which the insert the fragment. * @return The operation. */ private static Nindo structuralSample5(int location) { Attributes attributes = new AttributesImpl( Collections.singletonMap("href", "http://www.google.com/")); Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.elementStart("a", new AttributesImpl(attributes)); builder.characters("google"); builder.elementEnd(); return builder.build(); }
/** * Creates an operation to insert the XML fragment * "<a href=\"http://www.google.com/\">google</a>". * * @param location The location at which the insert the fragment. * @return The operation. */ private static Nindo structuralSample5(int location) { Attributes attributes = new AttributesImpl( Collections.singletonMap("href", "http://www.google.com/")); Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.elementStart("a", new AttributesImpl(attributes)); builder.characters("google"); builder.elementEnd(); return builder.build(); }
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();
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();
/** * Creates an operation to insert the XML fragment "12<u>3<i/><b/>4</u>56". * * @param location The location at which the insert the fragment. * @return The operation. */ private static Nindo structuralSample3(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.characters("12"); builder.elementStart("u", Attributes.EMPTY_MAP); builder.characters("3"); builder.elementStart("i", Attributes.EMPTY_MAP); builder.elementEnd(); builder.elementStart("b", Attributes.EMPTY_MAP); builder.elementEnd(); builder.characters("4"); builder.elementEnd(); builder.characters("56"); return builder.build(); }
/** * Creates an operation to insert the XML fragment * "12<u>3<i>hello</i><b>world</b>4</u>56". * * @param location The location at which the insert the fragment. * @return The operation. */ private static Nindo structuralSample2(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.characters("12"); builder.elementStart("u", Attributes.EMPTY_MAP); builder.characters("3"); builder.elementStart("i", Attributes.EMPTY_MAP); builder.characters("hello"); builder.elementEnd(); builder.elementStart("b", Attributes.EMPTY_MAP); builder.characters("world"); builder.elementEnd(); builder.characters("4"); builder.elementEnd(); builder.characters("56"); return builder.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)); }
/** * Creates an operation to insert the XML fragment * "12<u>3<i>hello</i><b>world</b>4</u>56". * * @param location The location at which the insert the fragment. * @return The operation. */ private static Nindo structuralSample2(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.characters("12"); builder.elementStart("u", Attributes.EMPTY_MAP); builder.characters("3"); builder.elementStart("i", Attributes.EMPTY_MAP); builder.characters("hello"); builder.elementEnd(); builder.elementStart("b", Attributes.EMPTY_MAP); builder.characters("world"); builder.elementEnd(); builder.characters("4"); builder.elementEnd(); builder.characters("56"); return builder.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)); }
/** * Creates an operation to insert the XML fragment "12<u>3<i/><b/>4</u>56". * * @param location The location at which the insert the fragment. * @return The operation. */ private static Nindo structuralSample3(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.characters("12"); builder.elementStart("u", Attributes.EMPTY_MAP); builder.characters("3"); builder.elementStart("i", Attributes.EMPTY_MAP); builder.elementEnd(); builder.elementStart("b", Attributes.EMPTY_MAP); builder.elementEnd(); builder.characters("4"); builder.elementEnd(); builder.characters("56"); return builder.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()); }
/** * Creates an operation to insert the XML fragment "12<u>34</u>56". * * @param location The location at which the insert the fragment. * @return The operation. */ private static Nindo structuralSample1(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.characters("12"); builder.elementStart("u", Attributes.EMPTY_MAP); builder.characters("34"); builder.elementEnd(); builder.characters("56"); return builder.build(); }
/** * Creates an operation to insert the XML fragment "12<u>34</u>56". * * @param location The location at which the insert the fragment. * @return The operation. */ private static Nindo structuralSample1(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.characters("12"); builder.elementStart("u", Attributes.EMPTY_MAP); builder.characters("34"); builder.elementEnd(); builder.characters("56"); return builder.build(); }
/** * Creates an operation to insert the XML fragment "<i>hello</i><b>world</b>". * * @param location The location at which the insert the fragment. * @return The operation. */ private static Nindo structuralSample4(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.elementStart("i", Attributes.EMPTY_MAP); builder.characters("hello"); builder.elementEnd(); builder.elementStart("b", Attributes.EMPTY_MAP); builder.characters("world"); builder.elementEnd(); return builder.build(); }
/** * Creates an operation to insert the XML fragment "<i>hello</i><b>world</b>". * * @param location The location at which the insert the fragment. * @return The operation. */ private static Nindo structuralSample4(int location) { Nindo.Builder builder = new Nindo.Builder(); builder.skip(location); builder.elementStart("i", Attributes.EMPTY_MAP); builder.characters("hello"); builder.elementEnd(); builder.elementStart("b", Attributes.EMPTY_MAP); builder.characters("world"); builder.elementEnd(); return builder.build(); }
private void startElement(Nindo.Builder builder, String tagName, Attributes attributes) { ++elementCount; builder.elementStart(tagName, attributes); ++offset; }
private Builder createElement(String tagName, Attributes attributes, Builder builder) { builder.elementStart(tagName, attributes); builder.elementEnd(); return builder; }
@Override public void elementStart(String type, Attributes attrs) { b.elementStart(type, attrs); } });