| Modifier and Type | Field and Description |
|---|---|
static String |
CONFIGURATION_EXECUTE_SHOW_CONTENT |
static String |
CONFIGURATION_LOGGER_MUTE |
static String |
CP
Common system executables
|
protected File |
currentWorkingDirectory
Track the current working directory
|
static int |
DIRECTORY |
protected static int |
EXIT_CODE
Exit code of the last executable execution
|
static int |
FILE |
static String |
FIND |
static String |
GREP |
static String |
GZIP |
static String |
KILL |
static String |
LS |
static String |
MKDIR |
static int |
NOT_FOUND
File types
|
protected Properties |
properties
Configuration
|
static String |
PS |
static String |
RM |
static String |
SYSTEMCTL
Systemdctl executable
|
static String |
SYSTEMD_SERVICE_ROOT
Systemd root path for service files
|
static String |
TAR |
static String |
UNZIP |
static String |
ZIP |
| Constructor and Description |
|---|
Toolset()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
File |
absoluteFile()
Method to get an absolute File in the current working directory
|
File |
absoluteFile(String path)
Method to get an absolute File
|
String |
absolutePath(File file)
Method to get an absolute path
|
String |
absolutePath(String path)
Method to get an absolute path
|
String[] |
arguments(List<String> argumentList) |
String[] |
arguments(String... arguments)
Method to convert a variable argument list into a an array
|
void |
changeDirectory(String path)
Method to change the current working directory
|
void |
checkExitCode(int expectedExitCode)
Method to check the exit code of the last execute command
|
long |
checksumCRC32(String file) |
void |
cleanDirectory(String directory) |
void |
copyDirectory(String srcDir,
String destDir) |
void |
copyDirectoryToDirectory(String srcDir,
String destDir) |
void |
copyFile(String srcFile,
String destFile) |
void |
debug(Object object)
Method to log a debug message
|
void |
deleteDirectory(String directory) |
boolean |
deleteQuietly(String file) |
boolean |
directoryContains(String directory,
String child) |
void |
error(Object object)
Method to log an error error message
|
ExecutionResult |
execute(String executable,
String[] arguments)
Method to execute an executable
|
ExecutionResult |
execute(String executable,
String[] arguments,
int expectedExitCode)
Method to execute an executable
|
boolean |
exists(String path)
Method to determine if a file exists
|
int |
exitCode()
Method to get the exit code of the last execute command
|
void |
forceDelete(String file) |
void |
forceMkdir(String directory) |
void |
forceMkdirParent(String file) |
String |
getConfiguration(String key,
String defaultValue)
Method to get a configuration value based on key
|
org.slf4j.Logger |
getLogger()
Method to get the slf4j Logger
|
String |
getTempDirectoryPath() |
String |
getUserDirectoryPath() |
void |
info(Object object)
Method to log an info message
|
List<String> |
listFiles(String path)
Method to rename a file
|
org.json.simple.JSONArray |
loadJSONArray(String path)
Method to load a file's content as a JSONArray
|
org.json.simple.JSONObject |
loadJSONObject(String path)
Method to load a file's content as a JSONObject
|
Properties |
loadProperties(String path)
Method to create a directory, creating any necassary parent directories
|
void |
mergeConfiguration(Properties properties)
Method to merge Properties into the current configuration Properties
|
void |
moveDirectory(String srcDir,
String destDir) |
void |
moveDirectoryToDirectory(String src,
String destDir,
boolean createDestDir) |
void |
moveFile(String srcFile,
String destFile) |
void |
moveFileToDirectory(String srcFile,
String destDir,
boolean createDestDir) |
void |
moveToDirectory(String src,
String destDir,
boolean createDestDir) |
String |
noExtension(String filename)
Method to get a filename without extension
|
String |
noPath(String path)
Method to a filename from an absolute path
|
org.json.simple.JSONArray |
parseJSONArray(String json)
Method to parse a String as a JSONArray
|
org.json.simple.JSONObject |
parseJSONObject(String json)
Method to parse a String as a JSONObject
|
String |
pwd()
Method to get the current working directory
|
byte[] |
readFileToByteArray(String file) |
String |
readFileToString(String file) |
String |
readFileToString(String file,
Charset encoding) |
List<String> |
recursivelyListFiles(String path)
Method to recursive list all children, grandchildren, etc.
|
void |
replaceProperties(Properties properties,
String path)
Method to replace Properties in a file
|
void |
replaceProperties(Properties properties,
String inputFilePath,
String outFilePath)
Method to replace Properties in a file
|
String |
replaceProperties(String content)
Method to replace Properties in a String
|
void |
setConfiguration(Properties properties)
Method to set configuration Properties
|
void |
setConfiguration(String key,
String value)
Method to set a configuration key / value
|
long |
sizeOf(File file) |
long |
sizeOfDirectory(String directory) |
String[] |
stringToArray(String string)
Method to convert a string with CRLF to a list
|
List<String> |
stringToList(String string)
Method to convert a string with CRLF to a list
|
void |
touch(String file) |
void |
trace(Object object)
Method to log a trace message
|
int |
type(String path)
Method to get the "type" of a file
|
String |
typeString(String path)
Method to get the "type" of a file as a String
|
void |
unzip(String zipFilename,
String destinationPath)
Method to unzip a file into a directory
|
void |
unzip(String zipFilename,
String destinationPath,
boolean overwrite)
Method to unzip a file into a directory
|
void |
warn(Object object)
Method to log a warning warning
|
void |
writeByteArrayToFile(String file,
byte[] data) |
void |
writeByteArrayToFile(String file,
byte[] data,
boolean append) |
void |
writeStringToFile(String file,
String data) |
void |
writeStringToFile(String file,
String data,
Charset encoding) |
void |
zip(String sourcePath,
String zipFilename)
Method to zip a directory
|
public static final String CONFIGURATION_LOGGER_MUTE
public static final String CONFIGURATION_EXECUTE_SHOW_CONTENT
public static final String SYSTEMD_SERVICE_ROOT
public static final String CP
public static final String FIND
public static final String GREP
public static final String GZIP
public static final String KILL
public static final String LS
public static final String MKDIR
public static final String PS
public static final String RM
public static final String TAR
public static final String UNZIP
public static final String ZIP
public static final String SYSTEMCTL
protected static int EXIT_CODE
public static final int NOT_FOUND
public static final int DIRECTORY
public static final int FILE
protected File currentWorkingDirectory
protected Properties properties
public void setConfiguration(String key, String value)
key - value - public void setConfiguration(Properties properties)
properties - public void mergeConfiguration(Properties properties)
properties - public String getConfiguration(String key, String defaultValue)
key - defaultValue - public List<String> stringToList(String string)
string - public String[] stringToArray(String string)
string - public String noExtension(String filename)
filename - public String noPath(String path)
path - public org.slf4j.Logger getLogger()
public void debug(Object object)
object - public void trace(Object object)
object - public void info(Object object)
object - public void warn(Object object)
object - public void error(Object object)
object - public void changeDirectory(String path)
path - public String pwd()
public String absolutePath(String path)
path - public String absolutePath(File file)
file - public File absoluteFile()
public File absoluteFile(String path)
path - public String[] arguments(String... arguments)
arguments - public Properties loadProperties(String path)
path - public boolean exists(String path)
path - public int type(String path)
path - public String typeString(String path)
path - public List<String> listFiles(String path)
oldPath - newPath - public List<String> recursivelyListFiles(String path)
path - public String replaceProperties(String content)
content - public void replaceProperties(Properties properties, String path)
properties - path - public void replaceProperties(Properties properties, String inputFilePath, String outFilePath)
properties - inputFilePath - infoFilePath - public org.json.simple.JSONObject parseJSONObject(String json)
json - public org.json.simple.JSONObject loadJSONObject(String path)
path - public org.json.simple.JSONArray parseJSONArray(String json)
json - public org.json.simple.JSONArray loadJSONArray(String path)
path - public ExecutionResult execute(String executable, String[] arguments)
executable - arguments - public ExecutionResult execute(String executable, String[] arguments, int expectedExitCode)
executable - arguments - expectedExitCode - public int exitCode()
public void checkExitCode(int expectedExitCode)
expectedExitCode - public void zip(String sourcePath, String zipFilename)
sourcePath - zipFilename - public void unzip(String zipFilename, String destinationPath)
zipFilename - destinationPath - public void unzip(String zipFilename, String destinationPath, boolean overwrite)
zipFilename - destinationPath - overwrite - public String getTempDirectoryPath()
public String getUserDirectoryPath()
public void touch(String file)
public void deleteDirectory(String directory)
public boolean deleteQuietly(String file)
public void cleanDirectory(String directory)
public byte[] readFileToByteArray(String file)
public void writeByteArrayToFile(String file, byte[] data)
public void writeByteArrayToFile(String file, byte[] data, boolean append)
public void forceDelete(String file)
public void forceMkdir(String directory)
public void forceMkdirParent(String file)
public long sizeOf(File file)
public long sizeOfDirectory(String directory)
public long checksumCRC32(String file)
public void moveDirectoryToDirectory(String src, String destDir, boolean createDestDir)
public void moveFileToDirectory(String srcFile, String destDir, boolean createDestDir)
Copyright © 2016. All rights reserved.