@Test public void testEscapeFieldTermination() { String text = "1234\tvalue\t5678\t"; String escaped = escaper.escapeForLoadFile(text); assertEquals("1234" + ESCAPED_BY_CHAR + FIELD_TERMINATED_CHAR + "value" + ESCAPED_BY_CHAR + FIELD_TERMINATED_CHAR + "5678" + ESCAPED_BY_CHAR + FIELD_TERMINATED_CHAR, escaped); logger.info("FROM:"); logger.info(text); logger.info("TO:"); logger.info(escaped); }
public String escapeForLoadFile(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(ESCAPED_BY_CHAR); sb.append(textCharacter); } else { sb.append(textCharacter); } } return sb.toString(); }
LoadDataEscaper { public String escapeForLoadFile(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(ESCAPED_BY_CHAR); sb.append(textCharacter); } else { sb.append(textCharacter); } } return sb.toString(); } }
LoadDataEscaper { public String escapeForLoadFile(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(ESCAPED_BY_CHAR); sb.append(textCharacter); } else { sb.append(textCharacter); } } return sb.toString(); }  }
LoadDataEscaper { public String escapeForLoadFile(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(ESCAPED_BY_CHAR); sb.append(textCharacter); } else { sb.append(textCharacter); } } return sb.toString(); }  String escapeForLoadFile(String text); }
LoadDataEscaper { public String escapeForLoadFile(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(ESCAPED_BY_CHAR); sb.append(textCharacter); } else { sb.append(textCharacter); } } return sb.toString(); }  String escapeForLoadFile(String text);  }