public static String[] splitValues(String value, String valueSeparator) { if (value != null && valueSeparator != null) { String[] split = split(value, valueSeparator); if (value.endsWith(valueSeparator) && PreprocessorUtils.isSyntaxValid(split[split.length - 1])) { String[] extendedSplit = new String[split.length + 1]; for (int i = 0; i < split.length; i++) { extendedSplit[i] = split[i]; } extendedSplit[split.length] = ""; return extendedSplit; } // Remove quotes from the beginning and end of split strings for (int i = 0; i < split.length; i++) { if ((split[i].endsWith("\"") && split[i].endsWith("\"")) || (split[i].startsWith("\'") && split[i].endsWith("\'"))) { split[i] = split[i].substring(1, split[i].length() - 1); } } return split; } else { return null; } }
public static String[] splitValues(String value, String valueSeparator) { if (value != null && valueSeparator != null) { String[] split = split(value, valueSeparator); if (value.endsWith(valueSeparator) && PreprocessorUtils.isSyntaxValid(split[split.length - 1])) { String[] extendedSplit = new String[split.length + 1]; for (int i = 0; i < split.length; i++) { extendedSplit[i] = split[i]; } extendedSplit[split.length] = ""; return extendedSplit; } // Remove quotes from the beginning and end of split strings for (int i = 0; i < split.length; i++) { if ((split[i].endsWith("\"") && split[i].endsWith("\"")) || (split[i].startsWith("\'") && split[i].endsWith("\'"))) { split[i] = split[i].substring(1, split[i].length() - 1); } } return split; } else { return null; } }
/** * Test for {@link ParserUtils#split(String, String)} */ public void testSplit() { String input = "something::{::}::nothing"; String[] split = ParserUtils.split(input, "::"); assertEquals("Size of the split", 3, split.length); assertEquals("First string", "something", split[0]); assertEquals("Second string", "{::}", split[1]); assertEquals("Third string", "nothing", split[2]); }