@Test public void testDecode() { assertEquals("aa\na", DumpUtil.decode("\"aa\na\"")); assertEquals("aa\"a", DumpUtil.decode("\"aa\"\"a\"")); assertEquals("", DumpUtil.decode("\"\"")); assertNull(DumpUtil.decode("")); assertNull(DumpUtil.decode(null)); }
public static String decode(String value) { if (value == null || value.equals("")) { return null; } if (DECODE_TARGET_PATTERN.matcher(value).matches()) { String s = value.substring(1, value.length() - 1); return s.replace(ESCAPED_QUOTE, QUOTE); } for (char c : value.toCharArray()) { if (c == '"' || c == ',' || c == '\n' || c == '\r') { throw new IllegalDumpValueRuntimeException(value); } } return value; }
DumpUtil { public static String decode(String value) { if (value == null || value.equals("")) { return null; } if (DECODE_TARGET_PATTERN.matcher(value).matches()) { String s = value.substring(1, value.length() - 1); return s.replace(ESCAPED_QUOTE, QUOTE); } for (char c : value.toCharArray()) { if (c == '"' || c == ',' || c == '\n' || c == '\r') { throw new IllegalDumpValueRuntimeException(value); } } return value; } }
DumpUtil { public static String decode(String value) { if (value == null || value.equals("")) { return null; } if (DECODE_TARGET_PATTERN.matcher(value).matches()) { String s = value.substring(1, value.length() - 1); return s.replace(ESCAPED_QUOTE, QUOTE); } for (char c : value.toCharArray()) { if (c == '"' || c == ',' || c == '\n' || c == '\r') { throw new IllegalDumpValueRuntimeException(value); } } return value; } protected  DumpUtil(); }
DumpUtil { public static String decode(String value) { if (value == null || value.equals("")) { return null; } if (DECODE_TARGET_PATTERN.matcher(value).matches()) { String s = value.substring(1, value.length() - 1); return s.replace(ESCAPED_QUOTE, QUOTE); } for (char c : value.toCharArray()) { if (c == '"' || c == ',' || c == '\n' || c == '\r') { throw new IllegalDumpValueRuntimeException(value); } } return value; } protected  DumpUtil(); static String encode(String value); static String decode(String value); static String quote(String value); }
DumpUtil { public static String decode(String value) { if (value == null || value.equals("")) { return null; } if (DECODE_TARGET_PATTERN.matcher(value).matches()) { String s = value.substring(1, value.length() - 1); return s.replace(ESCAPED_QUOTE, QUOTE); } for (char c : value.toCharArray()) { if (c == '"' || c == ',' || c == '\n' || c == '\r') { throw new IllegalDumpValueRuntimeException(value); } } return value; } protected  DumpUtil(); static String encode(String value); static String decode(String value); static String quote(String value);  }