List of usage examples for com.google.gwt.xml.client Node getNodeName
String getNodeName();
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);//from www .ja 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.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; }/*from w ww .j a v a 2 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; }//from w w w.ja v a 2 s .com attributes.put(node.getNodeName(), node.getNodeValue()); } return attributes; }
From source file:com.codenvy.editor.api.editor.common.ContentFormatter.java
License:Apache License
/** * Parse XML node to text format./*from w w w .j a v a 2 s. c o m*/ * * @param node * node that need to be formatted * @param depth * depth of node in xml * @return node in text format */ @NotNull private static String parseXMLNode(@NotNull Node node, int depth) { StringBuilder outputXml = new StringBuilder(); if (depth > 0) { outputXml.append('\n').append(createTab(depth)); } outputXml.append('<').append(node.getNodeName()).append(transformAttributes(node.getAttributes())) .append('>'); outputXml.append(transformChildrenNodes(node, depth)); if (!hasTextChildNode(node)) { outputXml.append('\n').append(createTab(depth)); } outputXml.append("</").append(node.getNodeName()).append('>'); return outputXml.toString(); }
From source file:com.codenvy.editor.api.editor.common.ContentFormatter.java
License:Apache License
/** * Transform attributes of xml node to string format. * * @param attributes//w ww.j a va 2s . co 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.editor.api.editor.common.ContentFormatter.java
License:Apache License
/** * Returns whether a node is the text node. * * @param node/*from w w w . ja va2 s . co m*/ * node that need to be checked * @return <code>true</code> if a node is the text node, and <code>false</code> otherwise */ private static boolean isTextNode(@NotNull Node node) { return node.getNodeName().equals("#text"); }
From source file:com.codenvy.editor.api.editor.elements.AbstractLink.java
License:Apache License
/** {@inheritDoc} */ @Override/*from w w w . j a v a 2s.c om*/ public void applyProperty(@Nonnull Node node) { String nodeName = node.getNodeName(); String nodeValue = node.getChildNodes().item(0).getNodeValue(); switch (nodeName) { case "source": source = nodeValue; break; case "target": target = nodeValue; break; case "uuid": id = nodeValue; break; } }
From source file:com.codenvy.editor.api.editor.elements.AbstractShape.java
License:Apache License
/** {@inheritDoc} */ @Override/*from w w w.j a va 2 s . co m*/ public void deserialize(@Nonnull Node node) { NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); String name = item.getNodeName(); if (isProperty(name)) { applyProperty(item); } else { Element element = findElement(name); element.deserialize(item); if (element instanceof Shape) { addShape((Shape) element); } else { addLink((Link) element); } } } }
From source file:com.codenvy.editor.api.editor.elements.AbstractShape.java
License:Apache License
/** {@inheritDoc} */ @Override//from w w w .j a v a2 s .com public void deserializeInternalFormat(@Nonnull Node node) { NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); String name = item.getNodeName(); if (isInternalProperty(name)) { applyProperty(item); } else { Element element = findElement(name); element.deserializeInternalFormat(item); if (element instanceof Shape) { addShape((Shape) element); } else { addLink((Link) element); } } } }
From source file:com.codenvy.editor.client.elements.Shape1.java
License:Apache License
@Override public void applyProperty(@Nonnull Node node) { String nodeName = node.getNodeName(); String nodeValue = node.getChildNodes().item(0).getNodeValue(); switch (nodeName) { case "property1": property1 = nodeValue;// w w w . j a va 2 s.c om break; case "x": setX(Integer.valueOf(nodeValue)); break; case "y": setY(Integer.valueOf(nodeValue)); break; case "uuid": id = nodeValue; break; case "autoAlign": setAutoAlignmentParam(Boolean.valueOf(nodeValue)); break; } }