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

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

本文整理了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

  1. private static void removeWhitespaceInner(Node n, Node parent) {
  2. // This n is removed from the parent if n is a whitespace node
  3. if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) {
  4. Text t = (Text) n;
  5. if (t.getData().matches("[ \t\n]*")) {
  6. parent.removeChild(t);
  7. }
  8. }
  9. if (n.hasChildNodes()) {
  10. int length = n.getChildNodes().getLength();
  11. List<Node> toBeProcessed = new ArrayList<Node>();
  12. // We collect all the nodes to iterate as the child nodes will change
  13. // upon removal
  14. for (int i = 0; i < length; i++) {
  15. toBeProcessed.add(n.getChildNodes().item(i));
  16. }
  17. // This changes the child nodes, but the iterator of nodes never changes
  18. // meaning that this is safe
  19. for (Node childNode : toBeProcessed) {
  20. removeWhitespaceInner(childNode, n);
  21. }
  22. }
  23. }

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

  1. private static void removeWhitespaceInner(Node n, Node parent) {
  2. // This n is removed from the parent if n is a whitespace node
  3. if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) {
  4. Text t = (Text) n;
  5. if (t.getData().matches("[ \t\n]*")) {
  6. parent.removeChild(t);
  7. }
  8. }
  9. if (n.hasChildNodes()) {
  10. int length = n.getChildNodes().getLength();
  11. List<Node> toBeProcessed = new ArrayList<Node>();
  12. // We collect all the nodes to iterate as the child nodes will change
  13. // upon removal
  14. for (int i = 0; i < length; i++) {
  15. toBeProcessed.add(n.getChildNodes().item(i));
  16. }
  17. // This changes the child nodes, but the iterator of nodes never changes
  18. // meaning that this is safe
  19. for (Node childNode : toBeProcessed) {
  20. removeWhitespaceInner(childNode, n);
  21. }
  22. }
  23. }

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

  1. private static void removeWhitespaceInner(Node n, Node parent) {
  2. // This n is removed from the parent if n is a whitespace node
  3. if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) {
  4. Text t = (Text) n;
  5. if (t.getData().matches("[ \t\n]*")) {
  6. parent.removeChild(t);
  7. }
  8. }
  9. if (n.hasChildNodes()) {
  10. int length = n.getChildNodes().getLength();
  11. List<Node> toBeProcessed = new ArrayList<Node>();
  12. // We collect all the nodes to iterate as the child nodes will change
  13. // upon removal
  14. for (int i = 0; i < length; i++) {
  15. toBeProcessed.add(n.getChildNodes().item(i));
  16. }
  17. // This changes the child nodes, but the iterator of nodes never changes
  18. // meaning that this is safe
  19. for (Node childNode : toBeProcessed) {
  20. removeWhitespaceInner(childNode, n);
  21. }
  22. }
  23. }

相关文章