### Question:
ArgumentListBuilder implements Serializable { public ArgumentListBuilder toWindowsCommand() { StringBuilder quotedArgs = new StringBuilder(); boolean quoted, percent; for (String arg : args) { quoted = percent = false; for (int i = 0; i < arg.length(); i++) { char c = arg.charAt(i); if (!quoted && (c == ' ' || c == '*' || c == '?' || c == ',' || c == ';')) { quoted = startQuoting(quotedArgs, arg, i); } else if (c == '^' || c == '&' || c == '<' || c == '>' || c == '|') { if (!quoted) quoted = startQuoting(quotedArgs, arg, i); } else if (c == '"') { if (!quoted) quoted = startQuoting(quotedArgs, arg, i); quotedArgs.append('"'); } else if (percent && ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))) { if (!quoted) quoted = startQuoting(quotedArgs, arg, i); quotedArgs.append('"').append(c); c = '"'; } percent = (c == '%'); if (quoted) quotedArgs.append(c); } if (quoted) quotedArgs.append('"'); else quotedArgs.append(arg); quotedArgs.append(' '); } quotedArgs.append("&& exit %%ERRORLEVEL%%"); return new ArgumentListBuilder().add("cmd.exe", "/C").addQuoted(quotedArgs.toString()); } ArgumentListBuilder();  ArgumentListBuilder(String... args); ArgumentListBuilder add(Object a); ArgumentListBuilder add(Object a, boolean mask); ArgumentListBuilder add(File f); ArgumentListBuilder add(String a); ArgumentListBuilder add(String a, boolean mask); ArgumentListBuilder prepend(String... args); ArgumentListBuilder addQuoted(String a); ArgumentListBuilder addQuoted(String a, boolean mask); ArgumentListBuilder add(String... args); ArgumentListBuilder addTokenized(String s); ArgumentListBuilder addKeyValuePair(String prefix, String key, String value, boolean mask); ArgumentListBuilder addKeyValuePairs(String prefix, Map<String,String> props); ArgumentListBuilder addKeyValuePairs(String prefix, Map<String,String> props, Set<String> propsToMask); ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver vr); ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver vr, Set<String> propsToMask); @Override String toString(); String[] toCommandArray(); @Override ArgumentListBuilder clone(); void clear(); List<String> toList(); String toStringWithQuote(); ArgumentListBuilder toWindowsCommand(); boolean hasMaskedArguments(); boolean[] toMaskArray(); void addMasked(String string);  }### Answer:
@Test public void testToWindowsCommand() { ArgumentListBuilder builder = new ArgumentListBuilder( "ant.bat", "-Dfoo1=abc", "-Dfoo2=foo bar", "-Dfoo3=/u*r", "-Dfoo4=/us?", "-Dfoo10=bar,baz", "-Dfoo5=foo;bar^baz", "-Dfoo6=<xml>&here;</xml>", "-Dfoo7=foo|bar\"baz", "-Dfoo8=% %QED% %comspec% %-%(%.%", "-Dfoo9=%'''%%@%"); assertArrayEquals(new String[] { "cmd.exe", "/C", "\"ant.bat -Dfoo1=abc \"-Dfoo2=foo bar\"" + " \"-Dfoo3=/u*r\" \"-Dfoo4=/us?\" \"-Dfoo10=bar,baz\" \"-Dfoo5=foo;bar^baz\"" + " \"-Dfoo6=<xml>&here;</xml>\" \"-Dfoo7=foo|bar\"\"baz\"" + " \"-Dfoo8=% %\"Q\"ED% %\"c\"omspec% %-%(%.%\"" + " -Dfoo9=%'''%%@% && exit %%ERRORLEVEL%%\"" }, builder.toWindowsCommand().toCommandArray()); }