protected static String parseFoundKey ( String value ) { // System.out.println("Start Value: " + value); String regex = "#\\{([A-Za-z]+\\.)?([^\\}]+)\\}" ; Pattern p = Pattern . compile ( regex ) ; Matcher matcher = p . matcher ( value ) ; while ( matcher . find ( ) ) { // System.out.print("Start index: " + matcher.start()); // System.out.print(" End index: " + matcher.end() + " \n"); String keyMatched = matcher . group ( ) . trim ( ) ; // System.out.println("Key: " + keyMatched); String trimmedKey = StringUtils . substring ( keyMatched , 2 , keyMatched . length ( ) - 1 ) ; // System.out.println("Trimmed Key: " + trimmedKey); String replacedValue = fetchString ( trimmedKey ) ; // System.out.println("Replaced Value: " + replacedValue); if ( StringUtils . contains ( replacedValue , "#{" ) ) { replacedValue = parseFoundKey ( replacedValue ) ; } value = StringUtils . replace ( value , keyMatched , replacedValue ) ; // System.out.println("New Value: " + value); } return value ; }
resolves an embedded key