protected String getSubstitutionValue ( String input ) { if ( input == null || input . trim ( ) . equals ( "" ) ) return input ; while ( input . indexOf ( "${" ) != - 1 ) { int from = input . indexOf ( "${" ) ; int to = input . indexOf ( "}" ) ; int dv = input . indexOf ( ":" , from + 2 ) ; if ( dv != - 1 && dv > to ) { dv = - 1 ; } String systemProperty = "" ; String defaultValue = "" ; if ( dv == - 1 ) { String s = input . substring ( from + 2 , to ) ; if ( "/" . equals ( s ) ) { systemProperty = File . separator ; } else if ( ":" . equals ( s ) ) { systemProperty = File . pathSeparator ; } else { systemProperty = SecurityActions . getSystemProperty ( s ) ; } } else { systemProperty = SecurityActions . getSystemProperty ( input . substring ( from + 2 , dv ) ) ; defaultValue = input . substring ( dv + 1 , to ) ; } String prefix = "" ; String postfix = "" ; if ( from != 0 ) { prefix = input . substring ( 0 , from ) ; } if ( to + 1 < input . length ( ) - 1 ) { postfix = input . substring ( to + 1 ) ; } if ( systemProperty != null && ! systemProperty . trim ( ) . equals ( "" ) ) { input = prefix + systemProperty + postfix ; } else if ( ! defaultValue . trim ( ) . equals ( "" ) ) { input = prefix + defaultValue + postfix ; } else { input = prefix + postfix ; } } return input ; }
System property substitution