public class Shell extends Object implements Cloneable
Class that abstracts the Shell functionality, with subclases for shells that behave particularly, like
command.comcmd.exe| Modifier and Type | Field and Description |
|---|---|
private char |
argQuoteDelimiter |
private String |
argumentEscapePattern |
private static char[] |
DEFAULT_QUOTING_TRIGGER_CHARS |
private boolean |
doubleQuotedArgumentEscaped |
private boolean |
doubleQuotedExecutableEscaped |
private String |
executable |
private char |
exeQuoteDelimiter |
private boolean |
quotedArgumentsEnabled |
private boolean |
quotedExecutableEnabled |
private List<String> |
shellArgs |
private String |
shellCommand |
private boolean |
singleQuotedArgumentEscaped |
private boolean |
singleQuotedExecutableEscaped |
private boolean |
unconditionallyQuote |
private String |
workingDir |
| Constructor and Description |
|---|
Shell() |
| Modifier and Type | Method and Description |
|---|---|
void |
addShellArg(String arg) |
void |
clearArguments() |
Object |
clone() |
protected String |
getArgumentEscapePattern() |
protected char |
getArgumentQuoteDelimiter() |
List<String> |
getCommandLine(String executable,
String[] arguments)
Get the command line for the provided executable and arguments in this shell
|
protected char[] |
getEscapeChars(boolean includeSingleQuote,
boolean includeDoubleQuote) |
String |
getExecutable() |
protected char |
getExecutableQuoteDelimiter() |
protected String |
getExecutionPreamble() |
List<String> |
getOriginalCommandLine(String executable,
String[] arguments) |
String |
getOriginalExecutable() |
protected char[] |
getQuotingTriggerChars() |
protected List<String> |
getRawCommandLine(String executable,
String[] arguments) |
String[] |
getShellArgs()
Get the shell arguments
|
List<String> |
getShellArgsList() |
String |
getShellCommand()
Get the command to execute the shell
|
List<String> |
getShellCommandLine(String[] arguments)
Get the full command line to execute, including shell command, shell arguments,
executable and executable arguments
|
File |
getWorkingDirectory() |
String |
getWorkingDirectoryAsString() |
protected boolean |
isDoubleQuotedArgumentEscaped() |
protected boolean |
isDoubleQuotedExecutableEscaped() |
boolean |
isQuotedArgumentsEnabled() |
boolean |
isQuotedExecutableEnabled() |
protected boolean |
isSingleQuotedArgumentEscaped() |
protected boolean |
isSingleQuotedExecutableEscaped() |
protected String |
quoteOneItem(String inputString,
boolean isExecutable) |
protected void |
setArgumentEscapePattern(String argumentEscapePattern) |
protected void |
setArgumentQuoteDelimiter(char argQuoteDelimiter) |
protected void |
setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped) |
protected void |
setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped) |
void |
setExecutable(String executable)
Sets the executable to run.
|
protected void |
setExecutableQuoteDelimiter(char exeQuoteDelimiter) |
void |
setQuotedArgumentsEnabled(boolean quotedArgumentsEnabled) |
void |
setQuotedExecutableEnabled(boolean quotedExecutableEnabled) |
void |
setShellArgs(String[] shellArgs)
Set the shell arguments when calling a command line (not the executable arguments)
(eg.
|
void |
setShellCommand(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(File workingDir)
Sets execution directory.
|
void |
setWorkingDirectory(String path)
Sets execution directory.
|
private static final char[] DEFAULT_QUOTING_TRIGGER_CHARS
private String shellCommand
private boolean quotedArgumentsEnabled
private boolean unconditionallyQuote
private String executable
private String workingDir
private boolean quotedExecutableEnabled
private boolean doubleQuotedArgumentEscaped
private boolean singleQuotedArgumentEscaped
private boolean doubleQuotedExecutableEscaped
private boolean singleQuotedExecutableEscaped
private char argQuoteDelimiter
private char exeQuoteDelimiter
private String argumentEscapePattern
public void setUnconditionalQuoting(boolean unconditionallyQuote)
unconditionallyQuote - public void setShellCommand(String shellCommand)
shellCommand - public String getShellCommand()
public void setShellArgs(String[] shellArgs)
shellArgs - public String[] getShellArgs()
public List<String> getCommandLine(String executable, String[] arguments)
executable - executable that the shell has to callarguments - arguments for the executable, not the shellprotected char[] getQuotingTriggerChars()
protected 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()
protected void setArgumentEscapePattern(String argumentEscapePattern)
protected String getArgumentEscapePattern()
public List<String> getShellCommandLine(String[] arguments)
arguments - arguments for the executable, not the shellpublic void addShellArg(String arg)
public void setQuotedArgumentsEnabled(boolean quotedArgumentsEnabled)
public boolean isQuotedArgumentsEnabled()
public void setQuotedExecutableEnabled(boolean quotedExecutableEnabled)
public boolean isQuotedExecutableEnabled()
public void setExecutable(String executable)
public String getExecutable()
public void setWorkingDirectory(String path)
public void setWorkingDirectory(File workingDir)
public File getWorkingDirectory()
public String getWorkingDirectoryAsString()
public void clearArguments()
public String getOriginalExecutable()
public List<String> getOriginalCommandLine(String executable, String[] arguments)
protected void setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped)
protected void setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped)
protected void setSingleQuotedArgumentEscaped(boolean singleQuotedArgumentEscaped)
protected void setSingleQuotedExecutableEscaped(boolean singleQuotedExecutableEscaped)
Copyright © 2016–2018 Simuline Organization (l2r). All rights reserved.