Package org.eclipse.cdt.core
Class CommandLauncher
- java.lang.Object
-
- org.eclipse.cdt.core.CommandLauncher
-
- All Implemented Interfaces:
ICommandLauncher
public class CommandLauncher extends java.lang.Object implements ICommandLauncher
- Restriction:
- This class is not intended to be subclassed by clients.
-
-
Field Summary
Fields Modifier and Type Field Description static intCOMMAND_CANCELEDprotected static longDELAYThe number of milliseconds to pause between polling.protected java.lang.String[]fCommandArgsprotected java.lang.StringfErrorMessageprotected java.lang.ProcessfProcessprotected booleanfShowCommandstatic intILLEGAL_COMMANDstatic intOK
-
Constructor Summary
Constructors Constructor Description CommandLauncher()Creates a new launcher Fills in stderr and stdout output to the given streams.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected java.lang.String[]constructCommandArray(java.lang.String command, java.lang.String[] commandArgs)Constructs a command array that will be passed to the processjava.lang.Processexecute(org.eclipse.core.runtime.IPath commandPath, java.lang.String[] args, java.lang.String[] env, org.eclipse.core.runtime.IPath changeToDirectory)Deprecated.java.lang.Processexecute(org.eclipse.core.runtime.IPath commandPath, java.lang.String[] args, java.lang.String[] env, org.eclipse.core.runtime.IPath workingDirectory, org.eclipse.core.runtime.IProgressMonitor monitor)Execute a commandjava.lang.String[]getCommandArgs()Returns an array of the command line arguments that were last used to execute a command.java.lang.StringgetCommandLine()Returns the constructed command line of the last command executed.protected java.lang.StringgetCommandLine(java.lang.String[] commandArgs)java.util.PropertiesgetEnvironment()Returns the set of environment variables in the context of which this launcher will execute commands.java.lang.StringgetErrorMessage()Returns a human readable error message corresponding to the last error encountered during command execution.org.eclipse.core.resources.IProjectgetProject()Gets the project this launcher is associated with.protected voidprintCommandLine(java.io.OutputStream os)voidsetErrorMessage(java.lang.String error)Sets the human readable error message corresponding to the last error encountered during command execution.voidsetProject(org.eclipse.core.resources.IProject project)Sets the project that this launcher is associated with, ornullif there is no such project.voidshowCommand(boolean show)Sets if the command should be printed out first before executing.intwaitAndRead(java.io.OutputStream out, java.io.OutputStream err)Deprecated.intwaitAndRead(java.io.OutputStream output, java.io.OutputStream err, org.eclipse.core.runtime.IProgressMonitor monitor)Reads output form the process to the streams.
-
-
-
Field Detail
-
COMMAND_CANCELED
public static final int COMMAND_CANCELED
- See Also:
- Constant Field Values
-
ILLEGAL_COMMAND
public static final int ILLEGAL_COMMAND
- See Also:
- Constant Field Values
-
OK
public static final int OK
- See Also:
- Constant Field Values
-
fProcess
protected java.lang.Process fProcess
-
fShowCommand
protected boolean fShowCommand
-
fCommandArgs
protected java.lang.String[] fCommandArgs
-
fErrorMessage
protected java.lang.String fErrorMessage
-
DELAY
protected static final long DELAY
The number of milliseconds to pause between polling.- See Also:
- Constant Field Values
-
-
Method Detail
-
showCommand
public void showCommand(boolean show)
Description copied from interface:ICommandLauncherSets if the command should be printed out first before executing.- Specified by:
showCommandin interfaceICommandLauncher
-
getErrorMessage
public java.lang.String getErrorMessage()
Description copied from interface:ICommandLauncherReturns a human readable error message corresponding to the last error encountered during command execution.- Specified by:
getErrorMessagein interfaceICommandLauncher- Returns:
- A String corresponding to the error, or
nullif there has been no error. The message could be multi-line, however it is NOT guaranteed that it ends with end of line.
-
setErrorMessage
public void setErrorMessage(java.lang.String error)
Description copied from interface:ICommandLauncherSets the human readable error message corresponding to the last error encountered during command execution. A subsequent call to getErrorMessage() will return this string.- Specified by:
setErrorMessagein interfaceICommandLauncher- Parameters:
error- A String corresponding to the error message, ornullif the error state is intended to be cleared.
-
getCommandArgs
public java.lang.String[] getCommandArgs()
Description copied from interface:ICommandLauncherReturns an array of the command line arguments that were last used to execute a command.- Specified by:
getCommandArgsin interfaceICommandLauncher- Returns:
- an array of type String[] corresponding to the arguments. The array can be empty, but should not be null.
-
getEnvironment
public java.util.Properties getEnvironment()
Description copied from interface:ICommandLauncherReturns the set of environment variables in the context of which this launcher will execute commands.- Specified by:
getEnvironmentin interfaceICommandLauncher- Returns:
- Properties
-
getCommandLine
public java.lang.String getCommandLine()
Description copied from interface:ICommandLauncherReturns the constructed command line of the last command executed.- Specified by:
getCommandLinein interfaceICommandLauncher- Returns:
- String
-
constructCommandArray
protected java.lang.String[] constructCommandArray(java.lang.String command, java.lang.String[] commandArgs)Constructs a command array that will be passed to the process
-
execute
@Deprecated public java.lang.Process execute(org.eclipse.core.runtime.IPath commandPath, java.lang.String[] args, java.lang.String[] env, org.eclipse.core.runtime.IPath changeToDirectory)Deprecated.- Since:
- 5.1
-
execute
public java.lang.Process execute(org.eclipse.core.runtime.IPath commandPath, java.lang.String[] args, java.lang.String[] env, org.eclipse.core.runtime.IPath workingDirectory, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreExceptionDescription copied from interface:ICommandLauncherExecute a command- Specified by:
executein interfaceICommandLauncherenv- The list of environment variables in variable=value format.- Throws:
org.eclipse.core.runtime.CoreException- if there is an error executing the command.- Since:
- 5.1
- See Also:
ICommandLauncher.execute(IPath, String[], String[], IPath, IProgressMonitor)
-
waitAndRead
@Deprecated public int waitAndRead(java.io.OutputStream out, java.io.OutputStream err)Deprecated.- Specified by:
waitAndReadin interfaceICommandLauncher
-
waitAndRead
public int waitAndRead(java.io.OutputStream output, java.io.OutputStream err, org.eclipse.core.runtime.IProgressMonitor monitor)Description copied from interface:ICommandLauncherReads output form the process to the streams. A progress monitor is polled to test if the cancel button has been pressed. Destroys the process if the monitor becomes canceled override to implement a different way to read the process inputs- Specified by:
waitAndReadin interfaceICommandLauncher
-
printCommandLine
protected void printCommandLine(java.io.OutputStream os)
-
getCommandLine
protected java.lang.String getCommandLine(java.lang.String[] commandArgs)
-
getProject
public org.eclipse.core.resources.IProject getProject()
Description copied from interface:ICommandLauncherGets the project this launcher is associated with.- Specified by:
getProjectin interfaceICommandLauncher- Returns:
- IProject, or
nullif there is no such project. - Since:
- 5.1
- See Also:
ICommandLauncher.getProject()
-
setProject
public void setProject(org.eclipse.core.resources.IProject project)
Description copied from interface:ICommandLauncherSets the project that this launcher is associated with, ornullif there is no such project.- Specified by:
setProjectin interfaceICommandLauncher- Since:
- 5.1
- See Also:
ICommandLauncher.setProject(org.eclipse.core.resources.IProject)
-
-