/** * returns the first child node that implements the given class. * * @param <T> * The type of the ODF element to be found. * @param clazz * is a class that extends OdfElement. * @param parentNode * is the parent O of the children to be found. * @return the first child node of the given parentNode that is a clazz or * null if none is found. */ @SuppressWarnings("unchecked") static public <T extends OdfElement> T findFirstChildNode(Class<T> clazz, Node parentNode) { if (parentNode != null && parentNode instanceof ParentNode) { Node node = ((ParentNode) parentNode).getFirstChild(); while ((node != null) && !clazz.isInstance(node)) { node = node.getNextSibling(); } if (node != null) { return (T) node; } } return null; }
/** * returns the first child node that implements the given class. * * @param <T> * The type of the ODF element to be found. * @param clazz * is a class that extends OdfElement. * @param parentNode * is the parent O of the children to be found. * @return the first child node of the given parentNode that is a clazz or * null if none is found. */ @SuppressWarnings("unchecked") static public <T extends OdfElement> T findFirstChildNode(Class<T> clazz, Node parentNode) { if (parentNode != null && parentNode instanceof ParentNode) { Node node = ((ParentNode) parentNode).getFirstChild(); while ((node != null) && !clazz.isInstance(node)) { node = node.getNextSibling(); } if (node != null) { return (T) node; } } return null; }
/** * returns the first child node that implements the given class. * * @param <T> * The type of the ODF element to be found. * @param clazz * is a class that extends OdfElement. * @param parentNode * is the parent O of the children to be found. * @return the first child node of the given parentNode that is a clazz or * null if none is found. */ @SuppressWarnings("unchecked") static public <T extends OdfElement> T findFirstChildNode(Class<T> clazz, Node parentNode) { if (parentNode != null && parentNode instanceof ParentNode) { Node node = ((ParentNode) parentNode).getFirstChild(); while ((node != null) && !clazz.isInstance(node)) { node = node.getNextSibling(); } if (node != null) { return (T) node; } } return null; }
void getTextContent(StringBuffer buf) throws DOMException { Node child = getFirstChild(); while (child != null) { if (hasTextContent(child)) { ((NodeImpl) child).getTextContent(buf); } child = child.getNextSibling(); } }
public String getTextContent() throws DOMException { Node child = getFirstChild(); if (child != null) { Node next = child.getNextSibling(); if (next == null) { return hasTextContent(child) ? ((NodeImpl) child).getTextContent() : ""; } StringBuffer buf = new StringBuffer(); getTextContent(buf); return buf.toString(); } return ""; }
/** * DOM Level 3 WD- Experimental. * Override inherited behavior from NodeImpl to support deep equal. */ public boolean isEqualNode(Node arg) { if (!super.isEqualNode(arg)) { return false; } // there are many ways to do this test, and there isn't any way // better than another. Performance may vary greatly depending on // the implementations involved. This one should work fine for us. Node child1 = getFirstChild(); Node child2 = arg.getFirstChild(); while (child1 != null && child2 != null) { if (!child1.isEqualNode(child2)) { return false; } child1 = child1.getNextSibling(); child2 = child2.getNextSibling(); } if (child1 != child2) { return false; } return true; }
if (containerElement != null && containerElement instanceof ParentNode) { Node node = ((ParentNode) containerElement).getFirstChild(); while ((node != null) && !FormTextareaElement.class.isInstance(node)
if (containerElement != null && containerElement instanceof ParentNode) { Node node = ((ParentNode) containerElement).getFirstChild(); while ((node != null) && !FormTextareaElement.class.isInstance(node)
public void setTextContent(String textContent) throws DOMException { // get rid of any existing children Node child; while ((child = getFirstChild()) != null) { removeChild(child); } // create a Text node to hold the given content if (textContent != null && textContent.length() != 0){ appendChild(ownerDocument().createTextNode(textContent)); } }