com.google.gwt.xml.client.Node.hasChildNodes()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中com.google.gwt.xml.client.Node.hasChildNodes()方法的一些代码示例,展示了Node.hasChildNodes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.hasChildNodes()方法的具体详情如下:
包路径:com.google.gwt.xml.client.Node
类名称:Node
方法名:hasChildNodes

Node.hasChildNodes介绍

[英]This method determines whether this Node has any child nodes.
[中]此方法确定此Node是否有任何子节点。

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

private static void removeWhitespaceInner(Node n, Node parent) {
 // This n is removed from the parent if n is a whitespace node
 if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) {
  Text t = (Text) n;
  if (t.getData().matches("[ \t\n]*")) {
   parent.removeChild(t);
  }
 }
 if (n.hasChildNodes()) {
  int length = n.getChildNodes().getLength();
  List<Node> toBeProcessed = new ArrayList<Node>();
  // We collect all the nodes to iterate as the child nodes will change 
  // upon removal
  for (int i = 0; i < length; i++) {
   toBeProcessed.add(n.getChildNodes().item(i));
  }
  // This changes the child nodes, but the iterator of nodes never changes
  // meaning that this is safe
  for (Node childNode : toBeProcessed) {
   removeWhitespaceInner(childNode, n);
  }
 }
}

代码示例来源:origin: net.wetheinter/gwt-user

private static void removeWhitespaceInner(Node n, Node parent) {
 // This n is removed from the parent if n is a whitespace node
 if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) {
  Text t = (Text) n;
  if (t.getData().matches("[ \t\n]*")) {
   parent.removeChild(t);
  }
 }
 if (n.hasChildNodes()) {
  int length = n.getChildNodes().getLength();
  List<Node> toBeProcessed = new ArrayList<Node>();
  // We collect all the nodes to iterate as the child nodes will change 
  // upon removal
  for (int i = 0; i < length; i++) {
   toBeProcessed.add(n.getChildNodes().item(i));
  }
  // This changes the child nodes, but the iterator of nodes never changes
  // meaning that this is safe
  for (Node childNode : toBeProcessed) {
   removeWhitespaceInner(childNode, n);
  }
 }
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

private static void removeWhitespaceInner(Node n, Node parent) {
 // This n is removed from the parent if n is a whitespace node
 if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) {
  Text t = (Text) n;
  if (t.getData().matches("[ \t\n]*")) {
   parent.removeChild(t);
  }
 }
 if (n.hasChildNodes()) {
  int length = n.getChildNodes().getLength();
  List<Node> toBeProcessed = new ArrayList<Node>();
  // We collect all the nodes to iterate as the child nodes will change 
  // upon removal
  for (int i = 0; i < length; i++) {
   toBeProcessed.add(n.getChildNodes().item(i));
  }
  // This changes the child nodes, but the iterator of nodes never changes
  // meaning that this is safe
  for (Node childNode : toBeProcessed) {
   removeWhitespaceInner(childNode, n);
  }
 }
}

相关文章