当前位置: 首页>>代码示例>>Java>>正文


Java Node.getChildCount方法代码示例

本文整理汇总了Java中nu.xom.Node.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getChildCount方法的具体用法?Java Node.getChildCount怎么用?Java Node.getChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nu.xom.Node的用法示例。


在下文中一共展示了Node.getChildCount方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: childTextNodesAsDOMList

import nu.xom.Node; //导入方法依赖的package包/类
/**
 * Generate a DOMList of all the text nodes of pNode, in document order.
 * @param pNode The target node.
 * @param pDeep If true, recurse through child nodes adding their text nodes too.
 * @return A DOMList of text nodes.
 */
@Override
public final DOMList childTextNodesAsDOMList(Node pNode, boolean pDeep){
  DOMList lList = new DOMList();
  for(int i=0; i < pNode.getChildCount(); i++){
    if(pNode.getChild(i) instanceof Text){
      //Wrap text nodes in DOMs
      lList.add(new DOM(pNode.getChild(i)));
    }
    else if (pDeep) {
      //Recurse through non-text children
      lList.addAll(childTextNodesAsDOMList(pNode.getChild(i), true));
    }
  }
  return lList;
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:22,代码来源:ActuateReadOnly.java

示例2: serializeNodeContents

import nu.xom.Node; //导入方法依赖的package包/类
public void serializeNodeContents(Node pNode) {
  try {
    startSerialiser();
    for(int i=0; i < pNode.getChildCount(); i++) {
      writeChild(pNode.getChild(i));
      //Place line breaks between elements
      if(mPrettyPrint && (pNode instanceof Element || pNode instanceof Comment || pNode instanceof ProcessingInstruction || pNode instanceof DocType) && i < pNode.getChildCount() - 1) {
        breakLine();
      }
    }
    flush();
  }
  catch (IOException e) {
    throw new ExInternal("XML serialisation failed", e);
  }
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:17,代码来源:ActuateReadOnly.java

示例3: moveContentsTo

import nu.xom.Node; //导入方法依赖的package包/类
/**
 * Moves all the children of pNode into pNewParent. pNode is left as is.
 * @param pNode The Node to copy children from.
 * @param pNewParent The new parent for pNode's children.
 */
public void moveContentsTo(Node pNode, Node pNewParent) {
  //if no children, do nothing
  if(pNode.getChildCount() == 0){
    return;
  }

  //This is a LIVE list so read off the front until it's depleted
  Node lChild;
  while((lChild = (pNode.getChild(0))) != null) {
    moveToParent(lChild, pNewParent);
  }
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:18,代码来源:ActuateReadWriteGeneric.java

示例4: copyContentsTo

import nu.xom.Node; //导入方法依赖的package包/类
/**
 * Copies all the children of pNode into pNewParent. pNode is left as is.
 * @param pNode The Node to copy children from.
 * @param pNewParent The new parent for pNode's children.
 * @param pResetRefs If true, foxids will be reset.
 */
public void copyContentsTo(Node pNode, Node pNewParent, boolean pResetRefs){
  for(int i=0; i<pNode.getChildCount(); i++){
    Node lChild = pNode.getChild(i);
    copyToParent(lChild, pNewParent, pResetRefs);
  }
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:13,代码来源:ActuateReadWriteGeneric.java

示例5: setText

import nu.xom.Node; //导入方法依赖的package包/类
public void setText(Node pNode, String pNewText) {

    mDocControl.setDocumentModifiedCount();

    // Cast to Element (checks is an element)
    Element lElement;
    try {
      lElement = (Element)pNode;
    }
    catch (ClassCastException x) {
      if(pNode instanceof Attribute) {
        Attribute lAttr = (Attribute) pNode;
        lAttr.setValue(XFUtil.nvl(pNewText, "")); // XOM cannot set attribute to null, must be empty string
        return;
      }
      else {
        throw new ExInternal("Cannot setText() on xml node of type "+pNode.getClass().getName(), x);
      }
    }

    // Remove all existing child text nodes
    for(int i = 0; i < pNode.getChildCount(); i++){
      Node lChild = pNode.getChild(i);
      if(lChild instanceof Text) {
        ((ParentNode) pNode).removeChild(lChild);
        i--;
      }
    }

    //Insert the new text node as the first child of the target
    if(!XFUtil.isNull(pNewText)) {
      lElement.insertChild(pNewText, 0);
    }
  }
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:35,代码来源:ActuateReadWrite.java

示例6: _value

import nu.xom.Node; //导入方法依赖的package包/类
/**
 * Concatenates the text nodes of pNode and appends them to pStringBuffer. If pNode is a complex element and pDeep
 * is true, recurses down into pNode and concatenates all text nodes at all levels below and including pNode.
 * @param pNode The target node.
 * @param pStringBuffer The StringBuffer to append the result to.
 * @param pDeep If true, recurse down tree.
 */
private void _value(Node pNode, StringBuffer pStringBuffer, boolean pDeep) {
  for(int i=0; i < pNode.getChildCount(); i++){
    Node c = pNode.getChild(i);
    if(c instanceof Text){
      pStringBuffer.append(((Text)c).getValue());
    } else if (c instanceof Element && pDeep){
      _value(c, pStringBuffer, pDeep);
    }
  }
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:18,代码来源:ActuateReadOnly.java

示例7: getChildNodes

import nu.xom.Node; //导入方法依赖的package包/类
/**
 * Gets all child Nodes for pNode, wrapped as a DOMList.
 * @param pNode The target Node.
 * @return DOMList of all pNodes' child Nodes.
 */
public DOMList getChildNodes(Node pNode) {

  DOMList lDOMList = new DOMList();
  for(int i=0; i < pNode.getChildCount(); i++){
    lDOMList.add(new DOM(pNode.getChild(i)));
  }

  return lDOMList;
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:15,代码来源:ActuateReadOnly.java

示例8: childTextNodesAsStringList

import nu.xom.Node; //导入方法依赖的package包/类
/**
 * Generate a String List of all the text nodes of pNode, in document order.
 * @param pNode The target node.
 * @param pDeep If true, recurse through child nodes adding their text nodes too.
 * @return A List of Strings representing text nodes.
 */
@Override
public final List<String> childTextNodesAsStringList(Node pNode, boolean pDeep){
  List<String> lList = new ArrayList<String>();
  for(int i=0; i < pNode.getChildCount(); i++){
    if(pNode.getChild(i) instanceof Text){
      lList.add(((Text)pNode.getChild(i)).getValue());
    }
    else if (pDeep) {
      lList.addAll(childTextNodesAsStringList(pNode.getChild(i), true));
    }
  }
  return lList;
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:20,代码来源:ActuateReadOnly.java

示例9: hasChildNodes

import nu.xom.Node; //导入方法依赖的package包/类
/**
 * Returns true if the element contains any nodes
 */
public boolean hasChildNodes(Node pNode) {
  return (pNode.getChildCount() > 0);
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:7,代码来源:ActuateReadOnly.java

示例10: advance

import nu.xom.Node; //导入方法依赖的package包/类
private NodeInfo advance() {
	if (currNode == null) { // if includeSelf
		currNode = start.node;
		return start;
	}

	int i;
	do {
		i = 0;
		Node p = currNode;

		if (p.getChildCount() == 0 || moveToNextSibling) { // move to next sibling

			moveToNextSibling = false; // do it just once
			while (true) {
				// if we've reached the root we're done scanning
				p = currNode.getParent();
				if (p == null) return null;

				// Note: correct even if currNode is an attribute.
				// Performance is particularly good with the O(1) patch
				// for XOM's ParentNode.indexOf()
				i = currNode.getParent().indexOf(currNode) + 1;

				if (i < p.getChildCount()) {
					break; // break out of while(true) loop; move to next sibling
				}
				else { // reached last sibling; move up
					currNode = p;
					// if we've come all the way back to the start anchor we're done
					if (p == anchor) return null;
				}
			}
		}
		currNode = p.getChild(i);
	} while (!conforms(currNode));

	// note the null here: makeNodeWrapper(parent, ...) is fast, so it
	// doesn't really matter that we don't keep a link to it.
	// In fact, it makes objects more short lived, easing pressure on
	// the VM allocator and collector for tenured heaps.
	return makeWrapper(currNode, docWrapper, null, i);
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:44,代码来源:NodeWrapper.java


注:本文中的nu.xom.Node.getChildCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。