public static String quote(String sentence){
  if (!sentence.contains("'")) {
    return addSingleQuotation(sentence);
  }
 else   if (sentence.contains("'") && !sentence.contains("\"")) {
    return addDoubleQuotation(sentence);
  }
 else {
    return changeToConcat(sentence);
  }
}

public static String quote ( String sentence ) { if ( ! sentence . contains ( "'" ) ) { return addSingleQuotation ( sentence ) ; } else if ( sentence . contains ( "'" ) && ! sentence . contains ( "\"" ) ) { return addDoubleQuotation ( sentence ) ; } else { return changeToConcat ( sentence ) ; } }
method perform intelligent escaping of quotes in xpath expressions , if necessary it constructs concat functions otherwise it simply add single or double quotes .
