public String replaceSomeTokens(String queryString,Map<String,String> replacements){
  Matcher matcher=tokenPattern.matcher(queryString);
  StringBuffer buf=new StringBuffer();
  while (matcher.find()) {
    String origToken=matcher.group(1);
    if (origToken != null) {
      String replacement=replacements.get(origToken);
      if (replacement == null) {
        replacement="${" + origToken + "}";
      }
      matcher.appendReplacement(buf,"");
      buf.append(replacement);
    }
  }
  matcher.appendTail(buf);
  return buf.toString();
}

public String replaceSomeTokens ( String queryString , Map < String , String > replacements ) { Matcher matcher = tokenPattern . matcher ( queryString ) ; StringBuffer buf = new StringBuffer ( ) ; while ( matcher . find ( ) ) { String origToken = matcher . group ( 1 ) ; if ( origToken != null ) { String replacement = replacements . get ( origToken ) ; if ( replacement == null ) { replacement = "${" + origToken + "}" ; } matcher . appendReplacement ( buf , "" ) ; buf . append ( replacement ) ; } } matcher . appendTail ( buf ) ; return buf . toString ( ) ; }
replaces some tokens in a query string with tokens of format $ { token - name } with the given replacements , which may again be tokens ( e . g . in another format ) or values . tokens that have no replacement defined stay in the original token format .
