org.sonar.api.utils.command
Class Command

java.lang.Object
  extended by org.sonar.api.utils.command.Command

public class Command
extends Object

Since:
2.7

Method Summary
 Command addArgument(String arg)
           
 Command addArguments(List<String> args)
           
 Command addArguments(String[] args)
           
static Command create(String executable)
          Create a command line without any arguments
 List<String> getArguments()
           
 File getDirectory()
           
 Map<String,String> getEnvironmentVariables()
          Environment variables that are propagated during command execution.
 String getExecutable()
           
 boolean isNewShell()
          true if a new shell should be used to execute the command.
 Command setDirectory(File d)
          Sets working directory.
 Command setEnvironmentVariable(String name, String value)
           
 Command setNewShell(boolean b)
          Set to true if a new shell should be used to execute the command.
 String toCommandLine()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static Command create(String executable)
Create a command line without any arguments

Parameters:
executable -

getExecutable

public String getExecutable()

getArguments

public List<String> getArguments()

addArgument

public Command addArgument(String arg)

addArguments

public Command addArguments(List<String> args)

addArguments

public Command addArguments(String[] args)

getDirectory

public File getDirectory()

setDirectory

public Command setDirectory(File d)
Sets working directory.


setEnvironmentVariable

public Command setEnvironmentVariable(String name,
                                      String value)
Since:
3.2
See Also:
getEnvironmentVariables()

getEnvironmentVariables

public Map<String,String> getEnvironmentVariables()
Environment variables that are propagated during command execution. The initial value is a copy of the environment of the current process.

Returns:
a non-null and immutable map of variables
Since:
3.2

isNewShell

public boolean isNewShell()
true if a new shell should be used to execute the command. The default behavior is to not use a new shell.

Since:
3.3

setNewShell

public Command setNewShell(boolean b)
Set to true if a new shell should be used to execute the command. This is useful when the executed command is a script with no execution rights (+x on unix). On windows, the command will be executed with cmd /C executable. On other platforms, the command will be executed with sh executable.

Since:
3.3

toCommandLine

public String toCommandLine()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009–2015 SonarSource. All rights reserved.