@Test public void testExample5ToString() { String test = "'\\n'"; String expectedString = new String(new char[] { 0x0A }); String toString = toText(test); assertEquals(toString, expectedString); }
public static String toText(String string) { boolean escaped = false; StringBuilder sb = new StringBuilder(); int i; string = removeQuotes(string); for (i = 0; i < string.length(); ++i) { char c = string.charAt(i); if (escaped) { escaped = false; if (REPLACEMENTS.containsKey(c)) { c = REPLACEMENTS.get(c); } sb.append(c); } else { switch(c) { case ESCAPE_CHARACTER: escaped = true; break; default: sb.append(c); break; } } } return sb.toString(); }
SqoopIDFUtils { public static String toText(String string) { boolean escaped = false; StringBuilder sb = new StringBuilder(); int i; string = removeQuotes(string); for (i = 0; i < string.length(); ++i) { char c = string.charAt(i); if (escaped) { escaped = false; if (REPLACEMENTS.containsKey(c)) { c = REPLACEMENTS.get(c); } sb.append(c); } else { switch(c) { case ESCAPE_CHARACTER: escaped = true; break; default: sb.append(c); break; } } } return sb.toString(); } }
SqoopIDFUtils { public static String toText(String string) { boolean escaped = false; StringBuilder sb = new StringBuilder(); int i; string = removeQuotes(string); for (i = 0; i < string.length(); ++i) { char c = string.charAt(i); if (escaped) { escaped = false; if (REPLACEMENTS.containsKey(c)) { c = REPLACEMENTS.get(c); } sb.append(c); } else { switch(c) { case ESCAPE_CHARACTER: escaped = true; break; default: sb.append(c); break; } } } return sb.toString(); }  }
SqoopIDFUtils { public static String toText(String string) { boolean escaped = false; StringBuilder sb = new StringBuilder(); int i; string = removeQuotes(string); for (i = 0; i < string.length(); ++i) { char c = string.charAt(i); if (escaped) { escaped = false; if (REPLACEMENTS.containsKey(c)) { c = REPLACEMENTS.get(c); } sb.append(c); } else { switch(c) { case ESCAPE_CHARACTER: escaped = true; break; default: sb.append(c); break; } } } return sb.toString(); }  static boolean isInteger(Column column); static String toCSVFixedPoint(Object obj, Column column); static Object toFixedPoint(String csvString, Column column); static String toCSVFloatingPoint(Object obj, Column column); static Object toFloatingPoint(String csvString, Column column); static String toCSVDecimal(Object obj); static Object toDecimal(String csvString, Column column); static String toCSVBit(Object obj); static Object toBit(String csvString); static String toCSVDate(Object obj); static String toCSVTime(Object obj, Column col); static Object toDate(String csvString, Column column); static Object toTime(String csvString, Column column); static String toCSVLocalDateTime(Object obj, Column col); static String toCSVDateTime(Object obj, Column col); static Object toDateTime(String csvString, Column column); static Long toDateTimeInMillis(String csvString, Column column); @SuppressWarnings("unchecked") static String toCSVMap(Map<Object, Object> map, Column column); static Map<Object, Object> toMap(String csvString); static List<Object> toList(JSONArray array); @SuppressWarnings("unchecked") static Map<Object, Object> toMap(JSONObject object); @SuppressWarnings("unchecked") static String toCSVList(Object[] list, Column column); static Object[] toList(String csvString); @SuppressWarnings("unchecked") static JSONArray toJSONArray(Object[] objectArray); static List<Object> toList(Object[] objectArray); @SuppressWarnings("unchecked") static Object[] toObjectArray(List<Object> list); static String toCSVString(String string); static String toText(String string); static String toCSVByteArray(Object obj); static byte[] toByteArray(String csvString); static String encloseWithQuotes(String string); static String removeQuotes(String string); static boolean isColumnListType(Column listType); static boolean isColumnStringType(Column stringType); @SuppressWarnings("unchecked") static String toCSV(Object[] objectArray, Schema schema); static String[] parseCSVString(String csvText); static Object[] fromCSV(String csvText, Schema schema); }
SqoopIDFUtils { public static String toText(String string) { boolean escaped = false; StringBuilder sb = new StringBuilder(); int i; string = removeQuotes(string); for (i = 0; i < string.length(); ++i) { char c = string.charAt(i); if (escaped) { escaped = false; if (REPLACEMENTS.containsKey(c)) { c = REPLACEMENTS.get(c); } sb.append(c); } else { switch(c) { case ESCAPE_CHARACTER: escaped = true; break; default: sb.append(c); break; } } } return sb.toString(); }  static boolean isInteger(Column column); static String toCSVFixedPoint(Object obj, Column column); static Object toFixedPoint(String csvString, Column column); static String toCSVFloatingPoint(Object obj, Column column); static Object toFloatingPoint(String csvString, Column column); static String toCSVDecimal(Object obj); static Object toDecimal(String csvString, Column column); static String toCSVBit(Object obj); static Object toBit(String csvString); static String toCSVDate(Object obj); static String toCSVTime(Object obj, Column col); static Object toDate(String csvString, Column column); static Object toTime(String csvString, Column column); static String toCSVLocalDateTime(Object obj, Column col); static String toCSVDateTime(Object obj, Column col); static Object toDateTime(String csvString, Column column); static Long toDateTimeInMillis(String csvString, Column column); @SuppressWarnings("unchecked") static String toCSVMap(Map<Object, Object> map, Column column); static Map<Object, Object> toMap(String csvString); static List<Object> toList(JSONArray array); @SuppressWarnings("unchecked") static Map<Object, Object> toMap(JSONObject object); @SuppressWarnings("unchecked") static String toCSVList(Object[] list, Column column); static Object[] toList(String csvString); @SuppressWarnings("unchecked") static JSONArray toJSONArray(Object[] objectArray); static List<Object> toList(Object[] objectArray); @SuppressWarnings("unchecked") static Object[] toObjectArray(List<Object> list); static String toCSVString(String string); static String toText(String string); static String toCSVByteArray(Object obj); static byte[] toByteArray(String csvString); static String encloseWithQuotes(String string); static String removeQuotes(String string); static boolean isColumnListType(Column listType); static boolean isColumnStringType(Column stringType); @SuppressWarnings("unchecked") static String toCSV(Object[] objectArray, Schema schema); static String[] parseCSVString(String csvText); static Object[] fromCSV(String csvText, Schema schema); static final String NULL_VALUE; static final String BYTE_FIELD_CHARSET; static final Map<Character, String> ORIGINALS; static final char CSV_SEPARATOR_CHARACTER; static final char ESCAPE_CHARACTER; static final char QUOTE_CHARACTER; static final DateTimeFormatter dtfWithFractionAndTimeZone; static final DateTimeFormatter dtfWithNoFractionAndTimeZone; static final DateTimeFormatter dtfWithFractionNoTimeZone; static final DateTimeFormatter dtfWithNoFractionWithTimeZone; static final DateTimeFormatter df; static final DateTimeFormatter tfWithFraction; static final DateTimeFormatter tfWithNoFraction; static final String[] TRUE_BIT_VALUES; static final Set<String> TRUE_BIT_SET; static final String[] FALSE_BIT_VALUES; static final Set<String> FALSE_BIT_SET; }