@Override protected Element stringToElement( String xml ) { return XMLParser.parse( xml ).getDocumentElement(); }
private boolean hasProperty(String name) { return properties != null && properties.getElementsByTagName(name) != null; }
protected XMLPacketImplGWT(final String name, @Nullable final String namespace) { document = XMLParser.createDocument(); element = document.createElement(name); if (namespace != null) { element.setAttribute("xmlns", namespace); } document.appendChild(element); }
Element databaseConnection = document.createElement( DATABASE_CONNECTION ); document.appendChild( databaseConnection ); Element databaseName = document.createElement( DATABASE_NAME ); Text databaseNameText = document.createTextNode( dbConn.getDatabaseName() ); databaseName.appendChild( databaseNameText ); databaseConnection.appendChild( databaseName ); Element databasePort = document.createElement( DATABASE_PORT ); Text databasePortText = document.createTextNode( dbConn.getDatabasePort() ); databasePort.appendChild( databasePortText ); databaseConnection.appendChild( databasePort ); Element hostname = document.createElement( HOSTNAME ); Text hostnameText = document.createTextNode( dbConn.getHostname() ); hostname.appendChild( hostnameText ); databaseConnection.appendChild( hostname ); Element indexTablespace = document.createElement( INDEX_TABLESPACE ); Text indexTablespaceText = document.createTextNode( dbConn.getIndexTablespace() ); indexTablespace.appendChild( indexTablespaceText ); databaseConnection.appendChild( indexTablespace ); Element dataTablespace = document.createElement( DATA_TABLESPACE ); Text dataTablespaceText = document.createTextNode( dbConn.getIndexTablespace() ); dataTablespace.appendChild( dataTablespaceText ); databaseConnection.appendChild( dataTablespace ); Element informixServername = document.createElement( SERVER_NAME );
@Override public XMLPacket addChild(final String name, final String namespace) { final Element newElement = document.createElement(checkNotNull(name)); if (namespace != null) { newElement.setAttribute("xmlns", namespace); } element.appendChild(newElement); return new XMLPacketImplGWT(newElement); }
@Override public void setText(final String text) { // TODO: remove ALL children? final NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node child = nodes.item(i); if (child.getNodeType() == Node.TEXT_NODE) { element.removeChild(child); } } if (!Strings.isNullOrEmpty(text)) { element.appendChild(document.createTextNode(text)); } }
@Override public XMLPacket addChild(final HasXML child) { checkArgument(checkNotNull(child.getXML()) instanceof XMLPacketImplGWT); final Element newElement = (Element) document.importNode(((XMLPacketImplGWT) child.getXML()).element, true); element.appendChild(newElement); return new XMLPacketImplGWT(newElement); }
public void nodeAdded(Object parent, Object node, int index) { Element parentNode = nodes.get(parent); Element childNode = document.createElement("event"); for (int i = 0; i < model.getColumnCount(); i++) { childNode.setAttribute(getAttributeName(i), getAttributeValue(node, i)); } parentNode.appendChild(childNode); nodes.put(node, childNode); updateTextArea(); }
@Override public XMLPacket getFirstParent() { return new XMLPacketImplGWT(document.getDocumentElement()); }
/** * return the text content of a tag in the position idx inside a xml document */ public static String getXmlNodeValue(Document doc, String tag, int idx) { if (doc == null) { return null; } return getXmlNodeValue(doc.getElementsByTagName(tag), tag, idx); }
public XmlDebugPanel(TreeTableModel model) { this.model = model; nodes = new IdentityHashMap<Object, Element>(); document = XMLParser.createDocument(); root = document.createElement("debug-panel"); initWidget(textArea = new TextArea()); textArea.ensureDebugId("debug-panel-xml"); textArea.setStyleName(Utils.style() + "-xml"); // Build the XML document based on the current state. document.appendChild(root); nodes.put(model.getRoot(), root); build(model.getRoot()); model.addTreeTableModelListener(this); }
/** * Parses a string into a XMLPacket. * * @param xml the string to parse * @return the resulting packet */ public static XMLPacket fromString(final String xml) { try { return new XMLPacketImplGWT(XMLParser.parse(xml).getDocumentElement()); } catch (final DOMParseException e) { return null; } }
public ArrayList<String> getParameters(String name) { ArrayList<String> array = new ArrayList<String>(); if (hasProperty(name)) { NodeList nodes = this.properties.getElementsByTagName(name); for (int i = 0; i < nodes.getLength(); i++) { array.add(nodes.item(i).getFirstChild().toString()); } } return array; }
public List<IDatasourceInfo> convert() { Document document = getXMLDocumentFromString( xml ); return getDatasourceInfoList( document.getDocumentElement() ); }
public boolean isSetProperty(String name) { return hasProperty(name) && properties.getElementsByTagName(name).getLength() > 0; }
private List<String> convertReponseToList( Response response ) { List<String> dataList = new ArrayList<String>(); Document document = (Document) XMLParser.parse( response.getText() ); Element element = document.getDocumentElement(); Node node = element.getFirstChild(); boolean done = false; do { try { dataList.add( getNodeValueByTagName( node, "Item" ) ); node = ( node.getNextSibling() != null ) ? node.getNextSibling() : null; if ( node == null ) { done = true; } } catch ( Exception e ) { done = true; } } while ( !done ); return dataList; }
private void parseEntries(@Nonnull final Document document) { NodeList entryNodes = document.getElementsByTagName(ENTRY_TAG); if (entryNodes != null) { Node entryNode; for (int i = 0; i < entryNodes.getLength(); i++) { entryNode = entryNodes.item(i); assert entryNode != null; if (entryNode.getNodeType() == ELEMENT_NODE) { entries.add(new Entry(entryNodes.item(i))); } } Collections.reverse(entries); } } }
public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { Document messageDom = XMLParser.parse(response.getText()); WmsGetCapabilitiesInfo capabilities; switch (version) { case V1_1_1: capabilities = new WmsGetCapabilitiesInfo111(messageDom.getDocumentElement()); break; case V1_3_0: capabilities = new WmsGetCapabilitiesInfo130(messageDom.getDocumentElement()); break; default: callback.onFailure("Unsupported version"); return; } callback.onSuccess(capabilities); } else { callback.onFailure(response.getText()); } } });
private void parseLinks(@Nonnull final Document document) { NodeList linkNodes = document.getElementsByTagName(LINK_TAG); if (linkNodes != null) { Node linkNode; for (int i = 0; i < linkNodes.getLength(); i++) { linkNode = linkNodes.item(i); if (isLinkBelongToFeed(linkNode)) { setLink(linkNode); } } } }
public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { try { Document messageDom = XMLParser.parse(response.getText()); WfsGetCapabilitiesInfo capabilities; switch (version) { case V1_0_0: capabilities = new WfsGetCapabilitiesInfo100(messageDom.getDocumentElement()); break; default: callback.onFailure("Unsupported version"); return; } callback.onSuccess(capabilities); } catch (Throwable t) { t.printStackTrace(); callback.onFailure(t.getMessage()); } } else { callback.onFailure(response.getText()); } } });