protoj.lang.internal.ant
Class CommandTask

java.lang.Object
  extended by protoj.lang.internal.ant.CommandTask

public final class CommandTask
extends java.lang.Object

A convenience class for executing a system command. Use the constructors to specify the minimal and most widely anticipated configuration and the initXXX methods for the less common configuration options.

As far as possible this class is used to hide the differences in syntax between different operating systems.

Author:
Ashley Williams

Constructor Summary
CommandTask(java.io.File dir, java.lang.String executable, java.lang.String argLine)
          Accepts the details of the system command that should be executed.
 
Method Summary
 void execute()
           
 java.lang.String getResult()
           
 java.lang.String getStderr()
           
 java.lang.String getStdout()
           
 void initSpawn(boolean spawn)
           
 boolean isSuccess()
          It only makes sense to call this method from a forked but non-spawned vm.
 boolean isWindows()
          Helper for CommandTask(java.io.File, java.lang.String, java.lang.String) for determining if the current OS is windows.
 void writeOutput()
          All the output from the executed command seems to get buffered.command has exited, the buffered output can be written using this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandTask

public CommandTask(java.io.File dir,
                   java.lang.String executable,
                   java.lang.String argLine)
Accepts the details of the system command that should be executed. This constructor also takes care of ensuring that on windows, the executable is in fact cmd.exe.

Parameters:
dir - the directory in which the command should be executed
executable - the command to execute without any command line arguments
argLine - a space-delimited list of command-line arguments.
Method Detail

initSpawn

public void initSpawn(boolean spawn)

isWindows

public boolean isWindows()
Helper for CommandTask(java.io.File, java.lang.String, java.lang.String) for determining if the current OS is windows.

Returns:

execute

public void execute()

getStdout

public java.lang.String getStdout()

getStderr

public java.lang.String getStderr()

getResult

public java.lang.String getResult()

writeOutput

public void writeOutput()
All the output from the executed command seems to get buffered.command has exited, the buffered output can be written using this method.


isSuccess

public boolean isSuccess()
It only makes sense to call this method from a forked but non-spawned vm. Remember that a spawned vm will outlive the calling process.

Returns: