@Override void getContent(Object node, List result) { if (node instanceof Branch) { result.addAll(((Branch) node).content()); } }
private void getDescendants(Branch node, List result) { List content = node.content(); for (Iterator iter = content.iterator(); iter.hasNext(); ) { Node subnode = (Node) iter.next(); if (subnode instanceof Element) { result.add(subnode); getDescendants(subnode, result); } } }
public static org.w3c.dom.Node insertBefore(Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException { if (node instanceof Branch) { assert newChild instanceof Node; Branch branch = (Branch) node; List<Node> list = branch.content(); int index = list.indexOf(refChild); if (index < 0) { branch.add((Node) newChild); } else { list.add(index, (Node) newChild); } return newChild; } else { throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Children not allowed for this node: " + node); } }
public static org.w3c.dom.Node replaceChild(Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild) throws DOMException { if (node instanceof Branch) { Branch branch = (Branch) node; List<Node> list = branch.content(); assert newChild instanceof Node; int index = list.indexOf(oldChild); if (index < 0) { throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to replace a non existing child " + "for node: " + node); } list.set(index, (Node) newChild); return oldChild; } else { throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Children not allowed for this node: " + node); } }
@Override void getContent(Object node, List result) { if (node instanceof Branch) { result.addAll(((Branch) node).content()); } }
void getContent(Object node, List result) { if(node instanceof Branch) { result.addAll(((Branch)node).content()); } }
@Override void getContent(Object node, List result) { if (node instanceof Branch) { result.addAll(((Branch) node).content()); } }
private void getDescendants(Branch node, List result) { List content = node.content(); for (Iterator iter = content.iterator(); iter.hasNext(); ) { Node subnode = (Node) iter.next(); if (subnode instanceof Element) { result.add(subnode); getDescendants(subnode, result); } } }
private void getDescendants(Branch node, List result) { List content = node.content(); for (Iterator iter = content.iterator(); iter.hasNext(); ) { Node subnode = (Node) iter.next(); if (subnode instanceof Element) { result.add(subnode); getDescendants(subnode, result); } } }
private void getDescendants(Branch node, List result) { List content = node.content(); for (Iterator iter = content.iterator(); iter.hasNext();) { Node subnode = (Node) iter.next(); if(subnode instanceof Element) { result.add(subnode); getDescendants(subnode, result); } } }
private boolean nodeContains(Node parent, Node node) { if (parent == node) return true; if (parent instanceof Branch) { Branch branch = (Branch) parent; List children = branch.content(); for (int i = 0, n = children.size(); i < n; i++) { boolean contains = nodeContains((Node)children.get(i), node); if (contains) return true; } } return false; }
public static org.w3c.dom.Node insertBefore(Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException { if (node instanceof Branch) { Branch branch = (Branch) node; List list = branch.content(); int index = list.indexOf(refChild); if (index < 0) { branch.add((Node) newChild); } else { list.add(index, newChild); } return newChild; } else { throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Children not allowed for this node: " + node); } }
public static org.w3c.dom.Node insertBefore(Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException { if (node instanceof Branch) { Branch branch = (Branch) node; List list = branch.content(); int index = list.indexOf(refChild); if (index < 0) { branch.add((Node) newChild); } else { list.add(index, newChild); } return newChild; } else { throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Children not allowed for this node: " + node); } }
public static org.w3c.dom.Node insertBefore(Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException { if (node instanceof Branch) { assert newChild instanceof Node; Branch branch = (Branch) node; List<Node> list = branch.content(); int index = list.indexOf(refChild); if (index < 0) { branch.add((Node) newChild); } else { list.add(index, (Node) newChild); } return newChild; } else { throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Children not allowed for this node: " + node); } }
public static org.w3c.dom.Node insertBefore(Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException { if (node instanceof Branch) { Branch branch = (Branch) node; List list = branch.content(); int index = list.indexOf(refChild); if (index < 0) { branch.add((Node) newChild); } else { list.add(index, newChild); } return newChild; } else { throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Children not allowed for this node: " + node); } }
public static org.w3c.dom.Node replaceChild(Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild) throws DOMException { if (node instanceof Branch) { Branch branch = (Branch) node; List list = branch.content(); int index = list.indexOf(oldChild); if (index < 0) { throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to replace a non existing child " + "for node: " + node); } list.set(index, newChild); return oldChild; } else { throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Children not allowed for this node: " + node); } }
public static org.w3c.dom.Node insertBefore(Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException { if (node instanceof Branch) { Branch branch = (Branch) node; List list = branch.content(); int index = list.indexOf(refChild); if (index < 0) { branch.add((Node) newChild); } else { list.add(index, newChild); } return newChild; } else { throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Children not allowed for this node: " + node); } }
public static org.w3c.dom.Node insertBefore(Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException { if (node instanceof Branch) { Branch branch = (Branch) node; List list = branch.content(); int index = list.indexOf(refChild); if (index < 0) { branch.add((Node) newChild); } else { list.add(index, newChild); } return newChild; } else { throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Children not allowed for this node: " + node); } }
public static org.w3c.dom.Node replaceChild(Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild) throws DOMException { if (node instanceof Branch) { Branch branch = (Branch) node; List<Node> list = branch.content(); assert newChild instanceof Node; int index = list.indexOf(oldChild); if (index < 0) { throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to replace a non existing child " + "for node: " + node); } list.set(index, (Node) newChild); return oldChild; } else { throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Children not allowed for this node: " + node); } }
protected void assertNodesEqualContent(Branch b1, Branch b2) { int c1 = b1.nodeCount(); int c2 = b2.nodeCount(); if (c1 != c2) { log("Content of: " + b1); log("is: " + b1.content()); log("Content of: " + b2); log("is: " + b2.content()); } Assert.assertEquals(c1, c2, String.format("Branches have same number of children (%d, %d for: %s and %s", c1, c2, b1, b2)); for (int i = 0; i < c1; i++) { Node n1 = b1.node(i); Node n2 = b2.node(i); assertNodesEqual(n1, n2); } }