public abstract class ConsoleTool
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.List<java.lang.String> |
binDirectories
contains possible absolute path directory.
contains possible sub-directories from tool-home where the tool stays For example, bin, tools, platform-tools etc. |
protected Console |
console |
Constructor and Description |
---|
ConsoleTool() |
Modifier and Type | Method and Description |
---|---|
Process2 |
batch(java.io.File workingDirectory,
java.util.List<java.lang.String> batchAndArgs) |
Process2 |
batch(java.io.File workingDirectory,
java.lang.String... batchAndArgs) |
Process2 |
batch(java.lang.String tool,
java.lang.String... args)
Execute a batch file.
|
Process2 |
exec(java.io.File workingDirectory,
java.util.List<java.lang.String> binaryAndArgs) |
Process2 |
exec(java.io.File workingDirectory,
java.lang.String... binaryAndArgs) |
Process2 |
exec(java.lang.String tool,
java.util.List<java.lang.String> args) |
Process2 |
exec(java.lang.String tool,
java.lang.String... args)
Execute an executable.
|
java.util.List<java.lang.String> |
getBinDirectories() |
java.lang.String |
getLastCommand() |
static java.lang.String |
getOsFamilyName() |
java.lang.String |
getToolHome()
This method will firstly try to return the field
toolHome If it is null, it will try to get the toolHome from properties getToolHomeProperties() If still not found, it will try to get the toolHome from environments getToolHomeEnvs() If still not found, it will throw out IllegalStateException. If the toolHome if found, it will be set to field toolHome . |
protected java.util.List<java.lang.String> |
getToolHomeEnvs()
Subclass should override this method to provide its own environment variables.
|
protected java.util.List<java.lang.String> |
getToolHomeProperties()
Subclass should override this method to provide its own system properties.
|
static boolean |
isMacOS() |
static boolean |
isUnixOS() |
static boolean |
isWindowsOS() |
protected java.lang.String |
locateTool(java.lang.String tool)
Try to find the location of the executable tools in the sdk's home path.
|
protected abstract void |
modifyBinDirectories()
This method will modify the
binDirectories according to tool itself. |
protected boolean |
needSearchRecursively(java.lang.String directoryName) |
protected java.lang.String |
searchFile(java.io.File directory,
java.lang.String filename,
boolean recusive)
Try to find a file matching 'filename' within directory.
|
void |
setToolHome(java.lang.String toolHome)
Only you are sure about the tool's home, you can set it.
Because if you set it, getToolHome() will not try to get the tool's homefrom "JVM properties" or "System environment variables" This method will verify if the toolHome exists and is a directory. |
protected Console console
protected final java.util.List<java.lang.String> binDirectories
public java.util.List<java.lang.String> getBinDirectories()
protected abstract void modifyBinDirectories()
binDirectories
according to tool itself.binDirectories
public static java.lang.String getOsFamilyName()
public static boolean isWindowsOS()
public static boolean isUnixOS()
public static boolean isMacOS()
protected java.lang.String locateTool(java.lang.String tool)
tool
- name like "adb.exe", "batch.bat" or "script.sh" etc...java.lang.IllegalStateException
- if tool cannot be found.protected java.lang.String searchFile(java.io.File directory, java.lang.String filename, boolean recusive)
directory
- File, the directory in which to search filefilename
- String, the filename to matchrecusive
- boolean, if we need to search files in sub-directorieslocateTool(String)
protected boolean needSearchRecursively(java.lang.String directoryName)
directoryName
- String, the directory to be searchedlocateTool(String)
public void setToolHome(java.lang.String toolHome)
getToolHome()
will not try to get the tool's hometoolHome
- java.lang.IllegalStateException
getToolHome()
public java.lang.String getToolHome()
toolHome
getToolHomeProperties()
getToolHomeEnvs()
toolHome
.java.lang.IllegalStateException
setToolHome(String)
protected java.util.List<java.lang.String> getToolHomeProperties()
protected java.util.List<java.lang.String> getToolHomeEnvs()
public java.lang.String getLastCommand()
public Process2 exec(java.lang.String tool, java.lang.String... args) throws java.io.IOException
tool,
- String, the executable (.exe)args,
- String, the parameters of the executable.java.io.IOException
public Process2 exec(java.lang.String tool, java.util.List<java.lang.String> args) throws java.io.IOException
java.io.IOException
public Process2 exec(java.io.File workingDirectory, java.lang.String... binaryAndArgs) throws java.io.IOException
java.io.IOException
public Process2 exec(java.io.File workingDirectory, java.util.List<java.lang.String> binaryAndArgs) throws java.io.IOException
java.io.IOException
public Process2 batch(java.lang.String tool, java.lang.String... args) throws java.io.IOException
tool,
- String, the batch file (.bat)args,
- String, the parameters for the batch filejava.io.IOException
public Process2 batch(java.io.File workingDirectory, java.lang.String... batchAndArgs) throws java.io.IOException
java.io.IOException
public Process2 batch(java.io.File workingDirectory, java.util.List<java.lang.String> batchAndArgs) throws java.io.IOException
java.io.IOException
Copyright © SAS Institute. All Rights Reserved.