org.codehaus.plexus.util.cli.shell

Class Shell

public class Shell extends Object implements Cloneable

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

Since: 1.2

Version: $Id: Shell.java 8010 2009-01-07 12:59:50Z vsiveton $

Author: Carlos Sanchez

Method Summary
voidaddShellArg(String arg)
voidclearArguments()
Objectclone()
protected chargetArgumentQuoteDelimiter()
ListgetCommandLine(String executable, String[] arguments)
Get the command line for the provided executable and arguments in this shell
protected char[]getEscapeChars(boolean includeSingleQuote, boolean includeDoubleQuote)
StringgetExecutable()
protected chargetExecutableQuoteDelimiter()
protected StringgetExecutionPreamble()
ListgetOriginalCommandLine(String executable, String[] arguments)
StringgetOriginalExecutable()
protected char[]getQuotingTriggerChars()
protected ListgetRawCommandLine(String executable, String[] arguments)
String[]getShellArgs()
Get the shell arguments
ListgetShellArgsList()
StringgetShellCommand()
Get the command to execute the shell
ListgetShellCommandLine(String[] arguments)
Get the full command line to execute, including shell command, shell arguments, executable and executable arguments
FilegetWorkingDirectory()
StringgetWorkingDirectoryAsString()
protected booleanisDoubleQuotedArgumentEscaped()
protected booleanisDoubleQuotedExecutableEscaped()
booleanisQuotedArgumentsEnabled()
booleanisQuotedExecutableEnabled()
protected booleanisSingleQuotedArgumentEscaped()
protected booleanisSingleQuotedExecutableEscaped()
protected voidsetArgumentQuoteDelimiter(char argQuoteDelimiter)
protected voidsetDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped)
protected voidsetDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped)
voidsetExecutable(String executable)
Sets the executable to run.
protected voidsetExecutableQuoteDelimiter(char exeQuoteDelimiter)
voidsetQuotedArgumentsEnabled(boolean quotedArgumentsEnabled)
voidsetQuotedExecutableEnabled(boolean quotedExecutableEnabled)
voidsetShellArgs(String[] shellArgs)
Set the shell arguments when calling a command line (not the executable arguments) (eg.
voidsetShellCommand(String shellCommand)
Set the command to execute the shell (eg.
protected voidsetSingleQuotedArgumentEscaped(boolean singleQuotedArgumentEscaped)
protected voidsetSingleQuotedExecutableEscaped(boolean singleQuotedExecutableEscaped)
voidsetWorkingDirectory(String path)
Sets execution directory.
voidsetWorkingDirectory(File workingDir)
Sets execution directory.

Method Detail

addShellArg

public void addShellArg(String arg)

clearArguments

public void clearArguments()

clone

public Object clone()

getArgumentQuoteDelimiter

protected char getArgumentQuoteDelimiter()

getCommandLine

public List getCommandLine(String executable, 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

getEscapeChars

protected char[] getEscapeChars(boolean includeSingleQuote, boolean includeDoubleQuote)

getExecutable

public String getExecutable()

getExecutableQuoteDelimiter

protected char getExecutableQuoteDelimiter()

getExecutionPreamble

protected String getExecutionPreamble()

getOriginalCommandLine

public List getOriginalCommandLine(String executable, String[] arguments)

getOriginalExecutable

public String getOriginalExecutable()

getQuotingTriggerChars

protected char[] getQuotingTriggerChars()

getRawCommandLine

protected List getRawCommandLine(String executable, String[] arguments)

getShellArgs

public String[] getShellArgs()
Get the shell arguments

Returns:

getShellArgsList

public List getShellArgsList()

getShellCommand

public String getShellCommand()
Get the command to execute the shell

Returns:

getShellCommandLine

public List getShellCommandLine(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()

getWorkingDirectory

public File getWorkingDirectory()

getWorkingDirectoryAsString

public String getWorkingDirectoryAsString()

isDoubleQuotedArgumentEscaped

protected boolean isDoubleQuotedArgumentEscaped()

isDoubleQuotedExecutableEscaped

protected boolean isDoubleQuotedExecutableEscaped()

isQuotedArgumentsEnabled

public boolean isQuotedArgumentsEnabled()

isQuotedExecutableEnabled

public boolean isQuotedExecutableEnabled()

isSingleQuotedArgumentEscaped

protected boolean isSingleQuotedArgumentEscaped()

isSingleQuotedExecutableEscaped

protected boolean isSingleQuotedExecutableEscaped()

setArgumentQuoteDelimiter

protected void setArgumentQuoteDelimiter(char argQuoteDelimiter)

setDoubleQuotedArgumentEscaped

protected void setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped)

setDoubleQuotedExecutableEscaped

protected void setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped)

setExecutable

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

setExecutableQuoteDelimiter

protected void setExecutableQuoteDelimiter(char exeQuoteDelimiter)

setQuotedArgumentsEnabled

public void setQuotedArgumentsEnabled(boolean quotedArgumentsEnabled)

setQuotedExecutableEnabled

public void setQuotedExecutableEnabled(boolean quotedExecutableEnabled)

setShellArgs

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

Parameters: shellArgs

setShellCommand

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

Parameters: shellCommand

setSingleQuotedArgumentEscaped

protected void setSingleQuotedArgumentEscaped(boolean singleQuotedArgumentEscaped)

setSingleQuotedExecutableEscaped

protected void setSingleQuotedExecutableEscaped(boolean singleQuotedExecutableEscaped)

setWorkingDirectory

public void setWorkingDirectory(String path)
Sets execution directory.

setWorkingDirectory

public void setWorkingDirectory(File workingDir)
Sets execution directory.
Copyright © 2001-2010 Codehaus. All Rights Reserved.