Example usage for com.google.gwt.xml.client Node hasAttributes

List of usage examples for com.google.gwt.xml.client Node hasAttributes

Introduction

In this page you can find the example usage for com.google.gwt.xml.client Node hasAttributes.

Prototype

boolean hasAttributes();

Source Link

Document

This method determines whether this Node has any attributes.

Usage

From source file:com.colinalworth.xmlview.client.XmlTreeViewModel.java

License:Apache License

@Override
public boolean isLeaf(Object value) {
    Node node = (Node) value;
    if (node instanceof Document) {
        //TODO consider replacing this with return true, as an empty document is useless
        return !node.hasChildNodes();
    } else if (node instanceof Element) {
        //is not a leaf if it has children, or if it has attributes
        return !node.hasChildNodes() && !node.hasAttributes();
    }/*w  w w.  j a  va  2 s .  co m*/
    //if not a Node, it is a leaf
    return true;
}

From source file:org.geomajas.gwt2.client.service.AbstractXmlNodeWrapper.java

License:Open Source License

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

From source file:org.geomajas.plugin.wms.client.capabilities.v1_1_1.WmsGetCapabilitiesInfo111.java

License:Open Source License

protected void parse(Node node) {
    if (node instanceof Element) {
        Element element = (Element) node;
        NodeList layerNodes = element.getElementsByTagName("Layer");

        layers = new ArrayList<WmsLayerInfo>();
        for (int i = 0; i < layerNodes.getLength(); i++) {
            Node layerNode = layerNodes.item(i);
            if (layerNode.hasAttributes()) {
                WmsLayerInfo layer = new WmsLayerInfo111(layerNode);
                layers.add(layer);//w  ww  .  ja v  a 2s .co m
            }
        }
    }
}

From source file:org.geomajas.plugin.wms.client.capabilities.v1_3_0.WmsGetCapabilitiesInfo130.java

License:Open Source License

protected void parse(Node node) {
    if (node instanceof Element) {
        Element element = (Element) node;
        NodeList layerNodes = element.getElementsByTagName("Layer");

        layers = new ArrayList<WmsLayerInfo>();
        for (int i = 0; i < layerNodes.getLength(); i++) {
            Node layerNode = layerNodes.item(i);
            if (layerNode.hasAttributes()) {
                WmsLayerInfo layer = new WmsLayerInfo130(layerNode);
                layers.add(layer);//  w  w  w.  j a  v  a 2 s  .c o  m
            }
        }
    }
}

From source file:org.ow2.proactive_grid_cloud_portal.scheduler.client.SubmitWindow.java

License:Open Source License

/**
 * @param jobDescriptor an XML job descriptor as a string
 * @return the name/value of all <variables><variable name value> elements
 *//*from w w w.  ja va2s. com*/
private Map<String, String> readVars(String jobDescriptor) {
    /* this will fail if someday the XML schema gets another <variable> tag elsewhere */

    Document dom = XMLParser.parse(jobDescriptor);
    NodeList variables = dom.getElementsByTagName("variable");
    Map<String, String> ret = new HashMap<String, String>();

    if (variables.getLength() > 0) {
        for (int i = 0; i < variables.getLength(); i++) {
            Node n = variables.item(i);

            if (n != null) {
                NamedNodeMap attrs = n.getAttributes();
                try {
                    if (attrs != null && n.hasAttributes()) {
                        String name = null;
                        String value = null;
                        for (int j = 0; j < attrs.getLength(); j++) {
                            Node attr = attrs.item(j);
                            if (attr.getNodeName().equals("name")) {
                                name = attr.getNodeValue();
                            }
                            if (attr.getNodeName().equals("value")) {
                                value = attr.getNodeValue();
                            }
                        }
                        if (name != null && value != null) {
                            if (!name.matches("[A-Za-z0-9._]+")) {
                                // this won't necessarily be a problem at job submission,
                                // but it definitely will be here in the client; don't bother
                                continue;
                            }

                            ret.put(name, value);
                        }
                    }
                } catch (JavaScriptException t) {
                    // Node.hasAttributes() throws if there are no attributes... (GWT 2.1.0)
                }
            }
        }
    }
    return ret;
}

From source file:stroom.widget.xsdbrowser.client.view.XMLUtil.java

License:Apache License

public static String getAttributeValue(final Node node, final XSDAttribute attribute,
        final boolean removePrefix) {
    String value = null;//w  ww .  ja  va  2 s  .  co m
    if (node != null && !(node instanceof CharacterData) && node.hasAttributes()) {
        final Node att = node.getAttributes().getNamedItem(attribute.toString());
        if (att != null) {
            if (removePrefix) {
                value = removePrefix(att.getNodeValue());
            } else {
                value = att.getNodeValue();
            }
        }
    }

    return value;
}