Package noaa.coastwatch.tools
Class ToolServices
java.lang.Object
noaa.coastwatch.tools.ToolServices
The tool services class defines various static methods relating
to the CoastWatch tools.
- Since:
- 3.1.2
- Author:
- Peter Hollemans
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe author.static final StringThe software copyright.static final StringThe software copyright (short version).static final StringThe standard error dialog instructions string.static final DimensionThe standard size of the help dialog.static final StringThe full package description.static final StringThe short package description.static final StringThe tool parameter splitting expression.static final StringThe support email address.static final StringThe software website. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringChecks the setup of tool services.static voidexitWithCode(int code) Performs an exit of a tool with the specified code.static voidfinishExecution(String name) Logs a finishing time for a executable task.static StringGets an about string appropriate for an about dialog box.static StringGets the current tool command line, or null if none has been set.static StringgetFullVersion(String tool) Gets a full tool and Java runtime version string for printing on the command line.static StringGets a Java runtime and OS version.static StringGets a string appropriate for a splash screen annotation.static StringGets the current command line parameter splitting regular expression.static StringgetToolVersion(String tool) Gets a tool version string.static StringGets a simple version string.static voidsetCommandLine(String command, String[] argv) Sets the current tool command line.static voidsetSplitRegex(String expr) Sets the current command line parameter splitting regular expression.static voidsetSystemExit(boolean flag) Sets the system exit flag.static ThrowableshortTrace(Throwable error, String prefix) Shortens the stack trace contained in a throwable error so that it ends at the mention of a specific class.static voidstartExecution(String name) Logs a starting time for an executable task.static voidStarts a memory monitor task that repeatedly outputs the status of memory usage to standard output until the VM exits.static voidstartMemoryMonitor(int interval) Starts a memory monitor task that repeatedly outputs the status of memory usage to standard output until the VM exits.static voidLogs a warning to the user if the throwable or any of its causes is an OutOfMemory error.
-
Field Details
-
PACKAGE
The full package description.- See Also:
-
PACKAGE_SHORT
The short package description.- See Also:
-
AUTHOR
The author.- See Also:
-
SUPPORT
The support email address.- See Also:
-
WEBSITE
The software website.- See Also:
-
COPYRIGHT
The software copyright.- See Also:
-
COPYRIGHT_SHORT
The software copyright (short version).- See Also:
-
SPLIT_REGEX
The tool parameter splitting expression.- See Also:
-
ERROR_INSTRUCTIONS
The standard error dialog instructions string.- See Also:
-
HELP_DIALOG_SIZE
The standard size of the help dialog.
-
-
Method Details
-
startExecution
Logs a starting time for an executable task.- Parameters:
name- the name of the task starting.- Since:
- 3.5.0
-
finishExecution
Logs a finishing time for a executable task.- Parameters:
name- the name of the task finishing.- Since:
- 3.5.0
-
setSystemExit
public static void setSystemExit(boolean flag) Sets the system exit flag.- Parameters:
flag- the exit flag, true to actually exit the system on a call toexitWithCode(int)or false to not.- Since:
- 3.5.0
-
getAbout
Gets an about string appropriate for an about dialog box.- Parameters:
tool- the tool or program name.- Returns:
- the about string.
-
getSplash
Gets a string appropriate for a splash screen annotation.- Parameters:
tool- the tool or program name.- Returns:
- the splash screen string.
-
getVersion
Gets a simple version string.- Returns:
- the version string, for example "3.2.2".
-
getToolVersion
Gets a tool version string.- Parameters:
tool- the tool or program name.- Returns:
- the tool version string, for example "[cwutils 3.2.2] cwrender".
-
getJavaVersion
Gets a Java runtime and OS version. -
getFullVersion
Gets a full tool and Java runtime version string for printing on the command line.- Parameters:
tool- the tool or program name.- Returns:
- the full version string.
-
setCommandLine
Sets the current tool command line. This method should be called by all tools at the beginning of main() so that other classes may retrieve the current command line via getCommandLine(). This is especially important for tools that create new data files, so that writers can insert the command line into the data file history.- Parameters:
command- the command or program name. If this is a class name, only the final part of the class name is retained as the program name.argv- an array of command line arguments.
-
getCommandLine
Gets the current tool command line, or null if none has been set. -
startMemoryMonitor
public static void startMemoryMonitor(int interval) Starts a memory monitor task that repeatedly outputs the status of memory usage to standard output until the VM exits.- Parameters:
interval- the interval in seconds for the memory status message.- Since:
- 3.8.1
-
startMemoryMonitor
public static void startMemoryMonitor()Starts a memory monitor task that repeatedly outputs the status of memory usage to standard output until the VM exits. -
getSplitRegex
Gets the current command line parameter splitting regular expression.- Returns:
- the current splitting expression.
-
setSplitRegex
Sets the current command line parameter splitting regular expression.- Parameters:
expr- the new splitting expression.
-
checkSetup
Checks the setup of tool services.- Returns:
- an error string if any issues encountered, or null if none.
-
exitWithCode
public static void exitWithCode(int code) Performs an exit of a tool with the specified code. The exit may be a system exit, or a soft exit depending on the exit mode. The default is to actually perform a system exit.- Parameters:
code- the code to use for exiting.- Since:
- 3.5.0
- See Also:
-
warnOutOfMemory
Logs a warning to the user if the throwable or any of its causes is an OutOfMemory error.- Parameters:
th- the throwable to check.- Since:
- 3.5.1
-
shortTrace
Shortens the stack trace contained in a throwable error so that it ends at the mention of a specific class. If the thowable has a non-null cause, it is modified as well.- Parameters:
error- the throwable to check.prefix- the prefix of the class name to look for. Any stack trace elements after the last one that contains the prefix are removed.- Returns:
- the throwable error passed in, for convenience.
- Since:
- 3.7.1
-