|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.schmant.support.SchmantUtil
public final class SchmantUtil
This class contains static utility methods for Schmant scripts and tasks. Its
initial state is created by the Launcher
class when
Schmant starts.
Method Summary | |
---|---|
static void |
debugLogContents(File f,
Report r)
Debug log the contents of a file |
static File |
getCommandFromPath(String cmd)
Get a command from the PATH environment variable. |
static File |
getCommandFromPath(String cmd,
String... extensions)
Get a command from the PATH environment variable. |
static File |
getCommandFromPathOrNull(String cmd,
String... extensions)
Get a command from the PATH environment variable, returning null
if the command was not found. |
static String |
getPathString(Collection<?> components)
Build a path string with the entries separated by the platform's path separator ( File.pathSeparator ). |
static String |
getPathString(Collection<String> components,
char separator)
Build a path string, i.e. |
static File |
getRelativeToScriptDirectory(File f)
Get absolute file created by appending the supplied file to the directory of the launched script. |
static File |
getSchmantHome()
Get the location of the Schmant installation that is currently running. |
static NamedReadableFile |
getScriptEFile()
Get the currently executing script file. |
static File |
getScriptFile()
Get a reference to the currently executing script file as a File
object. |
static TwoObjects<File,Deque<NamedReadableFile>> |
init(File schmantHome)
This method is called by the Launcher object that
launches the Schmant script. |
static NamedReadableFile |
popScriptFile()
This is called by Schmant methods after executing an included script. |
static void |
pushScriptFile(NamedReadableFile f)
This is called by Schmant methods when the application starts or when including another script file. |
static void |
tearDown(TwoObjects<File,Deque<NamedReadableFile>> prevContents)
This method is called by the Launcher to tear down
the data associated with this object when the Schmant program exits. |
static String |
trimQuotes(String s)
If s is enclosed in quotes (" :s), remove them. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static TwoObjects<File,Deque<NamedReadableFile>> init(File schmantHome)
Launcher
object that
launches the Schmant script. Scripts don't have to call it.
schmantHome
- The location of the Schmant installation that is
currently running.
Launcher
when it calls
tearDown(TwoObjects)
.tearDown(TwoObjects)
public static void tearDown(TwoObjects<File,Deque<NamedReadableFile>> prevContents)
Launcher
to tear down
the data associated with this object when the Schmant program exits.
prevContents
- The previous contents of this object, if any. This
should be the object returned by init(File)
.init(File)
public static String trimQuotes(String s)
s
is enclosed in quotes ("
:s), remove them.
s
- The string to remove quotes from.
s
without enclosing quotes.public static void debugLogContents(File f, Report r)
f
- The file.r
- The Report
to log to.public static File getCommandFromPathOrNull(String cmd, String... extensions)
null
if the command was not found. The command can have one of a set of
permitted file name extensions.
Tip: The org.entityfs.support.io.OsPlatform
class can be used to
check if the program is running on Windows or not.
cmd
- The command, e.g. findbugs
.extensions
- The list of file name extensions that the command may
have, for instance "", "exe"
.
File
built on the absolute path to the command, or
null
if the command was not found in the path.public static File getCommandFromPath(String cmd, String... extensions) throws EntityNotFoundException
Tip: The org.entityfs.support.io.OsPlatform
class can be used to
check if the program is running on Windows or not.
cmd
- The command, e.g. findbugs
.extensions
- The list of file name extensions that the command may
have, for instance "", "exe"
.
File
built on the absolute path to the command.
EntityNotFoundException
- If the command was not found on the
PATH
.public static File getCommandFromPath(String cmd) throws EntityNotFoundException
cmd
parameter.
cmd
- The command, e.g. findbugs
File
built on the absolute path to the command.
EntityNotFoundException
- If the command was not found on the
PATH
.public static String getPathString(Collection<String> components, char separator)
components
- The stringsseparator
- The separator character.
public static String getPathString(Collection<?> components)
File.pathSeparator
).
components
- A collection of objects. Each object is interpreted by
InterpretAsFileStrategy
.
public static void pushScriptFile(NamedReadableFile f)
public static NamedReadableFile popScriptFile()
public static File getScriptFile()
File
object. If the script file is not File
-backed, such as when it is
in a Zip file, this method returns null
.
null
if the script file is not File
-backed.
(ECFileResolvable
)getScriptEFile()
public static NamedReadableFile getScriptEFile()
public static File getSchmantHome()
public static File getRelativeToScriptDirectory(File f) throws IllegalArgumentException
f
- The relative file
IllegalArgumentException
- If the file is not a relative location.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |