Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.tools.ant.types.Commandline
public class Commandline
extends java.lang.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.
Nested Class Summary | |
static class |
|
class |
|
Field Summary | |
protected static String |
Constructor Summary | |
| |
|
Method Summary | |
void |
|
void |
|
void |
|
void |
|
void |
|
Object |
|
Commandline.Argument |
|
Commandline.Argument |
|
Commandline.Marker |
|
String |
|
static String |
|
protected static String |
|
static String |
|
String |
|
static String |
|
static String |
|
String[] |
|
String[] |
|
String |
|
static String |
|
void |
|
int |
|
String |
|
static String |
|
static String[] |
|
public Commandline()
Create an empty command line
public Commandline(String toProcess)
create a command line from a string
- Parameters:
toProcess
- the line: the first element becomes the executable, the rest the arguments
public void addArguments(String[] line)
append the arguments to the existing command
- Parameters:
line
- an array of arguments to append
public void addArgumentsToList(ListIterator list)
append all the arguments to the tail of a supplied list
- Parameters:
list
-
- Since:
- Ant 1.6
public void addCommandToList(ListIterator list)
add the entire command, including (optional) executable to a list
- Parameters:
list
-
- Since:
- Ant 1.6
public void clear()
Clear out the whole command line.
public void clearArgs()
Clear out the arguments but leave the executable in place for another operation.
public Object clone()
Generate a deep clone of the contained object.
- Returns:
- a clone of the contained object
public Commandline.Argument createArgument()
Creates an argument object. Each commandline object has at most one instance of the argument class. This method callsthis.createArgument(false)
.
- Returns:
- the argument object.
- See Also:
createArgument(boolean)
public Commandline.Argument createArgument(boolean insertAtStart)
Creates an argument object and adds it to our list of args. Each commandline object has at most one instance of the argument class.
- Parameters:
insertAtStart
- if true, the argument is inserted at the beginning of the list of args, otherwise it is appended.
public Commandline.Marker createMarker()
Return a marker. This marker can be used to locate a position on the commandline - to insert something for example - when all parameters have been set.
public String describeArguments()
Returns a String that describes the arguments suitable for verbose output before a call toRuntime.exec(String[])
- Since:
- Ant 1.5
public static String describeArguments(String[] args)
Returns a String that describes the arguments suitable for verbose output before a call toRuntime.exec(String[])
- Since:
- Ant 1.5
protected static String describeArguments(String[] args, int offset)
Returns a String that describes the arguments suitable for verbose output before a call toRuntime.exec(String[])
- Parameters:
offset
- ignore entries before this index
- Since:
- Ant 1.5
public static String describeArguments(Commandline line)
Returns a String that describes the arguments suitable for verbose output before a call toRuntime.exec(String[])
- Since:
- Ant 1.5
public String describeCommand()
Returns a String that describes the command and arguments suitable for verbose output before a call toRuntime.exec(String[])
- Since:
- Ant 1.5
public static String describeCommand(String[] args)
Returns a String that describes the command and arguments suitable for verbose output before a call toRuntime.exec(String[])
. This method assumes that the first entry in the array is the executable to run.
- Since:
- Ant 1.5
public static String describeCommand(Commandline line)
Returns a String that describes the command and arguments suitable for verbose output before a call toRuntime.exec(String[])
- Since:
- Ant 1.5
public String[] getArguments()
Returns all arguments defined byaddLine
,addValue
or the argument object.
public String[] getCommandline()
Returns the executable and all defined arguments.
public String getExecutable()
get the executable
- Returns:
- the program to run -null if not yet set
public static String quoteArgument(String argument)
Put quotes around the given String if necessary. If the argument doesn't include spaces or quotes, return it as is. If it contains double quotes, use single quotes - else surround the argument by double quotes.
public void setExecutable(String executable)
Sets the executable to run. All file separators in the string are converted to the platform specific value
public int size()
size operator. This actually creates the command line, so it is not a zero cost operation.
- Returns:
- number of elements in the command, including the executable
public String toString()
stringify operator returns the command line as a string
- Returns:
- the command line
public static String toString(String[] line)
Quotes the parts of the given array in way that makes them usable as command line arguments.
- Returns:
- empty string for null or no command, else every argument split by spaces and quoted by quoting rules
public static String[] translateCommandline(String toProcess)
crack a command line
- Parameters:
toProcess
- the command line to process
- Returns:
- the command line broken into strings. An empty or null toProcess parameter results in a zero sized array