public String substitute(String source) throws Exception {
  int index=source.indexOf("${");
  while (index >= 0) {
    index+=2;
    int endIndex=source.indexOf('}');
    if (endIndex >= 0 && endIndex > index + 1) {
      String key=source.substring(index,endIndex);
      String replace=m_envVars.get(key);
      if (replace != null) {
        String toReplace="${" + key + "}";
        source=source.replace(toReplace,replace);
      }
 else {
        throw new Exception("[Environment] Variable " + key + " doesn't seem to be set.");
      }
    }
 else {
      break;
    }
    index=source.indexOf("${");
  }
  return source;
}

public String substitute ( String source ) throws Exception { int index = source . indexOf ( "${" ) ; while ( index >= 0 ) { index += 2 ; int endIndex = source . indexOf ( '}' ) ; if ( endIndex >= 0 && endIndex > index + 1 ) { String key = source . substring ( index , endIndex ) ; String replace = m_envVars . get ( key ) ; if ( replace != null ) { String toReplace = "${" + key + "}" ; source = source . replace ( toReplace , replace ) ; } else { throw new Exception ( "[Environment] Variable " + key + " doesn't seem to be set." ) ; } } else { break ; } index = source . indexOf ( "${" ) ; } return source ; }
substitute a variable names for their values in the given string .
