@Override public N getNextSibling(N node) { return getDelegate().getNextSibling(node); }
/** * 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); }
/** * @param index The index of the tag we are interested in. * @return The element that contains the desired tag. */ private E getNthTagNode(int index) { N node = doc.getFirstChild(doc.getDocumentElement()); for (int i = 0; i < index; i++) { if (node == null) { return null; } node = doc.getNextSibling(node); } return doc.asElement(node); }
/** * Reads the document and sets up the initial state. If a node without text * is found, it is deleted and reported as a non-fatal error. */ public void processInitialState() { List<N> emptyNodes = new ArrayList<N>(); for (N node = doc.getFirstChild(doc.getDocumentElement()); node != null; node = doc.getNextSibling(node)) { T textNode = doc.asText(doc.getFirstChild(node)); if (textNode == null) { emptyNodes.add(node); } else { notifyAddTag(doc.getData(textNode)); tagElements.add(doc.asElement(node)); } } for (N emptyNode : emptyNodes) { doc.deleteNode(doc.asElement(emptyNode)); } }
@Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { E top = DocHelper.getFirstChildElement(doc, doc.getDocumentElement()); assertEquals(foreign, top); assertNull(doc.getNextSibling(top)); } });
@Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { E top = DocHelper.getFirstChildElement(doc, doc.getDocumentElement()); assertEquals(foreign, top); assertNull(doc.getNextSibling(top)); } });
/** * Deletes a tag from the document by name. * * @param tagName the name of the tag to delete. */ public void deleteTag(String tagName) { N node = doc.getFirstChild(doc.getDocumentElement()); while (node != null) { E element = doc.asElement(node); if (element != null) { T textNode = doc.asText(doc.getFirstChild(node)); if (textNode != null && doc.getData(textNode).equals(tagName)) { doc.deleteNode(element); return; } } node = doc.getNextSibling(node); } }
for (N lc = doc.getFirstChild(root); lc != null; lc = doc.getNextSibling(lc)) { if (isLineContainer(doc, lc)) { int start = -1; for (N line = doc.getFirstChild(lc); line != null; line = doc.getNextSibling(line)) { if (isLineElement(doc, line)) { if (start > 0) {
public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { Point<N> startText = doc.locate(locateAfterLineElement(doc)); doc.insertText(startText, "cd"); // Insert reply between c|d. N bodyNode = DocHelper.getElementWithTagName(doc, Blips.BODY_TAGNAME); N textNode = doc.getFirstChild(bodyNode); textNode = doc.getNextSibling(textNode); int replyLocation = doc.getLocation(Point.inText(textNode, 1)); blip.addReplyThread(replyLocation); // Insert text to give abc|d startText = Point.before(doc, textNode); doc.insertText(startText, "ab"); int newLocation = blip.locateReplyThreads().iterator().next().getLocation(); assertEquals(replyLocation + 2, newLocation); } });
public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { Point<N> startText = doc.locate(locateAfterLineElement(doc)); doc.insertText(startText, "cd"); // Insert reply between c|d. N bodyNode = DocHelper.getElementWithTagName(doc, Blips.BODY_TAGNAME); N textNode = doc.getFirstChild(bodyNode); textNode = doc.getNextSibling(textNode); int replyLocation = doc.getLocation(Point.inText(textNode, 1)); blip.addReplyThread(replyLocation); // Insert text to give abc|d startText = Point.before(doc, textNode); doc.insertText(startText, "ab"); int newLocation = blip.locateReplyThreads().iterator().next().getLocation(); assertEquals(replyLocation + 2, newLocation); } });
public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { Point<N> startText = doc.locate(locateAfterLineElement(doc)); doc.insertText(startText, "cd"); // Insert reply between c|d. N bodyNode = DocHelper.getElementWithTagName(doc, Blips.BODY_TAGNAME); N textNode = doc.getFirstChild(bodyNode); textNode = doc.getNextSibling(textNode); int replyLocation = doc.getLocation(Point.inText(textNode, 1)); ConversationThread replyThread = blip.addReplyThread(replyLocation); // Delete text and anchor. doc.deleteRange(Point.before(doc, textNode), Point.inElement(bodyNode, null)); int newLocation = blip.locateReplyThreads().iterator().next().getLocation(); assertEquals(Blips.INVALID_INLINE_LOCATION, newLocation); } });
public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { Point<N> startText = doc.locate(locateAfterLineElement(doc)); doc.insertText(startText, "cd"); // Insert reply between c|d. N bodyNode = DocHelper.getElementWithTagName(doc, Blips.BODY_TAGNAME); N textNode = doc.getFirstChild(bodyNode); textNode = doc.getNextSibling(textNode); int replyLocation = doc.getLocation(Point.inText(textNode, 1)); ConversationThread replyThread = blip.addReplyThread(replyLocation); // Delete text and anchor. doc.deleteRange(Point.before(doc, textNode), Point.inElement(bodyNode, null)); int newLocation = blip.locateReplyThreads().iterator().next().getLocation(); assertEquals(Blips.INVALID_INLINE_LOCATION, newLocation); } });
for (N child = doc.getFirstChild(lc); child != null; child = doc.getNextSibling(lc)) { if (isLineElement(doc, child)) { if (doc.getLocation(child) < location) {