@Test public void testEscapeEscapedByChar() { String text = "Some text with some \\ escape char \\\\ to change"; String escaped = escaper.escapeForStdIn(text); assertEquals("Some text with some " + ESCAPED_BY_CHAR + ESCAPED_BY_CHAR + " escape char " + ESCAPED_BY_CHAR + ESCAPED_BY_CHAR + ESCAPED_BY_CHAR + ESCAPED_BY_CHAR + " to change", escaped); logger.info("FROM:"); logger.info(text); logger.info("TO:"); logger.info(escaped); }
public String escapeForStdIn(String text) { if (text == null) { return null; } int firstEscapableChar = findFirstEscapableChar(text); if (firstEscapableChar == -1) { return text; } StringBuilder sb = new StringBuilder(text.substring(0, firstEscapableChar)); int textLength = text.length(); for (int i = firstEscapableChar; i < textLength; i++) { char textCharacter = text.charAt(i); if (isEscapable(textCharacter)) { sb.append(PgCopyConstants.ESCAPE_CHAR); sb.append(textCharacter); } else { sb.append(textCharacter); } } return sb.toString(); }
PgCopyEscaper { public String escapeForStdIn(String text) { if (text == null) { return null; } int firstEscapableChar = findFirstEscapableChar(text); if (firstEscapableChar == -1) { return text; } StringBuilder sb = new StringBuilder(text.substring(0, firstEscapableChar)); int textLength = text.length(); for (int i = firstEscapableChar; i < textLength; i++) { char textCharacter = text.charAt(i); if (isEscapable(textCharacter)) { sb.append(PgCopyConstants.ESCAPE_CHAR); sb.append(textCharacter); } else { sb.append(textCharacter); } } return sb.toString(); } }
PgCopyEscaper { public String escapeForStdIn(String text) { if (text == null) { return null; } int firstEscapableChar = findFirstEscapableChar(text); if (firstEscapableChar == -1) { return text; } StringBuilder sb = new StringBuilder(text.substring(0, firstEscapableChar)); int textLength = text.length(); for (int i = firstEscapableChar; i < textLength; i++) { char textCharacter = text.charAt(i); if (isEscapable(textCharacter)) { sb.append(PgCopyConstants.ESCAPE_CHAR); sb.append(textCharacter); } else { sb.append(textCharacter); } } return sb.toString(); }  }
PgCopyEscaper { public String escapeForStdIn(String text) { if (text == null) { return null; } int firstEscapableChar = findFirstEscapableChar(text); if (firstEscapableChar == -1) { return text; } StringBuilder sb = new StringBuilder(text.substring(0, firstEscapableChar)); int textLength = text.length(); for (int i = firstEscapableChar; i < textLength; i++) { char textCharacter = text.charAt(i); if (isEscapable(textCharacter)) { sb.append(PgCopyConstants.ESCAPE_CHAR); sb.append(textCharacter); } else { sb.append(textCharacter); } } return sb.toString(); }  String escapeForStdIn(String text); }
PgCopyEscaper { public String escapeForStdIn(String text) { if (text == null) { return null; } int firstEscapableChar = findFirstEscapableChar(text); if (firstEscapableChar == -1) { return text; } StringBuilder sb = new StringBuilder(text.substring(0, firstEscapableChar)); int textLength = text.length(); for (int i = firstEscapableChar; i < textLength; i++) { char textCharacter = text.charAt(i); if (isEscapable(textCharacter)) { sb.append(PgCopyConstants.ESCAPE_CHAR); sb.append(textCharacter); } else { sb.append(textCharacter); } } return sb.toString(); }  String escapeForStdIn(String text);  }