Refine search
/** * Get the previous sibling of <code>e</code> which is an element, or <code>null</code> if there is no such element. * * @param e * e * @return null if n is null, true otherwise */ public static Element getPreviousSiblingElement(Element e) { Node n = e; if (n == null) return null; while ((n = n.getPreviousSibling()) != null) { if (n.getNodeType() == Node.ELEMENT_NODE) return (Element) n; } return null; }
/** * Get the previous sibling of <code>e</code> which is an element, or <code>null</code> if there is no such element. * * @param e * e * @return null if n is null, true otherwise */ public static Element getPreviousSiblingElement(Element e) { Node n = e; if (n == null) return null; while ((n = n.getPreviousSibling()) != null) { if (n.getNodeType() == Node.ELEMENT_NODE) return (Element) n; } return null; }
/** * Get the previous sibling of <code>e</code> which is an element and has tag name <code>name</code>, or <code>null</code> if * there is no such element. * * @param e * e * @param name * name * @return null if n is null */ public static Element getPreviousSiblingElementByTagName(Element e, String name) { Node n = e; if (n == null) return null; while ((n = n.getPreviousSibling()) != null) { if (n.getNodeType() == Node.ELEMENT_NODE && ((Element) n).getTagName().equals(name)) return (Element) n; } return null; }
/** * Get the previous sibling of <code>e</code> which is an element and has tag name <code>name</code>, or <code>null</code> if * there is no such element. * * @param e * e * @param name * name * @return null if n is null */ public static Element getPreviousSiblingElementByTagName(Element e, String name) { Node n = e; if (n == null) return null; while ((n = n.getPreviousSibling()) != null) { if (n.getNodeType() == Node.ELEMENT_NODE && ((Element) n).getTagName().equals(name)) return (Element) n; } return null; }
/** * Returns the first text or CDATA node in the current sequence of text and * CDATA nodes. */ private TextImpl firstTextNodeInCurrentRun() { TextImpl firstTextInCurrentRun = this; for (Node p = getPreviousSibling(); p != null; p = p.getPreviousSibling()) { short nodeType = p.getNodeType(); if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { firstTextInCurrentRun = (TextImpl) p; } else { break; } } return firstTextInCurrentRun; }
/** * Get the last child of <code>e</code> which is an element, or <code>null</code> if there is no such element. * * @param e * e * @return n */ public static Element getLastChildElement(Element e) { Node n = e.getLastChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { n = n.getPreviousSibling(); } // Now n is either null or an Element return (Element) n; }
/** * Get the last child of <code>e</code> which is an element, or <code>null</code> if there is no such element. * * @param e * e * @return n */ public static Element getLastChildElement(Element e) { Node n = e.getLastChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { n = n.getPreviousSibling(); } // Now n is either null or an Element return (Element) n; }
private void closeElements (Node node) throws IOException { Node prev = (node == null) ? null : node.getPreviousSibling (), next; if (((node == null) && !elements.isEmpty ()) || ((prev != null) && (prev.getNodeType () == Node.ELEMENT_NODE))) { Iterator i = elements.iterator (); do { next = (Node) i.next (); i.remove (); if (elementOpened) { writer.write (" />"); elementOpened = false; } else { writer.write ("</" + next.getNodeName () + ">"); } } while (i.hasNext () && (next != prev)); } else if (elementOpened && (node.getNodeType () != Node.ATTRIBUTE_NODE)) { writer.write (">"); elementOpened = false; } }
for (int i = 0; i < size; i++) { NodeModel child = (NodeModel) children.get(i); if (child.node.getNodeType() == Node.ELEMENT_NODE) { ns.add(child); return new SimpleScalar(buf.toString().trim()); } else if (key.equals(AtAtKey.PREVIOUS_SIBLING_ELEMENT.getKey())) { Node previousSibling = node.getPreviousSibling(); while (previousSibling != null && !this.isSignificantNode(previousSibling)) { previousSibling = previousSibling.getPreviousSibling(); return previousSibling != null && previousSibling.getNodeType() == Node.ELEMENT_NODE ? wrap(previousSibling) : new NodeListModel(Collections.emptyList(), null); } else if (key.equals(AtAtKey.NEXT_SIBLING_ELEMENT.getKey())) { nextSibling = nextSibling.getNextSibling(); return nextSibling != null && nextSibling.getNodeType() == Node.ELEMENT_NODE ? wrap(nextSibling) : new NodeListModel(Collections.emptyList(), null); } else {
private static Node getPreviousTypedNode(Node node, short nodeType) { node = node.getPreviousSibling(); while (node != null && node.getNodeType() != nodeType) { node = node.getPreviousSibling(); } return node; }
public static Element getPrevSibling(Element e) { Node n = e.getPreviousSibling(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) n = n.getPreviousSibling(); return (Element) n; }
public Element getlastChild(Element e) { Node n = e.getLastChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) n = n.getPreviousSibling(); return n == null ? null : (Element) n; }
public static Element getLastChild(Element e) { if (e == null) return null; Node n = e.getLastChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) n = n.getPreviousSibling(); return (Element) n; }
public static Element getLastChild(Element e) { if (e == null) return null; Node n = e.getLastChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) n = n.getPreviousSibling(); return (Element) n; }
public static Element getPrevSibling(Element e) { Node n = e.getPreviousSibling(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) n = n.getPreviousSibling(); return (Element) n; }
private void reapComments(org.w3c.dom.Element element, Element context) { Node node = element.getPreviousSibling(); while (node != null && node.getNodeType() != Node.ELEMENT_NODE) { if (node.getNodeType() == Node.COMMENT_NODE) context.getComments().add(0, node.getTextContent()); node = node.getPreviousSibling(); } node = element.getLastChild(); while (node != null && node.getNodeType() != Node.ELEMENT_NODE) { node = node.getPreviousSibling(); } while (node != null) { if (node.getNodeType() == Node.COMMENT_NODE) context.getComments().add(node.getTextContent()); node = node.getNextSibling(); } }
private void reapComments(org.w3c.dom.Element element, Element context) { Node node = element.getPreviousSibling(); while (node != null && node.getNodeType() != Node.ELEMENT_NODE) { if (node.getNodeType() == Node.COMMENT_NODE) context.getComments().add(0, node.getTextContent()); node = node.getPreviousSibling(); } node = element.getLastChild(); while (node != null && node.getNodeType() != Node.ELEMENT_NODE) { node = node.getPreviousSibling(); } while (node != null) { if (node.getNodeType() == Node.COMMENT_NODE) context.getComments().add(node.getTextContent()); node = node.getNextSibling(); } }
private Node previousElementNode(Node node) { node = node.getPreviousSibling(); while (node != null && node.getNodeType() != ELEMENT_NODE) { node = node.getPreviousSibling(); } return node; }
private static Node getPreviousTypedNode(Node node, short nodeType) { node = node.getPreviousSibling(); while (node != null && node.getNodeType() != nodeType) { node = node.getPreviousSibling(); } return node; }
private static boolean isFirstElementChild(Node node) { node = node.getPreviousSibling(); while (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE) { return false; } node = node.getPreviousSibling(); } return true; }