@Test public void testParseEmpty() { List<String> ret = ListFormat.parse("[]"); assertNotNull(ret); assertEquals(0, ret.size()); }
public static List<String> parse(String input) { List<String> ret = new ArrayList<>(); if (input.length() > 0) { input = input.substring(1, input.length() - 1); StringTokenizer st = new StringTokenizer(input, ","); while (st.hasMoreTokens()) { String s = st.nextToken().trim(); if (s.charAt(0) == '"') ret.add(s.substring(1, s.length() - 1)); else { ret.add(s); } } } return ret; }
ListFormat { public static List<String> parse(String input) { List<String> ret = new ArrayList<>(); if (input.length() > 0) { input = input.substring(1, input.length() - 1); StringTokenizer st = new StringTokenizer(input, ","); while (st.hasMoreTokens()) { String s = st.nextToken().trim(); if (s.charAt(0) == '"') ret.add(s.substring(1, s.length() - 1)); else { ret.add(s); } } } return ret; } }
ListFormat { public static List<String> parse(String input) { List<String> ret = new ArrayList<>(); if (input.length() > 0) { input = input.substring(1, input.length() - 1); StringTokenizer st = new StringTokenizer(input, ","); while (st.hasMoreTokens()) { String s = st.nextToken().trim(); if (s.charAt(0) == '"') ret.add(s.substring(1, s.length() - 1)); else { ret.add(s); } } } return ret; }  }
ListFormat { public static List<String> parse(String input) { List<String> ret = new ArrayList<>(); if (input.length() > 0) { input = input.substring(1, input.length() - 1); StringTokenizer st = new StringTokenizer(input, ","); while (st.hasMoreTokens()) { String s = st.nextToken().trim(); if (s.charAt(0) == '"') ret.add(s.substring(1, s.length() - 1)); else { ret.add(s); } } } return ret; }  static String format(Object[] data); static String format(List<?> data); static List<String> parse(String input); }
ListFormat { public static List<String> parse(String input) { List<String> ret = new ArrayList<>(); if (input.length() > 0) { input = input.substring(1, input.length() - 1); StringTokenizer st = new StringTokenizer(input, ","); while (st.hasMoreTokens()) { String s = st.nextToken().trim(); if (s.charAt(0) == '"') ret.add(s.substring(1, s.length() - 1)); else { ret.add(s); } } } return ret; }  static String format(Object[] data); static String format(List<?> data); static List<String> parse(String input);  }