private String expandStringWithProperty ( String s ) throws Exception { // if expandProperties is false, don't expand property if ( ! expandProperties ) { return s ; } // if string doesn't contain property, returns original string if ( s == null || s . indexOf ( "${" ) == - 1 ) { return s ; } String toReturn = "" ; String [ ] split = s . split ( Pattern . quote ( "${" ) ) ; toReturn += split [ 0 ] ; for ( int i = 1 ; i < split . length ; i ++ ) { String part = split [ i ] ; // don't expand ${{...}} if ( part . startsWith ( "{" ) ) { toReturn += ( "${" + part ) ; continue ; } String [ ] splitPart = part . split ( "}" , 2 ) ; if ( splitPart . length < 2 ) { throw new Exception ( "ER001: Expand property without end } or inner property expansion!" ) ; } else { // add expanded property // ${/} = file.separator if ( splitPart [ 0 ] . equals ( "/" ) ) { toReturn += File . separator ; } else { toReturn += SecurityActions . getSystemProperty ( splitPart [ 0 ] ) ; } toReturn += splitPart [ 1 ] ; } } return toReturn ; }
Private method for expanding String which contains any property .