Package org.eclipse.cdt.core
Class CommandLauncher
- java.lang.Object
-
- org.eclipse.cdt.core.CommandLauncher
-
- All Implemented Interfaces:
ICommandLauncher
public class CommandLauncher extends Object implements ICommandLauncher
- Restriction:
- This class is not intended to be subclassed by clients.
-
-
Field Summary
Fields Modifier and Type Field Description static int
COMMAND_CANCELED
protected static long
DELAY
The number of milliseconds to pause between polling.protected String[]
fCommandArgs
protected String
fErrorMessage
protected Process
fProcess
protected boolean
fShowCommand
static int
ILLEGAL_COMMAND
static int
OK
-
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 String[]
constructCommandArray(String command, String[] commandArgs)
Constructs a command array that will be passed to the processProcess
execute(org.eclipse.core.runtime.IPath commandPath, String[] args, String[] env, org.eclipse.core.runtime.IPath changeToDirectory)
Deprecated.Process
execute(org.eclipse.core.runtime.IPath commandPath, String[] args, String[] env, org.eclipse.core.runtime.IPath workingDirectory, org.eclipse.core.runtime.IProgressMonitor monitor)
Execute a commandString[]
getCommandArgs()
Returns an array of the command line arguments that were last used to execute a command.String
getCommandLine()
Returns the constructed command line of the last command executed.protected String
getCommandLine(String[] commandArgs)
Properties
getEnvironment()
Returns the set of environment variables in the context of which this launcher will execute commands.String
getErrorMessage()
Returns a human readable error message corresponding to the last error encountered during command execution.org.eclipse.core.resources.IProject
getProject()
Gets the project this launcher is associated with.protected void
printCommandLine(OutputStream os)
void
setErrorMessage(String error)
Sets the human readable error message corresponding to the last error encountered during command execution.void
setProject(org.eclipse.core.resources.IProject project)
Sets the project that this launcher is associated with, ornull
if there is no such project.void
showCommand(boolean show)
Sets if the command should be printed out first before executing.int
waitAndRead(OutputStream out, OutputStream err)
Deprecated.int
waitAndRead(OutputStream output, 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 Process fProcess
-
fShowCommand
protected boolean fShowCommand
-
fCommandArgs
protected String[] fCommandArgs
-
fErrorMessage
protected 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:ICommandLauncher
Sets if the command should be printed out first before executing.- Specified by:
showCommand
in interfaceICommandLauncher
-
getErrorMessage
public String getErrorMessage()
Description copied from interface:ICommandLauncher
Returns a human readable error message corresponding to the last error encountered during command execution.- Specified by:
getErrorMessage
in interfaceICommandLauncher
- Returns:
- A String corresponding to the error, or
null
if 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(String error)
Description copied from interface:ICommandLauncher
Sets 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:
setErrorMessage
in interfaceICommandLauncher
- Parameters:
error
- A String corresponding to the error message, ornull
if the error state is intended to be cleared.
-
getCommandArgs
public String[] getCommandArgs()
Description copied from interface:ICommandLauncher
Returns an array of the command line arguments that were last used to execute a command.- Specified by:
getCommandArgs
in interfaceICommandLauncher
- Returns:
- an array of type String[] corresponding to the arguments. The array can be empty, but should not be null.
-
getEnvironment
public Properties getEnvironment()
Description copied from interface:ICommandLauncher
Returns the set of environment variables in the context of which this launcher will execute commands.- Specified by:
getEnvironment
in interfaceICommandLauncher
- Returns:
- Properties
-
getCommandLine
public String getCommandLine()
Description copied from interface:ICommandLauncher
Returns the constructed command line of the last command executed.- Specified by:
getCommandLine
in interfaceICommandLauncher
- Returns:
- String
-
constructCommandArray
protected String[] constructCommandArray(String command, String[] commandArgs)
Constructs a command array that will be passed to the process
-
execute
@Deprecated public Process execute(org.eclipse.core.runtime.IPath commandPath, String[] args, String[] env, org.eclipse.core.runtime.IPath changeToDirectory)
Deprecated.- Since:
- 5.1
-
execute
public Process execute(org.eclipse.core.runtime.IPath commandPath, String[] args, String[] env, org.eclipse.core.runtime.IPath workingDirectory, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
Description copied from interface:ICommandLauncher
Execute a command- Specified by:
execute
in interfaceICommandLauncher
env
- 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(OutputStream out, OutputStream err)
Deprecated.- Specified by:
waitAndRead
in interfaceICommandLauncher
-
waitAndRead
public int waitAndRead(OutputStream output, OutputStream err, org.eclipse.core.runtime.IProgressMonitor monitor)
Description copied from interface:ICommandLauncher
Reads 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:
waitAndRead
in interfaceICommandLauncher
-
printCommandLine
protected void printCommandLine(OutputStream os)
-
getProject
public org.eclipse.core.resources.IProject getProject()
Description copied from interface:ICommandLauncher
Gets the project this launcher is associated with.- Specified by:
getProject
in interfaceICommandLauncher
- Returns:
- IProject, or
null
if 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:ICommandLauncher
Sets the project that this launcher is associated with, ornull
if there is no such project.- Specified by:
setProject
in interfaceICommandLauncher
- Since:
- 5.1
- See Also:
ICommandLauncher.setProject(org.eclipse.core.resources.IProject)
-
-