Package weka.core
Class Environment
java.lang.Object
weka.core.Environment
- All Implemented Interfaces:
RevisionHandler
This class encapsulates a map of all environment and java system properties.
There are methods for adding and removing variables as well as a method for
replacing key names (enclosed by ${}) with their associated value in Strings.
- Version:
- $Revision: 5562 $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addVariable
(String key, String value) Add a variable to the internal map.static boolean
containsEnvVariables
(String source) Tests for the presence of environment variables.Returns the revision string.static Environment
Get the singleton system-wide (visible to every class in the running VM) set of environment variables.Get the names of the variables (keys) stored in the internal map.getVariableValue
(String key) Get the value for a particular variable.static void
Main method for testing this class.void
removeVariable
(String key) Remove a named variable from the map.substitute
(String source) Substitute a variable names for their values in the given string.
-
Constructor Details
-
Environment
public Environment()
-
-
Method Details
-
getSystemWide
Get the singleton system-wide (visible to every class in the running VM) set of environment variables.- Returns:
- the system-wide set of environment variables.
-
containsEnvVariables
Tests for the presence of environment variables.- Parameters:
source
- the string to test- Returns:
- true if the argument contains one or more environment variables
-
substitute
Substitute a variable names for their values in the given string.- Parameters:
source
- the source string to replace variables in- Returns:
- a String with all variable names replaced with their values
- Throws:
Exception
- if an unknown variable name is encountered
-
addVariable
Add a variable to the internal map.- Parameters:
key
- the name of the variablevalue
- its value
-
removeVariable
Remove a named variable from the map.- Parameters:
key
- the name of the varaible to remove.
-
getVariableNames
Get the names of the variables (keys) stored in the internal map.- Returns:
- a Set of variable names (keys)
-
getVariableValue
Get the value for a particular variable.- Parameters:
key
- the name of the variable to get- Returns:
- the associated value or null if this variable is not in the internal map
-
main
Main method for testing this class.- Parameters:
args
- a list of strings to replace variables in (e.g. "\${os.name} "\${java.version}")
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-