@Test public void testConvertToStringArray() throws Exception { assertNull(StringArrayConverter.convertToStringArray(null)); assertNull(StringArrayConverter.convertToStringArray("")); assertNull(StringArrayConverter.convertToStringArray(new NulToStringValue())); String[] array = StringArrayConverter.convertToStringArray("foo"); assertEquals(1, array.length); assertEquals("foo", array[0]); array = StringArrayConverter.convertToStringArray("foo,bar"); assertEquals(2, array.length); assertEquals("foo", array[0]); assertEquals("bar", array[1]); array = StringArrayConverter.convertToStringArray("foo,bar,baz"); assertEquals(3, array.length); assertEquals("foo", array[0]); assertEquals("bar", array[1]); assertEquals("baz", array[2]); }
public static String[] convertToStringArray(Object value) { if (value == null) { return null; } String text = value.toString(); if (text == null || text.isEmpty()) { return null; } StringTokenizer stok = new StringTokenizer(text, ","); final List<String> list = new ArrayList<String>(); while (stok.hasMoreTokens()) { list.add(stok.nextToken()); } String[] array = list.toArray(new String[list.size()]); return array; }
StringArrayConverter { public static String[] convertToStringArray(Object value) { if (value == null) { return null; } String text = value.toString(); if (text == null || text.isEmpty()) { return null; } StringTokenizer stok = new StringTokenizer(text, ","); final List<String> list = new ArrayList<String>(); while (stok.hasMoreTokens()) { list.add(stok.nextToken()); } String[] array = list.toArray(new String[list.size()]); return array; } }
StringArrayConverter { public static String[] convertToStringArray(Object value) { if (value == null) { return null; } String text = value.toString(); if (text == null || text.isEmpty()) { return null; } StringTokenizer stok = new StringTokenizer(text, ","); final List<String> list = new ArrayList<String>(); while (stok.hasMoreTokens()) { list.add(stok.nextToken()); } String[] array = list.toArray(new String[list.size()]); return array; }  }
StringArrayConverter { public static String[] convertToStringArray(Object value) { if (value == null) { return null; } String text = value.toString(); if (text == null || text.isEmpty()) { return null; } StringTokenizer stok = new StringTokenizer(text, ","); final List<String> list = new ArrayList<String>(); while (stok.hasMoreTokens()) { list.add(stok.nextToken()); } String[] array = list.toArray(new String[list.size()]); return array; }  static String[] convertToStringArray(Object value); static String convertToString(String[] value); }
StringArrayConverter { public static String[] convertToStringArray(Object value) { if (value == null) { return null; } String text = value.toString(); if (text == null || text.isEmpty()) { return null; } StringTokenizer stok = new StringTokenizer(text, ","); final List<String> list = new ArrayList<String>(); while (stok.hasMoreTokens()) { list.add(stok.nextToken()); } String[] array = list.toArray(new String[list.size()]); return array; }  static String[] convertToStringArray(Object value); static String convertToString(String[] value);  }