com.google.gwt.xml.client.Node类的使用及代码示例

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

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

Node介绍

[英]This is the base interface for DOM nodes, as obtained from using XMLParser methods. Methods for iterating over and accessing values from nodes are supplied here.
[中]这是DOM节点的基本接口,可以通过使用XMLParser方法获得。这里提供了迭代和访问节点值的方法。

代码示例

代码示例来源:origin: pentaho/data-access

  1. private String getNodeValueByTagName( Node node, String tagName ) {
  2. if ( node != null && node.getFirstChild() != null ) {
  3. return node.getFirstChild().getNodeValue();
  4. } else {
  5. return null;
  6. }
  7. }

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

  1. public static String getXmlNodeValue(Node node) {
  2. if (node.getNodeType() != Node.ELEMENT_NODE) {
  3. return null;
  4. }
  5. String ret = "";
  6. NodeList textNodes = node.getChildNodes();
  7. for (int i = 0; i < textNodes.getLength(); i++) {
  8. Node n = textNodes.item(i);
  9. if (n.getNodeType() == Node.TEXT_NODE
  10. && n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0) {
  11. ret += n.getNodeValue();
  12. } else if (n.getNodeType() == Node.CDATA_SECTION_NODE) {
  13. ret += n.getNodeValue();
  14. }
  15. }
  16. return ret.length() == 0 ? null : ret.replaceAll("^\\s+", "").replaceAll("\\s+$", "");
  17. }

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

  1. private boolean isQueryable(Node layerNode) {
  2. NamedNodeMap attributes = layerNode.getAttributes();
  3. Node q = attributes.getNamedItem("queryable");
  4. if (q != null) {
  5. return "1".equals(q.getNodeValue());
  6. }
  7. return false;
  8. }

代码示例来源: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: org.apache.cxf/cxf-rt-management-web

  1. @Nullable
  2. private String getTextValue(@Nonnull final Node node) {
  3. Node child = node.getFirstChild();
  4. if (child != null && child.getNodeType() == TEXT_NODE) {
  5. return child.getNodeValue();
  6. }
  7. return null;
  8. }

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

  1. protected void parse(Node node) {
  2. NodeList childNodes = node.getChildNodes();
  3. for (int i = 0; i < childNodes.getLength(); i++) {
  4. Node child = childNodes.item(i);
  5. String nodeName = child.getNodeName();
  6. if ("Name".equalsIgnoreCase(nodeName)) {
  7. name = getValueRecursive(child);
  8. } else if ("Title".equalsIgnoreCase(nodeName)) {
  9. title = getValueRecursive(child);
  10. } else if ("Abstract".equalsIgnoreCase(nodeName)) {
  11. abstractt = getValueRecursive(child);
  12. } else if ("LegendURL".equalsIgnoreCase(nodeName)) {
  13. legendUrl = createLegendInfo(child);
  14. }
  15. }
  16. }

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

  1. protected void parse(Node node) {
  2. NamedNodeMap attributes = node.getAttributes();
  3. type = getValueRecursive(attributes.getNamedItem("type"));
  4. NodeList childNodes = node.getChildNodes();
  5. for (int i = 0; i < childNodes.getLength(); i++) {
  6. Node child = childNodes.item(i);
  7. String nodeName = child.getNodeName();
  8. if ("Format".equalsIgnoreCase(nodeName)) {
  9. format = getValueRecursive(child);
  10. } else if ("OnlineResource".equalsIgnoreCase(nodeName)) {
  11. onlineResource = createOnlineResource(child);
  12. }
  13. }
  14. }

代码示例来源:origin: org.metawidget.modules/metawidget-all

  1. @Override
  2. @SuppressWarnings( { "cast", "unchecked" } )
  3. protected Map<String, String> getAttributesAsMap( Element element ) {
  4. NamedNodeMap nodes = element.getAttributes();
  5. int length = nodes.getLength();
  6. if ( length == 0 ) {
  7. return (Map<String, String>) Collections.EMPTY_MAP;
  8. }
  9. Map<String, String> attributes = new HashMap<String, String>( length );
  10. for ( int loop = 0; loop < length; loop++ ) {
  11. Node node = nodes.item( loop );
  12. attributes.put( node.getNodeName(), node.getNodeValue() );
  13. }
  14. return attributes;
  15. }
  16. }

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

  1. protected double getAttributeAsDouble(Node node, String name) {
  2. Node attr = node.getAttributes().getNamedItem(name);
  3. return getValueRecursiveAsDouble(attr);
  4. }

代码示例来源:origin: EmiteGWT/emite

  1. @Override
  2. public String getText() {
  3. final StringBuilder result = new StringBuilder();
  4. final NodeList nodes = element.getChildNodes();
  5. for (int i = 0; i < nodes.getLength(); i++) {
  6. final Node child = nodes.item(i);
  7. if (child.getNodeType() == Node.TEXT_NODE)
  8. result.append(child.getNodeValue());
  9. }
  10. return result.toString();
  11. }

代码示例来源:origin: org.apache.cxf/cxf-rt-management-web

  1. LazyXmlParser(@Nonnull final Node entryNode) {
  2. assert "entry".equals(entryNode.getNodeName());
  3. assert entryNode.getNodeType() == ELEMENT_NODE;
  4. this.entryNode = entryNode;
  5. }

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

  1. protected boolean hasAttribute(Node node, String name) {
  2. return node.hasAttributes() && node.getAttributes().getNamedItem(name) != null;
  3. }

代码示例来源:origin: pentaho/data-access

  1. private List<Node> getNodesByTagName( Element element, String tagName ) {
  2. List<Node> nodes = new ArrayList<Node>();
  3. NodeList list = element.getChildNodes();
  4. for ( int i = 0; i < list.getLength(); i++ ) {
  5. Node node = list.item( i );
  6. if ( node != null && node.getNodeName().equals( tagName ) ) {
  7. nodes.add( node );
  8. }
  9. }
  10. return nodes;
  11. }

代码示例来源:origin: org.apache.cxf/cxf-rt-management-web

  1. private boolean isLinkBelongToFeed(@Nonnull final Node node) {
  2. return node.getParentNode() != null && FEED_TAG.equals(node.getParentNode().getNodeName());
  3. }

代码示例来源:origin: org.apache.cxf/cxf-rt-management-web

  1. private void parseEntries(@Nonnull final Document document) {
  2. NodeList entryNodes = document.getElementsByTagName(ENTRY_TAG);
  3. if (entryNodes != null) {
  4. Node entryNode;
  5. for (int i = 0; i < entryNodes.getLength(); i++) {
  6. entryNode = entryNodes.item(i);
  7. assert entryNode != null;
  8. if (entryNode.getNodeType() == ELEMENT_NODE) {
  9. entries.add(new Entry(entryNodes.item(i)));
  10. }
  11. }
  12. Collections.reverse(entries);
  13. }
  14. }
  15. }

代码示例来源:origin: org.n52.sensorweb/sensorwebclient-ui

  1. public ArrayList<String> getParameters(String name) {
  2. ArrayList<String> array = new ArrayList<String>();
  3. if (hasProperty(name)) {
  4. NodeList nodes = this.properties.getElementsByTagName(name);
  5. for (int i = 0; i < nodes.getLength(); i++) {
  6. array.add(nodes.item(i).getFirstChild().toString());
  7. }
  8. }
  9. return array;
  10. }

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

  1. private void addLatLonBoundingBox(Node bboxNode) {
  2. NodeList childNodes = bboxNode.getChildNodes();
  3. double x = 0, y = 0, maxx = 0, maxy = 0;
  4. for (int i = 0; i < childNodes.getLength(); i++) {
  5. Node child = childNodes.item(i);
  6. String nodeName = child.getNodeName();
  7. if ("westBoundLongitude".equalsIgnoreCase(nodeName)) {
  8. x = getValueRecursiveAsDouble(child);
  9. } else if ("eastBoundLongitude".equalsIgnoreCase(nodeName)) {
  10. maxx = getValueRecursiveAsDouble(child);
  11. } else if ("southBoundLatitude".equalsIgnoreCase(nodeName)) {
  12. y = getValueRecursiveAsDouble(child);
  13. } else if ("northBoundLatitude".equalsIgnoreCase(nodeName)) {
  14. maxy = getValueRecursiveAsDouble(child);
  15. }
  16. }
  17. latlonBoundingBox = new Bbox(x, y, maxx - x, maxy - y);
  18. }
  19. }

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

  1. protected void parse(Node node) {
  2. NamedNodeMap attributes = node.getAttributes();
  3. width = getValueRecursiveAsInteger(attributes.getNamedItem("width"));
  4. height = getValueRecursiveAsInteger(attributes.getNamedItem("height"));
  5. NodeList childNodes = node.getChildNodes();
  6. for (int i = 0; i < childNodes.getLength(); i++) {
  7. Node child = childNodes.item(i);
  8. String nodeName = child.getNodeName();
  9. if ("Format".equalsIgnoreCase(nodeName)) {
  10. format = getValueRecursive(child);
  11. } else if ("OnlineResource".equalsIgnoreCase(nodeName)) {
  12. onlineResource = createOnlineResource(child);
  13. }
  14. }
  15. }

代码示例来源: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: pentaho/data-access

  1. public IDatabaseConnection convertToObject( String xml ) {
  2. Document document = XMLParser.parse( xml );
  3. Element element = document.getDocumentElement();
  4. IDatabaseConnection databaseConnection = new DatabaseConnection();
  5. databaseConnection.setDatabaseName( getNodeValueByTagName( element, DATABASE_NAME ) );
  6. databaseConnection.setHostname( getNodeValueByTagName( element, HOSTNAME ) );
  7. databaseConnection.setIndexTablespace( getNodeValueByTagName( element, INDEX_TABLESPACE ) );
  8. databaseConnection.setDataTablespace( getNodeValueByTagName( element, DATA_TABLESPACE ) );
  9. databaseConnection.setName( getNodeValueByTagName( element, NAME ) );
  10. databaseConnection.setUsername( getNodeValueByTagName( element, USERNAME ) );
  11. databaseConnection.setPassword( getNodeValueByTagName( element, PASSWORD ) );
  12. databaseConnection.setDatabasePort( getNodeValueByTagName( element, DATABASE_PORT ) );
  13. databaseConnection
  14. .setAccessType( DatabaseAccessType.getAccessTypeByName( getNodeValueByTagName( element, ACCESS_TYPE ) ) );
  15. databaseConnection.setDatabaseType(
  16. (DatabaseType) databaseTypeHelper.getDatabaseTypeByShortName( getNodeValueByTagName( element, DATABASE_TYPE ) ) );
  17. databaseConnection.setPassword( getNodeValueByTagName( element, PASSWORD ) );
  18. databaseConnection.setInformixServername( getNodeValueByTagName( element, SERVER_NAME ) );
  19. for ( Node node : getNodesByTagName( element, ATTRIBUTES ) ) {
  20. databaseConnection.getAttributes().put( node.getNodeName(), node.getNodeValue() );
  21. }
  22. return databaseConnection;
  23. }

相关文章