public class Commandline extends Object implements Cloneable
<someelement>
<acommandline executable="/executable/to/run">
<argument value="argument 1" />
<argument line="argument_1 argument_2 argument_3" />
<argument value="argument 4" />
</acommandline>
</someelement>
The element someelement
must provide a method
createAcommandline
which returns an instance of this class.
Modifier and Type | Class and Description |
---|---|
static class |
Commandline.Argument |
Constructor and Description |
---|
Commandline()
Create a new command line object.
|
Commandline(Shell shell)
Create a new command line object.
|
Commandline(String toProcess)
Create a new command line object.
|
Modifier and Type | Method and Description |
---|---|
void |
addArguments(String... line) |
void |
addEnvironment(String name,
String value)
Add an environment variable
|
void |
addSystemEnvironment()
Add system environment variables
|
void |
clearArgs()
Clear out the arguments but leave the executable in place for another operation.
|
Object |
clone() |
Arg |
createArg()
Creates an argument object.
|
Arg |
createArg(boolean insertAtStart)
Creates an argument object and adds it to our list of args.
|
Process |
execute()
Executes the command.
|
String[] |
getArguments()
Returns all arguments defined by
addLine ,
addValue or the argument object. |
String[] |
getCommandline()
Returns the executable and all defined arguments.
|
String[] |
getEnvironmentVariables()
Return the list of environment variables
|
String |
getExecutable() |
Shell |
getShell()
Get the shell to be used in this command line.
|
File |
getWorkingDirectory() |
void |
setExecutable(String executable)
Sets the executable to run.
|
void |
setWorkingDirectory(File workingDirectory)
Sets execution directory.
|
void |
setWorkingDirectory(String path)
Sets execution directory.
|
String |
toString() |
public Commandline(Shell shell)
public Commandline(String toProcess)
toProcess
- The command to processpublic Commandline()
public Arg createArg()
Each commandline object has at most one instance of the
argument class. This method calls
this.createArgument(false)
.
public Arg createArg(boolean insertAtStart)
Each commandline object has at most one instance of the argument class.
insertAtStart
- if true, the argument is inserted at the
beginning of the list of args, otherwise it is appended.public void setExecutable(String executable)
public String getExecutable()
public void addArguments(String... line)
public void addSystemEnvironment()
public String[] getEnvironmentVariables()
public String[] getCommandline()
public String[] getArguments()
addLine
,
addValue
or the argument object.public void setWorkingDirectory(String path)
public void setWorkingDirectory(File workingDirectory)
public File getWorkingDirectory()
public void clearArgs()
public Process execute() throws CommandLineException
CommandLineException
public Shell getShell()
Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.