ExpressionTokenizer { protected List<String> splitUnquoted(String str, String sub) { List<String> part = new ArrayList<>(); int pos = indexOfUnquoted(str, sub); if(pos >= 0) { String s = str.substring(0, pos); part.add(s); pos += sub.length(); if(pos<str.length()) { String str2 = str.substring(pos); List<String> part2 = splitUnquoted(str2, sub); part.addAll(part2); } } else { part.add(str); } return part; } ExpressionTokenizer(String arg); List<String> getCommandStrings();  }
@Test public void testSplitUnquoted1() { String str = "ls -ltr | grep -v hello"; ExpressionTokenizer t = new ExpressionTokenizer(str); assertEquals(Arrays.asList("ls -ltr ", " grep -v hello"), t.splitUnquoted(str, "|")); }
@Test public void testSplitUnquoted2() { String str = "ls -ltr \"|\" | grep -v hello"; ExpressionTokenizer t = new ExpressionTokenizer(str); assertEquals(Arrays.asList("ls -ltr \"|\" ", " grep -v hello"), t.splitUnquoted(str, "|")); }