本文整理了Java中org.dom4j.Element.nodeCount()
方法的一些代码示例,展示了Element.nodeCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.nodeCount()
方法的具体详情如下:
包路径:org.dom4j.Element
类名称:Element
方法名:nodeCount
暂无
代码示例来源:origin: igniterealtime/Openfire
private void treeWalk(Element element, Set<String> set) {
for (int i = 0, size = element.nodeCount(); i < size; i++) {
Node node = element.node(i);
if (node instanceof Element) {
Element emement = (Element) node;
StringTokenizer st = new StringTokenizer(emement.getTextTrim(), ", //{}");
while (st.hasMoreTokens()) {
// Remove enclosing {}
String string = st.nextToken().replaceAll("(\\{)([\\d\\D&&[^}]]+)(})", "$2");
Log.debug("VCardTemplate: found attribute " + string);
set.add(string);
}
treeWalk(emement, set);
}
}
}
}
代码示例来源:origin: igniterealtime/Openfire
private Element treeWalk(Element element, Map<String, String> map) {
for (int i = 0, size = element.nodeCount(); i < size; i++) {
Node node = element.node(i);
if (node instanceof Element) {
Element emement = (Element) node;
String elementText = emement.getTextTrim();
if (elementText != null && !"".equals(elementText)) {
String format = emement.getStringValue();
StringTokenizer st = new StringTokenizer(elementText, ", //{}");
while (st.hasMoreTokens()) {
// Remove enclosing {}
String field = st.nextToken();
String attrib = field.replaceAll("(\\{)(" + field + ")(})", "$2");
String value = map.get(attrib);
format = format.replaceFirst("(\\{)(" + field + ")(})", Matcher.quoteReplacement(value));
}
emement.setText(format);
}
treeWalk(emement, map);
}
}
return element;
}
}
代码示例来源:origin: pentaho/pentaho-kettle
private boolean childNode( Node node, IProgressMonitor monitor ) {
boolean rc = false; // true: we found child nodes
Element ce = (Element) node;
// List child
for ( int j = 0; j < ce.nodeCount(); j++ ) {
Node cnode = ce.node( j );
if ( !Utils.isEmpty( cnode.getName() ) ) {
Element cce = (Element) cnode;
if ( cce.nodeCount() > 1 ) {
if ( childNode( cnode, monitor ) == false ) {
// We do not have child nodes ...
setNodeField( cnode, monitor );
rc = true;
}
} else {
setNodeField( cnode, monitor );
rc = true;
}
}
}
return rc;
}
代码示例来源:origin: pentaho/pentaho-kettle
private void addLoopXPath( Node node, IProgressMonitor monitor ) {
Element ce = (Element) node;
monitor.worked( 1 );
// List child
for ( int j = 0; j < ce.nodeCount(); j++ ) {
if ( monitor.isCanceled() ) {
return;
}
Node cnode = ce.node( j );
if ( !Utils.isEmpty( cnode.getName() ) ) {
Element cce = (Element) cnode;
if ( !listpath.contains( cnode.getPath() ) ) {
nr++;
monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes",
String.valueOf( nr ) ) );
monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.AddingNode",
cnode.getPath() ) );
listpath.add( cnode.getPath() );
}
// let's get child nodes
if ( cce.nodeCount() > 1 ) {
addLoopXPath( cnode, monitor );
}
}
}
}
代码示例来源:origin: igniterealtime/Openfire
StringBuilder buffer = null;
boolean textOnly = true;
for ( int i = 0, size = element.nodeCount(); i < size; i++ ) {
Node node = element.node(i);
if ( node instanceof Text ) {
for ( int i = 0, size = element.nodeCount(); i < size; i++ ) {
Node node = element.node(i);
if (node instanceof Text) {
代码示例来源:origin: igniterealtime/Openfire
protected void writeElement(Element element) throws IOException {
int size = element.nodeCount();
String qualifiedName = element.getQualifiedName();
代码示例来源:origin: org.dom4j/dom4j
/**
* Processes the input object in the given mode. If input is a
* <code>Node</code>, this will processes all of the children of that
* node. If input is a <code>List</code> of <code>Nodes</code>s, these
* nodes will be iterated and all children of each node will be processed.
*
* @param element the input object
* @param mode
* the mode
* @throws Exception
* if something goes wrong
*/
public void applyTemplates(Element element, String mode) throws Exception {
Mode mod = ruleManager.getMode(mode);
// iterate through all children
for (int i = 0, size = element.nodeCount(); i < size; i++) {
Node node = element.node(i);
mod.fireRule(node);
}
}
代码示例来源:origin: org.dom4j/dom4j
public static org.w3c.dom.Node getNextSibling(Node node) {
Element parent = node.getParent();
if (parent != null) {
int index = parent.indexOf(node);
if (index >= 0) {
if (++index < parent.nodeCount()) {
Node next = parent.node(index);
return asDOMNode(next);
}
}
}
return null;
}
代码示例来源:origin: org.dom4j/dom4j
public void applyTemplates(Element element) throws Exception {
for (int i = 0, size = element.attributeCount(); i < size; i++) {
Attribute attribute = element.attribute(i);
fireRule(attribute);
}
for (int i = 0, size = element.nodeCount(); i < size; i++) {
Node node = element.node(i);
fireRule(node);
}
}
代码示例来源:origin: org.dom4j/dom4j
int size = element.nodeCount();
代码示例来源:origin: org.dom4j/dom4j
protected void writeElement(Element element) throws IOException {
int size = element.nodeCount();
String qualifiedName = element.getQualifiedName();
代码示例来源:origin: com.haulmont.cuba/cuba-core
protected void replaceInXmlTree(Element element, Map<Class, Class> classMapping) {
for (int i = 0; i < element.nodeCount(); i++) {
Node node = element.node(i);
if (node instanceof Element) {
Element childElement = (Element) node;
replaceClasses(childElement, classMapping);
replaceInXmlTree(childElement, classMapping);
}
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j
public static org.w3c.dom.Node getNextSibling(Node node) {
Element parent = node.getParent();
if (parent != null) {
int index = parent.indexOf(node);
if (index >= 0) {
if (++index < parent.nodeCount()) {
Node next = parent.node(index);
return asDOMNode(next);
}
}
}
return null;
}
代码示例来源:origin: maven/dom4j
public void applyTemplates(Element element) throws Exception {
for (int i = 0, size = element.attributeCount(); i < size; i++) {
Attribute attribute = element.attribute(i);
fireRule(attribute);
}
for (int i = 0, size = element.nodeCount(); i < size; i++) {
Node node = element.node(i);
fireRule(node);
}
}
代码示例来源:origin: org.jenkins-ci.dom4j/dom4j
public void applyTemplates(Element element) throws Exception {
for (int i = 0, size = element.attributeCount(); i < size; i++) {
Attribute attribute = element.attribute(i);
fireRule(attribute);
}
for (int i = 0, size = element.nodeCount(); i < size; i++) {
Node node = element.node(i);
fireRule(node);
}
}
代码示例来源:origin: apache/servicemix-bundles
public void applyTemplates(Element element) throws Exception {
for (int i = 0, size = element.attributeCount(); i < size; i++) {
Attribute attribute = element.attribute(i);
fireRule(attribute);
}
for (int i = 0, size = element.nodeCount(); i < size; i++) {
Node node = element.node(i);
fireRule(node);
}
}
代码示例来源:origin: dom4j/dom4j
public void applyTemplates(Element element) throws Exception {
for (int i = 0, size = element.attributeCount(); i < size; i++) {
Attribute attribute = element.attribute(i);
fireRule(attribute);
}
for (int i = 0, size = element.nodeCount(); i < size; i++) {
Node node = element.node(i);
fireRule(node);
}
}
代码示例来源:origin: org.dom4j/org.motechproject.org.dom4j
public void applyTemplates(Element element) throws Exception {
for (int i = 0, size = element.attributeCount(); i < size; i++) {
Attribute attribute = element.attribute(i);
fireRule(attribute);
}
for (int i = 0, size = element.nodeCount(); i < size; i++) {
Node node = element.node(i);
fireRule(node);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j
public void applyTemplates(Element element) throws Exception {
for (int i = 0, size = element.attributeCount(); i < size; i++) {
Attribute attribute = element.attribute(i);
fireRule(attribute);
}
for (int i = 0, size = element.nodeCount(); i < size; i++) {
Node node = element.node(i);
fireRule(node);
}
}
代码示例来源:origin: dom4j/dom4j
public void testGetNode() throws Exception {
Element root = document.getRootElement();
assertNotNull("Has root element", root);
int count = root.nodeCount();
assertTrue("Root has correct node count", count == 2);
boolean iterated = false;
for (int i = 0; i < count; i++) {
Node node = root.node(i);
assertTrue("Valid node returned from node()", node != null);
iterated = true;
}
assertTrue("Iteration completed", iterated);
}
内容来源于网络,如有侵权,请联系作者删除!