org.codehaus.plexus.util.cli.shell
Class Shell

java.lang.Object
  extended byorg.codehaus.plexus.util.cli.shell.Shell
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BourneShell, CmdShell, CommandShell

public class Shell
extends java.lang.Object
implements java.lang.Cloneable

Class that abstracts the Shell functionality, with subclases for shells that behave particularly, like

Since:
1.2
Version:
$Id: Shell.java 5960 2007-02-28 22:35:43Z jdcasey $
Author:
Carlos Sanchez

Constructor Summary
Shell()
           
 
Method Summary
 void addShellArg(java.lang.String arg)
           
 void clearArguments()
           
 java.lang.Object clone()
           
 java.util.List getCommandLine(java.lang.String executable, java.lang.String[] arguments)
          Get the command line for the provided executable and arguments in this shell
 java.lang.String getExecutable()
           
 java.util.List getOriginalCommandLine(java.lang.String executable, java.lang.String[] arguments)
           
 java.lang.String getOriginalExecutable()
           
 java.lang.String[] getShellArgs()
          Get the shell arguments
 java.util.List getShellArgsList()
           
 java.lang.String getShellCommand()
          Get the command to execute the shell
 java.util.List getShellCommandLine(java.lang.String[] arguments)
          Get the full command line to execute, including shell command, shell arguments, executable and executable arguments
 java.io.File getWorkingDirectory()
           
protected  boolean isDoubleQuotedArgumentEscaped()
           
protected  boolean isDoubleQuotedExecutableEscaped()
           
 boolean isQuotedArgumentsEnabled()
           
 boolean isQuotedExecutableEnabled()
           
protected  boolean isSingleQuotedArgumentEscaped()
           
protected  boolean isSingleQuotedExecutableEscaped()
           
protected  void setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped)
           
protected  void setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped)
           
 void setExecutable(java.lang.String executable)
          Sets the executable to run.
 void setQuotedArgumentsEnabled(boolean quotedArgumentsEnabled)
           
 void setQuotedExecutableEnabled(boolean quotedExecutableEnabled)
           
 void setShellArgs(java.lang.String[] shellArgs)
          Set the shell arguments when calling a command line (not the executable arguments) (eg.
 void setShellCommand(java.lang.String shellCommand)
          Set the command to execute the shell (eg.
protected  void setSingleQuotedArgumentEscaped(boolean singleQuotedArgumentEscaped)
           
protected  void setSingleQuotedExecutableEscaped(boolean singleQuotedExecutableEscaped)
           
 void setWorkingDirectory(java.io.File workingDir)
          Sets execution directory.
 void setWorkingDirectory(java.lang.String path)
          Sets execution directory.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Shell

public Shell()
Method Detail

setShellCommand

public void setShellCommand(java.lang.String shellCommand)
Set the command to execute the shell (eg. COMMAND.COM, /bin/bash,...)

Parameters:
shellCommand -

getShellCommand

public java.lang.String getShellCommand()
Get the command to execute the shell

Returns:

setShellArgs

public void setShellArgs(java.lang.String[] shellArgs)
Set the shell arguments when calling a command line (not the executable arguments) (eg. /X /C for CMD.EXE)

Parameters:
shellArgs -

getShellArgs

public java.lang.String[] getShellArgs()
Get the shell arguments

Returns:

getCommandLine

public java.util.List getCommandLine(java.lang.String executable,
                                     java.lang.String[] arguments)
Get the command line for the provided executable and arguments in this shell

Parameters:
executable - executable that the shell has to call
arguments - arguments for the executable, not the shell
Returns:
List with one String object with executable and arguments quoted as needed

isDoubleQuotedArgumentEscaped

protected boolean isDoubleQuotedArgumentEscaped()

isSingleQuotedArgumentEscaped

protected boolean isSingleQuotedArgumentEscaped()

isDoubleQuotedExecutableEscaped

protected boolean isDoubleQuotedExecutableEscaped()

isSingleQuotedExecutableEscaped

protected boolean isSingleQuotedExecutableEscaped()

getShellCommandLine

public java.util.List getShellCommandLine(java.lang.String[] arguments)
Get the full command line to execute, including shell command, shell arguments, executable and executable arguments

Parameters:
arguments - arguments for the executable, not the shell
Returns:
List of String objects, whose array version is suitable to be used as argument of Runtime.getRuntime().exec()

getShellArgsList

public java.util.List getShellArgsList()

addShellArg

public void addShellArg(java.lang.String arg)

setQuotedArgumentsEnabled

public void setQuotedArgumentsEnabled(boolean quotedArgumentsEnabled)

isQuotedArgumentsEnabled

public boolean isQuotedArgumentsEnabled()

setQuotedExecutableEnabled

public void setQuotedExecutableEnabled(boolean quotedExecutableEnabled)

isQuotedExecutableEnabled

public boolean isQuotedExecutableEnabled()

setExecutable

public void setExecutable(java.lang.String executable)
Sets the executable to run.


getExecutable

public java.lang.String getExecutable()

setWorkingDirectory

public void setWorkingDirectory(java.lang.String path)
Sets execution directory.


setWorkingDirectory

public void setWorkingDirectory(java.io.File workingDir)
Sets execution directory.


getWorkingDirectory

public java.io.File getWorkingDirectory()

clearArguments

public void clearArguments()

clone

public java.lang.Object clone()

getOriginalExecutable

public java.lang.String getOriginalExecutable()

getOriginalCommandLine

public java.util.List getOriginalCommandLine(java.lang.String executable,
                                             java.lang.String[] arguments)

setDoubleQuotedArgumentEscaped

protected void setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped)

setDoubleQuotedExecutableEscaped

protected void setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped)

setSingleQuotedArgumentEscaped

protected void setSingleQuotedArgumentEscaped(boolean singleQuotedArgumentEscaped)

setSingleQuotedExecutableEscaped

protected void setSingleQuotedExecutableEscaped(boolean singleQuotedExecutableEscaped)


Copyright © 2001-2007 Codehaus. All Rights Reserved.