public String interpolate ( ) { getValues ( ) ; if ( definition == null ) { return "" ; } int variableStart = definition . indexOf ( "{" ) ; if ( variableStart < 0 ) { return definition ; } int index = 0 ; int variableEnd = 0 ; StringBuilder sb = new StringBuilder ( ) ; while ( variableStart >= 0 ) { sb . append ( definition . substring ( variableEnd , variableStart ) ) ; variableEnd = getIndexForEndOfVariable ( definition , variableStart ) + 1 ; variableStart = definition . indexOf ( "{" , variableEnd ) ; sb . append ( values . get ( index ++ ) . getValue ( ) ) ; } if ( variableEnd < definition . length ( ) ) { sb . append ( definition . substring ( variableEnd ) ) ; } return sb . toString ( ) ; }
This will strip off any { stuff substituting values accordingly