stagesupport/src/main/java/com/streamsets/datacollector/util/EscapeUtil.java
private static String escapeQuotesAndBackSlash(String path, boolean isSingleQuoteEscape) {
    String quoteChar = isSingleQuoteEscape? "'" : "\"";
    StringBuilder sb = new StringBuilder(path.length() * 2).append(quoteChar);
    char[] chars = path.toCharArray();
    for (char c : chars) {
      if (c == '\\') {
        sb.append("\\\\");
      } else if (c == '"') {
        sb.append(isSingleQuoteEscape? "\\\"" : "\\\\\"");
      } else if (c == '\'') {
        sb.append(isSingleQuoteEscape? "\\\\\'" : "\\\'");
      } else {
        sb.append(c);
      }
    }
    return sb.append(quoteChar).toString();
  }
private static String escapeQuotesAndBackSlash(String path, boolean isSingleQuoteEscape) {
    String quoteChar = isSingleQuoteEscape? "'" : "\"";
    StringBuilder sb = new StringBuilder(path.length() * 2).append(quoteChar);
    char[] chars = path.toCharArray();
    for (char c : chars) {
      if (c == '\\') {
        sb.append("\\\\");
      } else if (c == '"') {
        sb.append(isSingleQuoteEscape? "\\\"" : "\\\\\"");
      } else if (c == '\'') {
        sb.append(isSingleQuoteEscape? "\\\\\'" : "\\\'");
      } else {
        sb.append(c);
      }
    }
    return sb.append(quoteChar).toString();
  }
This method escapes backslash, double quotes and single quotes (keeping replacement of ' to \\\\\'
as is so as to maintain backward compatibility any serialization/deserialization)