本文整理了Java中org.dom4j.Branch.node()
方法的一些代码示例,展示了Branch.node()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Branch.node()
方法的具体详情如下:
包路径:org.dom4j.Branch
类名称:Branch
方法名:node
[英]Returns the Node
at the specified index position.
[中]返回指定索引位置处的Node
。
代码示例来源:origin: org.dom4j/dom4j
public int compareContent(Branch b1, Branch b2) {
int c1 = b1.nodeCount();
int c2 = b2.nodeCount();
int answer = c1 - c2;
if (answer == 0) {
for (int i = 0; i < c1; i++) {
Node n1 = b1.node(i);
Node n2 = b2.node(i);
answer = compare(n1, n2);
if (answer != 0) {
break;
}
}
}
return answer;
}
代码示例来源:origin: org.hudsonci.xpath/xpath-service
private Node getNodeForPath(Document doc, SimplePath path) {
Node node = doc;
for (SimplePath p = path; p != null; p = p.next) {
if (!(node instanceof Branch))
throw new IllegalStateException("Node with children not a Branch");
Branch parent = (Branch) node;
node = parent.node(p.childNum);
}
return node;
}
代码示例来源:origin: org.dom4j/dom4j
/**
* Writes each child node within the provided {@link Branch}instance. This
* method simply iterates through the {@link Branch}'s nodes and calls
* {@link #writeNode(Node)}.
*
* @param branch
* The node whose children will be written to the stream.
*
* @throws XMLStreamException
* If an error occurs writing to the stream.
*/
public void writeChildNodes(Branch branch) throws XMLStreamException {
for (int i = 0, s = branch.nodeCount(); i < s; i++) {
Node n = branch.node(i);
writeNode(n);
}
}
代码示例来源:origin: org.dom4j/dom4j
public static void appendElementsByTagName(List<? super Element> list, Branch parent,
String name) {
final boolean isStar = "*".equals(name);
for (int i = 0, size = parent.nodeCount(); i < size; i++) {
Node node = parent.node(i);
if (node instanceof Element) {
Element element = (Element) node;
if (isStar || name.equals(element.getName())) {
list.add(element);
}
appendElementsByTagName(list, element, name);
}
}
}
代码示例来源:origin: org.dom4j/dom4j
public void appendContent(Branch branch) {
for (int i = 0, size = branch.nodeCount(); i < size; i++) {
Node node = branch.node(i);
add((Node) node.clone());
}
}
代码示例来源:origin: org.dom4j/dom4j
public static void appendElementsByTagNameNS(List<? super Element> list, Branch parent,
String namespace, String localName) {
final boolean isStarNS = "*".equals(namespace);
final boolean isStar = "*".equals(localName);
for (int i = 0, size = parent.nodeCount(); i < size; i++) {
Node node = parent.node(i);
if (node instanceof Element) {
Element element = (Element) node;
if ((isStarNS
|| (((namespace == null)
|| (namespace.length() == 0)) && ((element
.getNamespaceURI() == null) || (element
.getNamespaceURI().length() == 0)))
|| ((namespace != null) && namespace
.equals(element.getNamespaceURI())))
&& (isStar || localName.equals(element.getName()))) {
list.add(element);
}
appendElementsByTagNameNS(list, element, namespace, localName);
}
}
}
代码示例来源:origin: org.dom4j/dom4j
/**
* Factory method to create List of children TreeNodes
*
* @return DOCUMENT ME!
*/
protected List<TreeNode> createChildList() {
// add attributes and content as children?
Branch branch = getXmlBranch();
int size = branch.nodeCount();
List<TreeNode> childList = new ArrayList<TreeNode>(size);
for (int i = 0; i < size; i++) {
Node node = branch.node(i);
// ignore whitespace text nodes
if (node instanceof CharacterData) {
String text = node.getText();
if (text == null) {
continue;
}
text = text.trim();
if (text.length() <= 0) {
continue;
}
}
childList.add(createChildTreeNode(node));
}
return childList;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j
public static void appendElementsByTagName(List list, Branch parent,
String name) {
final boolean isStar = "*".equals(name);
for (int i = 0, size = parent.nodeCount(); i < size; i++) {
Node node = parent.node(i);
if (node instanceof Element) {
Element element = (Element) node;
if (isStar || name.equals(element.getName())) {
list.add(element);
}
appendElementsByTagName(list, element, name);
}
}
}
代码示例来源:origin: org.dom4j/com.springsource.org.dom4j
public static void appendElementsByTagName(List list, Branch parent,
String name) {
final boolean isStar = "*".equals(name);
for (int i = 0, size = parent.nodeCount(); i < size; i++) {
Node node = parent.node(i);
if (node instanceof Element) {
Element element = (Element) node;
if (isStar || name.equals(element.getName())) {
list.add(element);
}
appendElementsByTagName(list, element, name);
}
}
}
代码示例来源:origin: dom4j/dom4j
public void appendContent(Branch branch) {
for (int i = 0, size = branch.nodeCount(); i < size; i++) {
Node node = branch.node(i);
add((Node) node.clone());
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j
public void appendContent(Branch branch) {
for (int i = 0, size = branch.nodeCount(); i < size; i++) {
Node node = branch.node(i);
add((Node) node.clone());
}
}
代码示例来源:origin: org.dom4j/com.springsource.org.dom4j
public void appendContent(Branch branch) {
for (int i = 0, size = branch.nodeCount(); i < size; i++) {
Node node = branch.node(i);
add((Node) node.clone());
}
}
代码示例来源:origin: maven/dom4j
public void appendContent(Branch branch) {
for (int i = 0, size = branch.nodeCount(); i < size; i++) {
Node node = branch.node(i);
add((Node) node.clone());
}
}
代码示例来源:origin: org.dom4j/org.motechproject.org.dom4j
public void appendContent(Branch branch) {
for (int i = 0, size = branch.nodeCount(); i < size; i++) {
Node node = branch.node(i);
add((Node) node.clone());
}
}
代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand
public void appendContent(Branch branch) {
for (int i = 0, size = branch.nodeCount(); i < size; i++) {
Node node = branch.node(i);
add((Node) node.clone());
}
}
代码示例来源:origin: org.jenkins-ci.dom4j/dom4j
public void appendContent(Branch branch) {
for (int i = 0, size = branch.nodeCount(); i < size; i++) {
Node node = branch.node(i);
add((Node) node.clone());
}
}
代码示例来源:origin: apache/servicemix-bundles
public void appendContent(Branch branch) {
for (int i = 0, size = branch.nodeCount(); i < size; i++) {
Node node = branch.node(i);
add((Node) node.clone());
}
}
代码示例来源:origin: org.hudsonci.xpath/xpath-service
private void createChildren(Branch dparent, org.w3c.dom.Node wparent) {
Branch b = (Branch) dparent;
for (int i = 0, n = b.nodeCount(); i < n; i++) {
Node child = b.node(i);
org.w3c.dom.Node wchild = createChild(child, wparent);
if (wchild != null)
createChildren((Branch)child, wchild);
}
endText(wparent);
}
代码示例来源:origin: dom4j/dom4j
/**
* Tests all the children of the branch have the correct parent
*
* @param parent
* DOCUMENT ME!
*/
protected void testParent(Branch parent) {
for (int i = 0, size = parent.nodeCount(); i < size; i++) {
Node node = parent.node(i);
assertTrue("Child node of root has parent of root", node
.getParent() == parent);
}
}
代码示例来源:origin: dom4j/dom4j
/**
* Tests all the children of the branch have the correct document
*
* @param branch
* DOCUMENT ME!
* @param doc
* DOCUMENT ME!
*/
protected void testDocument(Branch branch, Document doc) {
for (int i = 0, size = branch.nodeCount(); i < size; i++) {
Node node = branch.node(i);
assertTrue("Node has correct document", node.getDocument() == doc);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!