public static String substituteValueInExpression ( String expression , String newValue ) { ExpressionTemplate t = new ExpressionTemplate ( expression ) ; if ( newValue != null && ( getExpressionKey ( t . getTemplate ( ) ) == null || ( t . isComplex ( ) && ! newValue . equals ( t . getValue ( ) ) ) ) ) return newValue ; String result = t . getSubstitution ( ) ; if ( ! t . isComplex ( ) && newValue != null ) { int start = result . lastIndexOf ( ":$" ) ; start = result . indexOf ( ":" , start + 1 ) ; int end = result . indexOf ( "}" , start + 1 ) ; if ( start < 0 || end < 0 || start == result . lastIndexOf ( "${:}" ) + 2 ) return result ; result = result . substring ( 0 , start + 1 ) + newValue + result . substring ( end ) ; } return result ; }
Substitutes a default value in expression by a new one