本文整理了Java中org.dom4j.Branch.content()
方法的一些代码示例,展示了Branch.content()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Branch.content()
方法的具体详情如下:
包路径:org.dom4j.Branch
类名称:Branch
方法名:content
[英]Returns the content nodes of this branch as a backed Listso that the content of this branch may be modified directly using the Listinterface. The List
is backed by the Branch
so that changes to the list are reflected in the branch and vice versa.
[中]将此分支的内容节点作为备份列表返回,以便可以使用Listinterface直接修改此分支的内容。List
由Branch
支持,因此对列表的更改将反映在分支中,反之亦然。
代码示例来源:origin: org.freemarker/freemarker
@Override
void getContent(Object node, List result) {
if (node instanceof Branch) {
result.addAll(((Branch) node).content());
}
}
代码示例来源:origin: org.freemarker/freemarker
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);
}
}
}
代码示例来源:origin: org.dom4j/dom4j
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);
}
}
代码示例来源:origin: org.dom4j/dom4j
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);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
@Override
void getContent(Object node, List result) {
if (node instanceof Branch) {
result.addAll(((Branch) node).content());
}
}
代码示例来源:origin: org.freemarker/com.springsource.freemarker
void getContent(Object node, List result) {
if(node instanceof Branch) {
result.addAll(((Branch)node).content());
}
}
代码示例来源:origin: org.freemarker/freemarker-gae
@Override
void getContent(Object node, List result) {
if (node instanceof Branch) {
result.addAll(((Branch) node).content());
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
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);
}
}
}
代码示例来源:origin: org.freemarker/freemarker-gae
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);
}
}
}
代码示例来源:origin: org.freemarker/com.springsource.freemarker
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);
}
}
}
代码示例来源:origin: org.hudsonci.xpath/xpath-service
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;
}
代码示例来源:origin: org.dom4j/com.springsource.org.dom4j
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);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j
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);
}
}
代码示例来源:origin: dom4j/dom4j
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);
}
}
代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand
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);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j
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);
}
}
代码示例来源:origin: org.dom4j/org.motechproject.org.dom4j
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);
}
}
代码示例来源:origin: maven/dom4j
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);
}
}
代码示例来源:origin: dom4j/dom4j
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);
}
}
代码示例来源:origin: dom4j/dom4j
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);
}
}
内容来源于网络,如有侵权,请联系作者删除!