Example #1
0
 /** @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;
 }
Example #2
0
 @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()));
   }
 }
Example #3
0
 private void addArg(String arg, boolean quoted) {
   args.add(ExecArg.fromString(arg, quoted));
 }
Example #4
0
 /**
  * Visit with a visitor
  *
  * @param visitor visitor
  */
 public void visitWith(ExecArg.Visitor visitor) {
   for (ExecArg arg : getList()) {
     arg.accept(visitor);
   }
 }