@Override public E insertXml(Point<N> point, XmlStringBuilder xml) { return getDelegate().insertXml(point, xml); }
/** * Inserts content into the start of the line specified by the element. * * @param doc * @param line the line element to insert into * @param initialContent the content to insert * @return the node that was inserted. */ public static <N, E extends N, T extends N> N insertContentIntoLineStart( final MutableDocument<N, E, T> doc, E line, XmlStringBuilder initialContent) { doc.insertXml(Point.after(doc, line), initialContent); return doc.getNextSibling(line); }
/** * Inserts content into the end of the line specified by the element. * * @param doc * @param line the line element to insert into * @param content the content to insert * @return the node that was inserted into. */ public static <N, E extends N, T extends N> N insertContentIntoLineEnd( final MutableDocument<N, E, T> doc, E line, XmlStringBuilder content) { // Find the next line and insert just before it. Point<N> point = roundLocation(doc, Rounding.LINE, Point.start(doc, line), RoundDirection.RIGHT); if (point == null) { throw new AssertionError("Not a valid line location."); } return doc.insertXml(point, content); }
/** * Appends a line to the given line container * * @param doc * @param lineContainer * @param content optional content for the new line, may be null * @param attributes optional attributes, may be null. * @return the line token representing the start of the new line */ public static <N, E extends N, T extends N> E appendLine(final MutableDocument<N, E, T> doc, E lineContainer, XmlStringBuilder content, Attributes attributes) { E line = doc.createChildElement(lineContainer, LINE_TAGNAME, attributes); if (content != null && content.getLength() > 0) { doc.insertXml(Point.<N>end(lineContainer), content); } return line; }
/** * Adds a tag to the document. * * @param tagName The name of the tag. * @param i The index at which to insert the tag. */ public void addTag(String tagName, int i) { E node = getNthTagNode(i); El<N> point = Point.<N>inElement(doc.getDocumentElement(), node); XmlStringBuilder xml = getXmlFor(tagName); doc.insertXml(point, xml); }
/** * Finds the last valid line and appends to the end of it. * * @param doc the document to insert into. * @param content the content to append. */ public static <N, E extends N, T extends N> E appendToLastLine(MutableDocument<N, E, T> doc, XmlStringBuilder content) { checkNotParagraphDocument(doc); // TODO(user): Don't duplicate the code below. for (E el : DocIterate.deepElementsReverse(doc, doc.getDocumentElement(), null)) { if (isLineContainer(doc, el)) { // TODO(user): Check for at least a line tag? I'm assuming // there is one... Point<N> point = Point.inElement((N) el, null); if (point != null) { return doc.insertXml(point, content); } } } // Looks like no line to add to, just append. return appendLine(doc, content); }
if (isLineElement(doc, child)) { if (doc.getLocation(child) < location) { return doc.insertXml(point, content);
doc.insertXml(Point.<N>end(lc), content);