private void appendEvaluated(StringBuffer buffer,String s){
  boolean escape=false;
  boolean dollar=false;
  for (int i=0; i < s.length(); i++) {
    char c=s.charAt(i);
    if (c == '\\' && !escape) {
      escape=true;
    }
 else     if (c == '$' && !escape) {
      dollar=true;
    }
 else     if (c >= '0' && c <= '9' && dollar) {
      buffer.append(group(c - '0'));
      dollar=false;
    }
 else {
      buffer.append(c);
      dollar=false;
      escape=false;
    }
  }
  if (escape) {
    throw new ArrayIndexOutOfBoundsException(s.length());
  }
}

private void appendEvaluated ( StringBuffer buffer , String s ) { boolean escape = false ; boolean dollar = false ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == '\\' && ! escape ) { escape = true ; } else if ( c == '$' && ! escape ) { dollar = true ; } else if ( c >= '0' && c <= '9' && dollar ) { buffer . append ( group ( c - '0' ) ) ; dollar = false ; } else { buffer . append ( c ) ; dollar = false ; escape = false ; } } if ( escape ) { throw new ArrayIndexOutOfBoundsException ( s . length ( ) ) ; } }
internal helper method to append a given string to a given string buffer . if the string contains any references to groups , these are replaced by the corresponding group ' s contents .
