public class CommandLine extends Object
Constructor and Description |
---|
CommandLine(CommandLine other)
Copy constructor.
|
CommandLine(File executable)
Create a command line without any arguments.
|
CommandLine(String executable)
Create a command line without any arguments.
|
Modifier and Type | Method and Description |
---|---|
CommandLine |
addArgument(String argument)
Add a single argument.
|
CommandLine |
addArgument(String argument,
boolean handleQuoting)
Add a single argument.
|
CommandLine |
addArguments(String addArguments)
Add multiple arguments.
|
CommandLine |
addArguments(String[] addArguments)
Add multiple arguments.
|
CommandLine |
addArguments(String[] addArguments,
boolean handleQuoting)
Add multiple arguments.
|
CommandLine |
addArguments(String addArguments,
boolean handleQuoting)
Add multiple arguments.
|
String[] |
getArguments()
Returns the expanded and quoted command line arguments.
|
String |
getExecutable()
Returns the executable.
|
Map<String,?> |
getSubstitutionMap() |
boolean |
isFile()
Was a file being used to set the executable?
|
static CommandLine |
parse(String line)
Create a command line from a string.
|
static CommandLine |
parse(String line,
Map<String,?> substitutionMap)
Create a command line from a string.
|
void |
setSubstitutionMap(Map<String,?> substitutionMap)
Set the substitutionMap to expand variables in the
command line.
|
String |
toString()
Stringify operator returns the command line as a string.
|
String[] |
toStrings()
Returns the command line as an array of strings.
|
public CommandLine(String executable)
executable
- the executablepublic CommandLine(File executable)
executable
- the executable filepublic CommandLine(CommandLine other)
other
- the instance to copypublic static CommandLine parse(String line)
line
- the first element becomes the executable, the rest the argumentsIllegalArgumentException
- If line is null or all whitespacepublic static CommandLine parse(String line, Map<String,?> substitutionMap)
line
- the first element becomes the executable, the rest the argumentssubstitutionMap
- the name/value pairs used for substitutionIllegalArgumentException
- If line is null or all whitespacepublic String getExecutable()
public boolean isFile()
public CommandLine addArguments(String[] addArguments)
addArguments
- An array of argumentspublic CommandLine addArguments(String[] addArguments, boolean handleQuoting)
addArguments
- An array of argumentshandleQuoting
- Add the argument with/without handling quotingpublic CommandLine addArguments(String addArguments)
addArguments
- An string containing multiple arguments.public CommandLine addArguments(String addArguments, boolean handleQuoting)
addArguments
- An string containing multiple arguments.handleQuoting
- Add the argument with/without handling quotingpublic CommandLine addArgument(String argument)
argument
- The argument to addIllegalArgumentException
- If argument contains both single and double quotespublic CommandLine addArgument(String argument, boolean handleQuoting)
argument
- The argument to addhandleQuoting
- Add the argument with/without handling quotingpublic String[] getArguments()
public Map<String,?> getSubstitutionMap()
public void setSubstitutionMap(Map<String,?> substitutionMap)
substitutionMap
- the mappublic String[] toStrings()
Copyright © 2014 The Apache Software Foundation. All rights reserved.