protected String getValueRecursive(Node node) { if (node != null) { if (node.getNodeValue() != null) { return node.getNodeValue(); } if (node.getFirstChild() != null) { return getValueRecursive(node.getFirstChild()); } } return null; }
protected String getValueRecursive(Node node) { if (node != null) { if (node.getNodeValue() != null) { return node.getNodeValue().trim(); } if (node.getFirstChild() != null) { return getValueRecursive(node.getFirstChild()); } } return null; }
private boolean isQueryable(Node layerNode) { NamedNodeMap attributes = layerNode.getAttributes(); Node q = attributes.getNamedItem("queryable"); if (q != null) { return "1".equals(q.getNodeValue()); } return false; }
@Nullable private String getTextValue(@Nonnull final Node node) { Node child = node.getFirstChild(); if (child != null && child.getNodeType() == TEXT_NODE) { return child.getNodeValue(); } return null; }
private boolean isQueryable(Node layerNode) { NamedNodeMap attributes = layerNode.getAttributes(); Node q = attributes.getNamedItem("queryable"); if (q != null) { return "1".equals(q.getNodeValue()); } return false; }
private String getNodeValueByTagName( Node node, String tagName ) { if ( node != null && node.getFirstChild() != null ) { return node.getFirstChild().getNodeValue(); } else { return null; } }
public static String getXmlNodeValue(Node node) { if (node.getNodeType() != Node.ELEMENT_NODE) { return null; } String ret = ""; NodeList textNodes = node.getChildNodes(); for (int i = 0; i < textNodes.getLength(); i++) { Node n = textNodes.item(i); if (n.getNodeType() == Node.TEXT_NODE && n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0) { ret += n.getNodeValue(); } else if (n.getNodeType() == Node.CDATA_SECTION_NODE) { ret += n.getNodeValue(); } } return ret.length() == 0 ? null : ret.replaceAll("^\\s+", "").replaceAll("\\s+$", ""); }
private void setLink(@Nonnull final Node node) { Node typeNode = node.getAttributes().getNamedItem(TYPE_ATTRIBUTE); Node urlNode = node.getAttributes().getNamedItem(URL_ATTRIBUTE); if (typeNode != null && urlNode != null) { String typeValue = typeNode.getNodeValue(); String urlValue = urlNode.getNodeValue(); if (FIRST_LINK.equals(typeValue)) { first = urlValue; } else if (PREVIOUS_LINK.equals(typeValue)) { previous = urlValue; } else if (SELF_LINK.equals(typeValue)) { self = urlValue; } else if (NEXT_LINK.equals(typeValue)) { next = urlValue; } else if (LAST_LINK.equals(typeValue)) { last = urlValue; } } } }
@Override public String getText() { final StringBuilder result = new StringBuilder(); 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) result.append(child.getNodeValue()); } return result.toString(); }
@Override @SuppressWarnings( { "cast", "unchecked" } ) protected Map<String, String> getAttributesAsMap( Element element ) { NamedNodeMap nodes = element.getAttributes(); int length = nodes.getLength(); if ( length == 0 ) { return (Map<String, String>) Collections.EMPTY_MAP; } Map<String, String> attributes = new HashMap<String, String>( length ); for ( int loop = 0; loop < length; loop++ ) { Node node = nodes.item( loop ); attributes.put( node.getNodeName(), node.getNodeValue() ); } return attributes; } }
public static String getXmlNodeValue(NodeList list, String tagName, int idx) { if (list == null || list.getLength() <= idx) { return null; } Node node = list.item(idx); if (node.getNodeType() != Node.ELEMENT_NODE) { return null; } String ret = ""; NodeList textNodes = node.getChildNodes(); for (int i = 0; i < textNodes.getLength(); i++) { Node n = textNodes.item(i); if (n.getNodeType() == Node.TEXT_NODE && n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0) { ret += n.getNodeValue(); } else if (n.getNodeType() == Node.CDATA_SECTION_NODE) { ret += n.getNodeValue(); } } return ret.length() == 0 ? null : ret.replaceAll("^\\s+", "").replaceAll("\\s+$", ""); }
private String getNodeValueByTagName( Element element, String tagName ) { Node node = getNodeByTagName( element, tagName ); if ( node != null && node.getFirstChild() != null ) { return node.getFirstChild().getNodeValue(); } else { return null; } } }
private String getNodeValueByTagName( Element element, String tagName ) { Node node = getNodeByTagName( element, tagName ); if ( node != null && node.getFirstChild() != null ) { return node.getFirstChild().getNodeValue(); } else { return null; } } }
Node attribute = node.getAttributes().getNamedItem(ATTR_BLOBSTORE_PARAM_NAME); if (attribute != null) { String paramName = attribute.getNodeValue(); if (paramName != null) { addHidden(paramName, value);
public IDatabaseConnection convertToObject( String xml ) { Document document = XMLParser.parse( xml ); Element element = document.getDocumentElement(); IDatabaseConnection databaseConnection = new DatabaseConnection(); databaseConnection.setDatabaseName( getNodeValueByTagName( element, DATABASE_NAME ) ); databaseConnection.setHostname( getNodeValueByTagName( element, HOSTNAME ) ); databaseConnection.setIndexTablespace( getNodeValueByTagName( element, INDEX_TABLESPACE ) ); databaseConnection.setDataTablespace( getNodeValueByTagName( element, DATA_TABLESPACE ) ); databaseConnection.setName( getNodeValueByTagName( element, NAME ) ); databaseConnection.setUsername( getNodeValueByTagName( element, USERNAME ) ); databaseConnection.setPassword( getNodeValueByTagName( element, PASSWORD ) ); databaseConnection.setDatabasePort( getNodeValueByTagName( element, DATABASE_PORT ) ); databaseConnection .setAccessType( DatabaseAccessType.getAccessTypeByName( getNodeValueByTagName( element, ACCESS_TYPE ) ) ); databaseConnection.setDatabaseType( (DatabaseType) databaseTypeHelper.getDatabaseTypeByShortName( getNodeValueByTagName( element, DATABASE_TYPE ) ) ); databaseConnection.setPassword( getNodeValueByTagName( element, PASSWORD ) ); databaseConnection.setInformixServername( getNodeValueByTagName( element, SERVER_NAME ) ); for ( Node node : getNodesByTagName( element, ATTRIBUTES ) ) { databaseConnection.getAttributes().put( node.getNodeName(), node.getNodeValue() ); } return databaseConnection; }