/** @return Flatten the list of arguments into a list */ public ArrayList<String> asFlatStringList() { final ArrayList<String> strings = new ArrayList<String>(); for (ExecArg arg : getList()) { arg.accept( new ExecArg.Visitor() { @Override public void visit(ExecArg arg) { if (arg.isList()) { for (ExecArg execArg : arg.getList()) { execArg.accept(this); } } else { strings.add(arg.getString()); } } }); } return strings; }
@Override public void visit(ExecArg arg) { if (arg.isList()) { CommandVisitor commandVisitor = new CommandVisitor(new ArrayList<String>(), quote, expand); for (ExecArg execArg : arg.getList()) { execArg.accept(commandVisitor); } String join = joinAndQuote(commandVisitor.getCommandList(), arg.isQuoted() ? quote : null); getCommandList().add(join); } else { getCommandList().add(convertAndQuote(arg.getString(), arg.isQuoted())); } }
private void addArg(String arg, boolean quoted) { args.add(ExecArg.fromString(arg, quoted)); }
/** * Visit with a visitor * * @param visitor visitor */ public void visitWith(ExecArg.Visitor visitor) { for (ExecArg arg : getList()) { arg.accept(visitor); } }