Package kieker.tools.common
Class ParameterEvaluationUtils
java.lang.Object
kieker.tools.common.ParameterEvaluationUtils
public final class ParameterEvaluationUtils
extends java.lang.Object
Collection of command line parameter evaluation functions.
- Since:
- 1.15
- Author:
- Reiner Jung
-
Method Summary
Modifier and Type Method Description static boolean
checkDirectory(java.io.File location, java.lang.String label, com.beust.jcommander.JCommander commander)
Check whether the given handle refers to an existing directory.static <T> T
createFromConfiguration(java.lang.Class<T> clazz, Configuration configuration, java.lang.String key, java.lang.String errorMessage)
Instantiate on object from a property.static java.net.URL
createURL(java.lang.String urlString, java.lang.String label)
Create an URL from a given string.static boolean
isFileReadable(java.io.File file, java.lang.String label, com.beust.jcommander.JCommander commander)
Check whether a specified file is readable.
-
Method Details
-
checkDirectory
public static boolean checkDirectory(java.io.File location, java.lang.String label, com.beust.jcommander.JCommander commander)Check whether the given handle refers to an existing directory.- Parameters:
location
- path to the directorylabel
- noun or phrase indicating the parameter of the given location, e.g., "input directory"commander
- command line handler used to plot the usage message- Returns:
- returns true if the directory exists, else false
-
isFileReadable
public static boolean isFileReadable(java.io.File file, java.lang.String label, com.beust.jcommander.JCommander commander)Check whether a specified file is readable.- Parameters:
file
- the file handlelabel
- noun or phrase indicating the parameter of the given location, e.g., "configuration file"commander
- command line handler used to plot the usage message- Returns:
- true when the file is readable
-
createURL
public static java.net.URL createURL(java.lang.String urlString, java.lang.String label)Create an URL from a given string.- Parameters:
urlString
- the url stringlabel
- label used to indicate which string- Returns:
- returns an URL or null on error
-
createFromConfiguration
public static <T> T createFromConfiguration(java.lang.Class<T> clazz, Configuration configuration, java.lang.String key, java.lang.String errorMessage)Instantiate on object from a property.- Type Parameters:
T
- class type of the object to be instantiated- Parameters:
clazz
- class object for the object to be instantiatedconfiguration
- configuration object containing the class namekey
- key of the entry that should contain the a class nameerrorMessage
- error message in case the object cannot be instantiated- Returns:
- returns either an object conforming to the object class or null if the initialization in incomplete
-