Save This Page
Home » apache-ant-1.8.1 » org.apache.tools » ant » types » [javadoc | source]
org.apache.tools.ant.types
public class: Commandline [javadoc | source]
java.lang.Object
   org.apache.tools.ant.types.Commandline

All Implemented Interfaces:
    Cloneable

Commandline objects help handling command lines specifying processes to execute. The class can be used to define a command line as nested elements or as a helper to define a command line by an application.

<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:
public static class  Commandline.Argument  Used for nested xml command line definitions. 
public class  Commandline.Marker  Class to keep track of the position of an Argument.

This class is there to support the srcfile and targetfile elements of <apply>.

 
Field Summary
protected static final  String DISCLAIMER     
Constructor:
 public Commandline() 
 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.
Method from org.apache.tools.ant.types.Commandline Summary:
addArguments,   addArgumentsToList,   addCommandToList,   clear,   clearArgs,   clone,   createArgument,   createArgument,   createMarker,   describeArguments,   describeArguments,   describeArguments,   describeArguments,   describeCommand,   describeCommand,   describeCommand,   getArguments,   getCommandline,   getExecutable,   iterator,   quoteArgument,   setExecutable,   size,   toString,   toString,   translateCommandline
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tools.ant.types.Commandline Detail:
 public  void addArguments(String[] line) 
    Append the arguments to the existing command.
 public  void addArgumentsToList(ListIterator list) 
    Append all the arguments to the tail of a supplied list.
 public  void addCommandToList(ListIterator list) 
    Add the entire command, including (optional) executable to a list.
 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.
 public Argument createArgument() 
    Create an argument object.

    Each commandline object has at most one instance of the argument class. This method calls this.createArgument(false).

 public Argument createArgument(boolean insertAtStart) 
    Create an argument object and add it to our list of args.

    Each commandline object has at most one instance of the argument class.

 public 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() 
    Return a String that describes the arguments suitable for verbose output before a call to Runtime.exec(String[]).
 public static String describeArguments(Commandline line) 
    Return a String that describes the arguments suitable for verbose output before a call to Runtime.exec(String[]).
 public static String describeArguments(String[] args) 
    Return a String that describes the arguments suitable for verbose output before a call to Runtime.exec(String[]).
 protected static String describeArguments(String[] args,
    int offset) 
    Return a String that describes the arguments suitable for verbose output before a call to Runtime.exec(String[]).
 public String describeCommand() 
    Return a String that describes the command and arguments suitable for verbose output before a call to Runtime.exec(String[]).
 public static String describeCommand(Commandline line) 
    Return a String that describes the command and arguments suitable for verbose output before a call to Runtime.exec(String[]).
 public static String describeCommand(String[] args) 
    Return a String that describes the command and arguments suitable for verbose output before a call to Runtime.exec(String[]).

    This method assumes that the first entry in the array is the executable to run.

 public String[] getArguments() 
    Returns all arguments defined by addLine, addValue or the argument object.
 public String[] getCommandline() 
    Return the executable and all defined arguments.
 public String getExecutable() 
    Get the executable.
 public Iterator iterator() 
    Get an iterator to the arguments list.
 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) 
    Set 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.
 public String toString() 
    Return the command line as a string.
 public static String toString(String[] line) 
    Quote the parts of the given array in way that makes them usable as command line arguments.
 public static String[] translateCommandline(String toProcess) 
    Crack a command line.