PGtokenizer { public int tokenize(String string, char delim) { tokens.clear(); int nest = 0; int p; int s; boolean skipChar = false; boolean nestedDoubleQuote = false; char c = (char)0; for (p = 0, s = 0; p < string.length(); p++) { c = string.charAt(p); if (c == '(' || c == '[' || c == '<' || (!nestedDoubleQuote && !skipChar && c == '"')) { nest++; if (c == '"') { nestedDoubleQuote = true; skipChar = true; } } if (c == ')' || c == ']' || c == '>' || (nestedDoubleQuote && !skipChar && c == '"')) { nest--; if (c == '"') { nestedDoubleQuote = false; } } skipChar = c == '\\'; if (nest == 0 && c == delim) { tokens.add(string.substring(s, p)); s = p + 1; } } if (s < string.length()) { tokens.add(string.substring(s)); } if ( s == string.length() && c == delim) { tokens.add(""); } return tokens.size(); } @SuppressWarnings("method.invocation.invalid")  PGtokenizer(String string, char delim); int tokenize(String string, char delim); int getSize(); String getToken(int n); PGtokenizer tokenizeToken(int n, char delim); static String remove(String s, String l, String t); void remove(String l, String t); static String removePara(String s); void removePara(); static String removeBox(String s); void removeBox(); static String removeAngle(String s); void removeAngle(); static String removeCurlyBrace(String s); void removeCurlyBrace();  }
@Test void tokenize() { PGtokenizer pGtokenizer = new PGtokenizer("1,2EC1830300027,1,,",','); assertEquals(5,pGtokenizer.getSize()); }