private static String resolve ( final String value , final Resolver resolver ) { StringBuilder builder = new StringBuilder ( ) ; int position = 0 ; String prefix = resolver . getPrefix ( ) + "{" ; String postfix = "}" ; for ( int index = value . indexOf ( prefix ) ; index != - 1 ; index = value . indexOf ( prefix , position ) ) { builder . append ( value , position , index ) ; int start = index + 2 ; int end = value . indexOf ( postfix , start ) ; if ( end == - 1 ) { InternalLogger . log ( Level . WARN , "Closing curly bracket is missing for '" + value + "'" ) ; return value ; } String name = value . substring ( start , end ) ; if ( name . length ( ) == 0 ) { InternalLogger . log ( Level . WARN , "Empty variable names cannot be resolved: " + value ) ; return value ; } String data = resolver . resolve ( name ) ; if ( data == null ) { InternalLogger . log ( Level . WARN , "'" + name + "' could not be found in " + resolver . getName ( ) ) ; return value ; } else { builder . append ( data ) ; } position = end + 1 ; } builder . append ( value , position , value . length ( ) ) ; return builder . toString ( ) ; }
Resolves placeholders with passed resolver .