Here you can find the source of resolveLeafNodeValue(Node node)
private static void resolveLeafNodeValue(Node node)
//package com.java2s; /*/*from w w w .java 2s. c o m*/ * Copyright (c) 2016, WSO2 Inc. (http://wso2.com) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import java.io.File; public class Main { private static void resolveLeafNodeValue(Node node) { if (node != null) { Element element = (Element) node; NodeList childNodeList = element.getChildNodes(); for (int j = 0; j < childNodeList.getLength(); j++) { Node chileNode = childNodeList.item(j); if (!chileNode.hasChildNodes()) { String nodeValue = resolveSystemProperty(chileNode.getTextContent()); childNodeList.item(j).setTextContent(nodeValue); } else { resolveLeafNodeValue(chileNode); } } } } private static String resolveSystemProperty(String text) { int indexOfStartingChars = -1; int indexOfClosingBrace; // The following condition deals with properties. // Properties are specified as ${system.property}, // and are assumed to be System properties while (indexOfStartingChars < text.indexOf("${") && (indexOfStartingChars = text.indexOf("${")) != -1 && (indexOfClosingBrace = text.indexOf('}')) != -1) { // Is a // property // used? String sysProp = text.substring(indexOfStartingChars + 2, indexOfClosingBrace); String propValue = System.getProperty(sysProp); if (propValue != null) { text = text.substring(0, indexOfStartingChars) + propValue + text.substring(indexOfClosingBrace + 1); } if (sysProp.equals("carbon.home") && propValue != null && propValue.equals(".")) { text = new File(".").getAbsolutePath() + File.separator + text; } } return text; } }