org.objectweb.common
Class Cmd

java.lang.Object
  extended by org.objectweb.common.Cmd

public class Cmd
extends java.lang.Object

This class allows to run a command in sub-process.

Author:
Helene Joanin : Initial developer, Christophe Ney : Fix to handle arguments containing white spaces., Nozomi Matsumura : GenIC i18n problem. GenIC invoke javac and javac's output has non asc-ii characters, javac's output did not show collectly., Guillaume Tulloup : Invoke directly the com.sun.tools.javac.Main.compile() method to work around a limitation on Windows. (See bug #100587), Helene Joanin : Invoke directly the com.sun.tools.rmic.Main.compile() method to work around a limitation on Windows.

Constructor Summary
Cmd(java.lang.String cmd)
          Construtor method of Cmd class.
Cmd(java.lang.String cmd, boolean invoke)
          Construtor method of Cmd class.
Cmd(java.lang.String cmd, java.lang.String[] env, boolean invoke)
          Construtor method of Cmd class.
 
Method Summary
 void addArgument(java.lang.String arg)
          Add a new argument to the command.
 void addArguments(java.util.List args)
          Add a new argument to the command.
 java.util.Iterator getCommandLine()
           
 boolean run()
          Execute the command.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cmd

public Cmd(java.lang.String cmd,
           boolean invoke)
Construtor method of Cmd class.

Parameters:
cmd - command
invoke - try to invoke directly the method of the java class of the command

Cmd

public Cmd(java.lang.String cmd)
Construtor method of Cmd class. Equivalent to Cmd(cmd, false).

Parameters:
cmd - command

Cmd

public Cmd(java.lang.String cmd,
           java.lang.String[] env,
           boolean invoke)
Construtor method of Cmd class.

Parameters:
cmd - command
env - environment of the command
invoke - invoke the compile method of the class instead of execute the command
Method Detail

addArgument

public void addArgument(java.lang.String arg)
Add a new argument to the command.

Parameters:
arg - argument added to the tail of the command argument list

addArguments

public void addArguments(java.util.List args)
Add a new argument to the command.

Parameters:
args - argument added to the tail of the command argument list

run

public boolean run()
Execute the command. (In case of the exit value of the command is not 0, the output and error streams of the command is traced.)

Returns:
false if the command cannot be executed, or if its exit value is not 0.

getCommandLine

public java.util.Iterator getCommandLine()
Returns:
iterator over the command line

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the string representation of the object for UI purpose