Example usage for com.google.gwt.xml.client NamedNodeMap item

List of usage examples for com.google.gwt.xml.client NamedNodeMap item

Introduction

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

Prototype

Node item(int index);

Source Link

Document

This method gets the item at the index position.

Usage

From source file:com.bramosystems.oss.player.playlist.client.impl.SAXParser.java

License:Apache License

private void processNodes(NodeList node) throws ParseException {
    for (int i = 0; i < node.getLength(); i++) {
        Node nd = node.item(i);//ww w.  j a v a 2  s .c  o  m
        switch (nd.getNodeType()) {
        case Node.ELEMENT_NODE:
            HashMap<String, String> attr = new HashMap<String, String>();
            NamedNodeMap nnm = nd.getAttributes();
            for (int j = 0; j < nnm.getLength(); j++) {
                Node nm = nnm.item(j);
                attr.put(nm.getNodeName(), nm.getNodeValue());
            }
            handler.onNodeStart(nd.getNodeName(), attr, nd.getNamespaceURI());
            processNodes(nd.getChildNodes());
            handler.onNodeEnd(nd.getNodeName());
            break;
        case Node.TEXT_NODE:
            handler.setNodeValue(nd.getParentNode().getNodeName(), nd.getNodeValue());
        }
    }
}

From source file:com.calclab.emite.base.xml.XMLPacketImplGWT.java

License:Open Source License

@Override
public ImmutableMap<String, String> getAttributes() {
    final ImmutableMap.Builder<String, String> result = ImmutableMap.builder();
    final NamedNodeMap attribs = element.getAttributes();
    for (int i = 0; i < attribs.getLength(); i++) {
        final Attr attrib = (Attr) attribs.item(i);
        result.put(attrib.getName(), attrib.getValue());
    }/* w  ww. j  av  a  2s.c om*/
    return result.build();
}

From source file:com.calclab.emite.core.client.packet.gwt.GWTPacket.java

License:Open Source License

@Override
public HashMap<String, String> getAttributes() {
    final HashMap<String, String> map = new HashMap<String, String>();
    final NamedNodeMap attributes = element.getAttributes();
    for (int index = 0; index < attributes.getLength(); index++) {
        final Node attrib = attributes.item(index);
        if (attrib == null) {
            continue;
        }/*  w  ww. j  av a2  s. c  om*/

        map.put(attrib.getNodeName(), attrib.getNodeValue());
    }
    return map;
}

From source file:com.calclab.emite.core.client.packet.gwt.GWTPacket.java

License:Open Source License

public Map<String, String> getAttributtes() {
    final HashMap<String, String> attributes = new HashMap<String, String>();
    final NamedNodeMap original = element.getAttributes();
    for (int index = 0; index < original.getLength(); index++) {
        final Node node = original.item(index);
        if (node == null) {
            continue;
        }// w  w w .j a  va  2 s.c  o  m

        attributes.put(node.getNodeName(), node.getNodeValue());
    }
    return attributes;
}

From source file:com.codenvy.editor.api.editor.common.ContentFormatter.java

License:Apache License

/**
 * Transform attributes of xml node to string format.
 *
 * @param attributes/*from  w  w w.j a va 2  s  .  c  o m*/
 *         attributes that need to be formatted
 * @return node's attributes in text format
 */
@NotNull
private static String transformAttributes(@NotNull NamedNodeMap attributes) {
    StringBuilder text = new StringBuilder();

    for (int i = 0; i < attributes.getLength(); i++) {
        Node item = attributes.item(i);
        text.append(' ').append(item.getNodeName()).append("=\"").append(item.getNodeValue()).append('"');
    }

    return text.toString();
}

From source file:com.codenvy.ide.client.common.ContentFormatter.java

License:Open Source License

/**
 * Transform attributes of xml node to string format.
 *
 * @param attributes//from   w ww.j a  va  2 s .co m
 *         attributes that need to be formatted
 * @return node's attributes in text format
 */
@Nonnull
private static String transformAttributes(@Nonnull NamedNodeMap attributes) {
    StringBuilder text = new StringBuilder();

    for (int i = 0; i < attributes.getLength(); i++) {
        Node item = attributes.item(i);
        text.append(' ').append(item.getNodeName()).append("=\"").append(item.getNodeValue()).append('"');
    }

    return text.toString();
}

From source file:com.codenvy.ide.client.elements.AbstractEntityElement.java

License:Open Source License

/**
 * Read all attributes from XML node to the diagram element
 *
 * @param node// ww  w. j  av  a 2s .co  m
 *         XML node that need to be analyzed
 */
protected void readXMLAttributes(@Nonnull Node node) {
    NamedNodeMap attributeMap = node.getAttributes();

    for (int i = 0; i < attributeMap.getLength(); i++) {
        Node attributeNode = attributeMap.item(i);

        String nodeName = attributeNode.getNodeName();
        String nodeValue = attributeNode.getNodeValue();

        applyAttribute(nodeName, nodeValue);
    }
}

From source file:com.codenvy.ide.client.elements.Branch.java

License:Open Source License

/**
 * Deserialize attributes of current node.
 *
 * @param node//ww w  . j  a  v  a 2 s .  c om
 *         XML node that need to be deserialized
 */
private void deserializeAttributes(@Nonnull Node node) {
    attributes.clear();

    NamedNodeMap attributeMap = node.getAttributes();

    for (int i = 0; i < attributeMap.getLength(); i++) {
        Node attributeNode = attributeMap.item(i);

        attributes.put(attributeNode.getNodeName(), attributeNode.getNodeValue());
    }
}

From source file:com.codenvy.ide.client.elements.endpoints.address.AddressEndpoint.java

License:Open Source License

/**
 * Apply addressing properties from XML node to the diagram element.
 *
 * @param node/*from  w  w w  .  j  a  va  2 s  .c  om*/
 *         XML node that need to be analyzed
 */
private void applyAddressingProperties(@Nonnull Node node) {
    putProperty(ADDRESSING_ENABLED, true);

    NamedNodeMap attributeMap = node.getAttributes();

    for (int i = 0; i < attributeMap.getLength(); i++) {
        Node attributeNode = attributeMap.item(i);

        String attributeName = attributeNode.getNodeName();
        String attributeValue = attributeNode.getNodeValue();

        applyAddressingAttribute(attributeName, attributeValue);
    }
}

From source file:com.codenvy.ide.client.elements.mediators.log.Property.java

License:Open Source License

/**
 * Apply attributes from XML node to the diagram element
 *
 * @param node//ww w  . ja v a  2s  .  c  om
 *         XML node that need to be analyzed
 */
public void applyAttributes(@Nonnull Node node) {
    NamedNodeMap attributeMap = node.getAttributes();

    for (int i = 0; i < attributeMap.getLength(); i++) {
        Node attributeNode = attributeMap.item(i);

        String nodeName = attributeNode.getNodeName();
        String nodeValue = attributeNode.getNodeValue();

        switch (nodeName) {
        case NAME_ATTRIBUTE:
            putProperty(NAME, nodeValue);
            break;

        case EXPRESSION_ATTRIBUTE:
            putProperty(EXPRESSION, nodeValue);
            putProperty(TYPE, ValueType.EXPRESSION);
            break;

        case VALUE_ATTRIBUTE:
            putProperty(VALUE, nodeValue);
            break;

        default:
            applyNameSpace(nameSpaceProvider, getProperty(NAMESPACES), nodeName, nodeValue);
        }
    }
}