@Test public void testSplitCmd_cmdLineNoQuotes() { assertArrayEquals( CollectionsUtils.splitCmd("foo bar baaz qux"), new String[]{"foo", "bar", "baaz", "qux"} ); }
public static String[] splitCmd(String cmd) { String arg = ""; ArrayList<String> args = new ArrayList<String>(); ArrayList<Character> quotes = new ArrayList<Character>(); LOGGER.debug(String.format("Parsing cmd line: %s", cmd)); for (int i = 0; i < cmd.length(); i++){ char c = cmd.charAt(i); if (c == ' ' && quotes.size() == 0) { args.add(arg); arg = ""; continue; } else if (c == '\'' || c == '"') { if (quotes.size() > 0 && quotes.get(0) == c) { quotes.remove(0); } else { quotes.add(0, c); } } arg += c; } if (arg != "") { args.add(arg); } if (quotes.size() != 0) { throw new MinimesosException("Marathon cmd config quotes are not closed properly"); } return args.toArray(new String[args.size()]); }
CollectionsUtils { public static String[] splitCmd(String cmd) { String arg = ""; ArrayList<String> args = new ArrayList<String>(); ArrayList<Character> quotes = new ArrayList<Character>(); LOGGER.debug(String.format("Parsing cmd line: %s", cmd)); for (int i = 0; i < cmd.length(); i++){ char c = cmd.charAt(i); if (c == ' ' && quotes.size() == 0) { args.add(arg); arg = ""; continue; } else if (c == '\'' || c == '"') { if (quotes.size() > 0 && quotes.get(0) == c) { quotes.remove(0); } else { quotes.add(0, c); } } arg += c; } if (arg != "") { args.add(arg); } if (quotes.size() != 0) { throw new MinimesosException("Marathon cmd config quotes are not closed properly"); } return args.toArray(new String[args.size()]); } }
CollectionsUtils { public static String[] splitCmd(String cmd) { String arg = ""; ArrayList<String> args = new ArrayList<String>(); ArrayList<Character> quotes = new ArrayList<Character>(); LOGGER.debug(String.format("Parsing cmd line: %s", cmd)); for (int i = 0; i < cmd.length(); i++){ char c = cmd.charAt(i); if (c == ' ' && quotes.size() == 0) { args.add(arg); arg = ""; continue; } else if (c == '\'' || c == '"') { if (quotes.size() > 0 && quotes.get(0) == c) { quotes.remove(0); } else { quotes.add(0, c); } } arg += c; } if (arg != "") { args.add(arg); } if (quotes.size() != 0) { throw new MinimesosException("Marathon cmd config quotes are not closed properly"); } return args.toArray(new String[args.size()]); } private  CollectionsUtils(); }
CollectionsUtils { public static String[] splitCmd(String cmd) { String arg = ""; ArrayList<String> args = new ArrayList<String>(); ArrayList<Character> quotes = new ArrayList<Character>(); LOGGER.debug(String.format("Parsing cmd line: %s", cmd)); for (int i = 0; i < cmd.length(); i++){ char c = cmd.charAt(i); if (c == ' ' && quotes.size() == 0) { args.add(arg); arg = ""; continue; } else if (c == '\'' || c == '"') { if (quotes.size() > 0 && quotes.get(0) == c) { quotes.remove(0); } else { quotes.add(0, c); } } arg += c; } if (arg != "") { args.add(arg); } if (quotes.size() != 0) { throw new MinimesosException("Marathon cmd config quotes are not closed properly"); } return args.toArray(new String[args.size()]); } private  CollectionsUtils(); static List<T> typedList(List original, Class<T> clazz); static String[] splitCmd(String cmd); }
CollectionsUtils { public static String[] splitCmd(String cmd) { String arg = ""; ArrayList<String> args = new ArrayList<String>(); ArrayList<Character> quotes = new ArrayList<Character>(); LOGGER.debug(String.format("Parsing cmd line: %s", cmd)); for (int i = 0; i < cmd.length(); i++){ char c = cmd.charAt(i); if (c == ' ' && quotes.size() == 0) { args.add(arg); arg = ""; continue; } else if (c == '\'' || c == '"') { if (quotes.size() > 0 && quotes.get(0) == c) { quotes.remove(0); } else { quotes.add(0, c); } } arg += c; } if (arg != "") { args.add(arg); } if (quotes.size() != 0) { throw new MinimesosException("Marathon cmd config quotes are not closed properly"); } return args.toArray(new String[args.size()]); } private  CollectionsUtils(); static List<T> typedList(List original, Class<T> clazz); static String[] splitCmd(String cmd);  }