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

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

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

Node.getChildNodes介绍

[英]This method retrieves the child nodes.
[中]此方法检索子节点。

代码示例

代码示例来源: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);
  }
 }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient

protected void parse(Node node) {
  NodeList childNodes = node.getChildNodes();
  for (int i = 0; i < childNodes.getLength(); i++) {
    Node child = childNodes.item(i);
    String nodeName = child.getNodeName();
    if ("Name".equalsIgnoreCase(nodeName)) {
      name = getValueRecursive(child);
    } else if ("Title".equalsIgnoreCase(nodeName)) {
      title = getValueRecursive(child);
    } else if ("Abstract".equalsIgnoreCase(nodeName)) {
      abstractt = getValueRecursive(child);
    } else if ("LegendURL".equalsIgnoreCase(nodeName)) {
      legendUrl = createLegendInfo(child);
    }
  }
}

代码示例来源:origin: com.googlecode.gwtupload/gwtupload

public static String getXmlNodeValue(Node node) {
 if (node.getNodeType() != Node.ELEMENT_NODE) {
  return null;
 }
 String ret = "";
 NodeList textNodes = node.getChildNodes();
 for (int i = 0; i < textNodes.getLength(); i++) {
  Node n = textNodes.item(i);
  if (n.getNodeType() == Node.TEXT_NODE
    && n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0) {
   ret += n.getNodeValue();
  } else if (n.getNodeType() == Node.CDATA_SECTION_NODE) {
   ret += n.getNodeValue();
  }
 }
 return ret.length() == 0 ? null : ret.replaceAll("^\\s+", "").replaceAll("\\s+$", "");
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-wfs

protected void parse(Node node) {
  parsed = true;
  NodeList childNodes = node.getChildNodes();
  for (int i = 0; i < childNodes.getLength(); i++) {
    Node child = childNodes.item(i);
    String nodeName = child.getNodeName();
    if ("Name".equalsIgnoreCase(nodeName)) {
      name = getValueRecursive(child);
    } else if ("Title".equalsIgnoreCase(nodeName)) {
      title = getValueRecursive(child);
    } else if ("Abstract".equalsIgnoreCase(nodeName)) {
      abstractt = getValueRecursive(child);
    } else if ("Keywords".equalsIgnoreCase(nodeName)) {
      addKeyWords(child);
    } else if ("SRS".equalsIgnoreCase(nodeName)) {
      defaultCrs = getValueRecursive(child);
    } else if ("LatLongBoundingBox".equalsIgnoreCase(nodeName)) {
      addLatLonBoundingBox(child);
    }
  }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient

private void addLatLonBoundingBox(Node bboxNode) {
    NodeList childNodes = bboxNode.getChildNodes();
    double x = 0, y = 0, maxx = 0, maxy = 0;
    for (int i = 0; i < childNodes.getLength(); i++) {
      Node child = childNodes.item(i);
      String nodeName = child.getNodeName();
      if ("westBoundLongitude".equalsIgnoreCase(nodeName)) {
        x = getValueRecursiveAsDouble(child);
      } else if ("eastBoundLongitude".equalsIgnoreCase(nodeName)) {
        maxx = getValueRecursiveAsDouble(child);
      } else if ("southBoundLatitude".equalsIgnoreCase(nodeName)) {
        y = getValueRecursiveAsDouble(child);
      } else if ("northBoundLatitude".equalsIgnoreCase(nodeName)) {
        maxy = getValueRecursiveAsDouble(child);
      }
    }
    latlonBoundingBox = new Bbox(x, y, maxx - x, maxy - y);
  }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient

protected void parse(Node node) {
  queryable = isQueryable(node);
  NodeList childNodes = node.getChildNodes();
  for (int i = 0; i < childNodes.getLength(); i++) {
    Node child = childNodes.item(i);
    String nodeName = child.getNodeName();
    if ("Name".equalsIgnoreCase(nodeName)) {
      name = getValueRecursive(child);
    } else if ("Title".equalsIgnoreCase(nodeName)) {
      title = getValueRecursive(child);
    } else if ("Abstract".equalsIgnoreCase(nodeName)) {
      abstractt = getValueRecursive(child);
    } else if ("KeywordList".equalsIgnoreCase(nodeName)) {
      addKeyWords(child);
    } else if ("CRS".equalsIgnoreCase(nodeName)) {
      crs.add(getValueRecursive(child));
    } else if ("EX_GeographicBoundingBox".equalsIgnoreCase(nodeName)) {
      addLatLonBoundingBox(child);
    } else if ("BoundingBox".equalsIgnoreCase(nodeName)) {
      addBoundingBox(child);
    } else if ("MetadataURL".equalsIgnoreCase(nodeName)) {
      metadataUrl = new WmsLayerMetadataUrlInfo130(child);
    } else if ("Style".equalsIgnoreCase(nodeName)) {
      styleInfo.add(new WmsLayerStyleInfo130(child));
    }
  }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient

protected void parse(Node node) {
  queryable = isQueryable(node);
  NodeList childNodes = node.getChildNodes();
  for (int i = 0; i < childNodes.getLength(); i++) {
    Node child = childNodes.item(i);
    String nodeName = child.getNodeName();
    if ("Name".equalsIgnoreCase(nodeName)) {
      name = getValueRecursive(child);
    } else if ("Title".equalsIgnoreCase(nodeName)) {
      title = getValueRecursive(child);
    } else if ("Abstract".equalsIgnoreCase(nodeName)) {
      abstractt = getValueRecursive(child);
    } else if ("KeywordList".equalsIgnoreCase(nodeName)) {
      addKeyWords(child);
    } else if ("SRS".equalsIgnoreCase(nodeName)) {
      crs.add(getValueRecursive(child));
    } else if ("BoundingBox".equalsIgnoreCase(nodeName)) {
      addBoundingBox(child);
    } else if ("LatLonBoundingBox".equalsIgnoreCase(nodeName)) {
      addLatLonBoundingBox(child);
    } else if ("MetadataURL".equalsIgnoreCase(nodeName)) {
      metadataUrl = new WmsLayerMetadataUrlInfo111(child);
    } else if ("Style".equalsIgnoreCase(nodeName)) {
      styleInfo.add(new WmsLayerStyleInfo111(child));
    }
  }
}

代码示例来源:origin: com.googlecode.gwtupload/gwtupload

public static String getXmlNodeValue(NodeList list, String tagName, int idx) {
 if (list == null || list.getLength() <= idx) {
  return null;
 }
 Node node = list.item(idx);
 if (node.getNodeType() != Node.ELEMENT_NODE) {
  return null;
 }
 String ret = "";
 NodeList textNodes = node.getChildNodes();
 for (int i = 0; i < textNodes.getLength(); i++) {
  Node n = textNodes.item(i);
  if (n.getNodeType() == Node.TEXT_NODE
    && n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0) {
   ret += n.getNodeValue();
  } else if (n.getNodeType() == Node.CDATA_SECTION_NODE) {
   ret += n.getNodeValue();
  }
 }
 return ret.length() == 0 ? null : ret.replaceAll("^\\s+", "").replaceAll("\\s+$", "");
}

代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient

protected void parse(Node node) {
  NamedNodeMap attributes = node.getAttributes();
  type = getValueRecursive(attributes.getNamedItem("type"));
  NodeList childNodes = node.getChildNodes();
  for (int i = 0; i < childNodes.getLength(); i++) {
    Node child = childNodes.item(i);
    String nodeName = child.getNodeName();
    if ("Format".equalsIgnoreCase(nodeName)) {
      format = getValueRecursive(child);
    } else if ("OnlineResource".equalsIgnoreCase(nodeName)) {
      onlineResource = createOnlineResource(child);
    }
  }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient

protected void parse(Node node) {
  NamedNodeMap attributes = node.getAttributes();
  width = getValueRecursiveAsInteger(attributes.getNamedItem("width"));
  height = getValueRecursiveAsInteger(attributes.getNamedItem("height"));
  NodeList childNodes = node.getChildNodes();
  for (int i = 0; i < childNodes.getLength(); i++) {
    Node child = childNodes.item(i);
    String nodeName = child.getNodeName();
    if ("Format".equalsIgnoreCase(nodeName)) {
      format = getValueRecursive(child);
    } else if ("OnlineResource".equalsIgnoreCase(nodeName)) {
      onlineResource = createOnlineResource(child);
    }
  }
}

相关文章