MCPcopy Create free account
hub / github.com/apache/calcite / printJavaString

Method printJavaString

core/src/main/java/org/apache/calcite/util/Util.java:507–529  ·  view source on GitHub ↗

Prints a string, enclosing in double quotes (") and escaping if necessary. For example, printDoubleQuoted(w,"x\"y",false) prints "x\"y" . The appendable where the value is printed must not incur I/O operations. This method is not meant to be used for writing the values t

(
      Appendable appendable,
      @Nullable String s,
      boolean nullMeansNull)

Source from the content-addressed store, hash-verified

505 * @throws IllegalStateException if the print to the specified appendable fails due to I/O
506 */
507 public static void printJavaString(
508 Appendable appendable,
509 @Nullable String s,
510 boolean nullMeansNull) {
511 try {
512 if (s == null) {
513 if (nullMeansNull) {
514 appendable.append("null");
515 }
516 } else {
517 String s1 = replace(s, "\\", "\\\\");
518 String s2 = replace(s1, "\"", "\\\"");
519 String s3 = replace(s2, "\n\r", "\\n");
520 String s4 = replace(s3, "\n", "\\n");
521 String s5 = replace(s4, "\r", "\\r");
522 appendable.append('"');
523 appendable.append(s5);
524 appendable.append('"');
525 }
526 } catch (IOException ioe) {
527 throw new IllegalStateException("The specified appendable should not incur I/O.", ioe);
528 }
529 }
530
531 public static void println(
532 PrintWriter pw,

Callers 4

assertPrintEqualsMethod · 0.95
dumpGraphvizMethod · 0.95
appendAsJavaMethod · 0.95
printMethod · 0.95

Calls 2

replaceMethod · 0.95
appendMethod · 0.65

Tested by 1

assertPrintEqualsMethod · 0.76