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
command.com
cmd.exe
Constructor and Description |
---|
Shell() |
Modifier and Type | Method and Description |
---|---|
void |
addShellArg(java.lang.String arg) |
void |
clearArguments() |
java.lang.Object |
clone() |
protected char |
getArgumentQuoteDelimiter() |
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
|
protected char[] |
getEscapeChars(boolean includeSingleQuote,
boolean includeDoubleQuote) |
java.lang.String |
getExecutable() |
protected char |
getExecutableQuoteDelimiter() |
protected java.lang.String |
getExecutionPreamble() |
java.util.List |
getOriginalCommandLine(java.lang.String executable,
java.lang.String[] arguments) |
java.lang.String |
getOriginalExecutable() |
protected char[] |
getQuotingTriggerChars() |
protected java.util.List |
getRawCommandLine(java.lang.String executable,
java.lang.String[] arguments) |
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() |
java.lang.String |
getWorkingDirectoryAsString() |
protected boolean |
isDoubleQuotedArgumentEscaped() |
protected boolean |
isDoubleQuotedExecutableEscaped() |
boolean |
isQuotedArgumentsEnabled() |
boolean |
isQuotedExecutableEnabled() |
protected boolean |
isSingleQuotedArgumentEscaped() |
protected boolean |
isSingleQuotedExecutableEscaped() |
protected java.lang.String |
quoteOneItem(java.lang.String inputString,
boolean isExecutable) |
protected void |
setArgumentQuoteDelimiter(char argQuoteDelimiter) |
protected void |
setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped) |
protected void |
setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped) |
void |
setExecutable(java.lang.String executable)
Sets the executable to run.
|
protected void |
setExecutableQuoteDelimiter(char exeQuoteDelimiter) |
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 |
setUnconditionalQuoting(boolean unconditionallyQuote)
Toggle unconditional quoting
|
void |
setWorkingDirectory(java.io.File workingDir)
Sets execution directory.
|
void |
setWorkingDirectory(java.lang.String path)
Sets execution directory.
|
public void setUnconditionalQuoting(boolean unconditionallyQuote)
unconditionallyQuote
- public void setShellCommand(java.lang.String shellCommand)
shellCommand
- public java.lang.String getShellCommand()
public void setShellArgs(java.lang.String[] shellArgs)
shellArgs
- protected java.lang.String quoteOneItem(java.lang.String inputString, boolean isExecutable)
public java.lang.String[] getShellArgs()
public java.util.List getCommandLine(java.lang.String executable, java.lang.String[] arguments)
executable
- executable that the shell has to callarguments
- arguments for the executable, not the shellprotected java.util.List getRawCommandLine(java.lang.String executable, java.lang.String[] arguments)
protected char[] getQuotingTriggerChars()
protected java.lang.String getExecutionPreamble()
protected char[] getEscapeChars(boolean includeSingleQuote, boolean includeDoubleQuote)
protected boolean isDoubleQuotedArgumentEscaped()
protected boolean isSingleQuotedArgumentEscaped()
protected boolean isDoubleQuotedExecutableEscaped()
protected boolean isSingleQuotedExecutableEscaped()
protected void setArgumentQuoteDelimiter(char argQuoteDelimiter)
protected char getArgumentQuoteDelimiter()
protected void setExecutableQuoteDelimiter(char exeQuoteDelimiter)
protected char getExecutableQuoteDelimiter()
public java.util.List getShellCommandLine(java.lang.String[] arguments)
arguments
- arguments for the executable, not the shellpublic java.util.List getShellArgsList()
public void addShellArg(java.lang.String arg)
public void setQuotedArgumentsEnabled(boolean quotedArgumentsEnabled)
public boolean isQuotedArgumentsEnabled()
public void setQuotedExecutableEnabled(boolean quotedExecutableEnabled)
public boolean isQuotedExecutableEnabled()
public void setExecutable(java.lang.String executable)
public java.lang.String getExecutable()
public void setWorkingDirectory(java.lang.String path)
public void setWorkingDirectory(java.io.File workingDir)
public java.io.File getWorkingDirectory()
public java.lang.String getWorkingDirectoryAsString()
public void clearArguments()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String getOriginalExecutable()
public java.util.List getOriginalCommandLine(java.lang.String executable, java.lang.String[] arguments)
protected void setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped)
protected void setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped)
protected void setSingleQuotedArgumentEscaped(boolean singleQuotedArgumentEscaped)
protected void setSingleQuotedExecutableEscaped(boolean singleQuotedExecutableEscaped)