public class Environment extends Object implements RevisionHandler
| Constructor and Description |
|---|
Environment() |
| Modifier and Type | Method and Description |
|---|---|
void |
addVariable(String key,
String value)
Add a variable to the internal map of this properties object.
|
void |
addVariableSystemWide(String key,
String value)
Add a a variable to the internal map of this properties object and to the
global system-wide environment;
|
static boolean |
containsEnvVariables(String source)
Tests for the presence of environment variables.
|
String |
getRevision()
Returns the revision string.
|
static Environment |
getSystemWide()
Get the singleton system-wide (visible to every class in the running VM)
set of environment variables.
|
Set<String> |
getVariableNames()
Get the names of the variables (keys) stored in the internal map.
|
String |
getVariableValue(String key)
Get the value for a particular variable.
|
static void |
main(String[] args)
Main method for testing this class.
|
void |
removeVariable(String key)
Remove a named variable from the map.
|
String |
substitute(String source)
Substitute a variable names for their values in the given string.
|
public static Environment getSystemWide()
public static boolean containsEnvVariables(String source)
source - the string to testpublic String substitute(String source) throws Exception
source - the source string to replace variables inException - if an unknown variable name is encounteredpublic void addVariable(String key, String value)
key - the name of the variablevalue - its valuepublic void addVariableSystemWide(String key, String value)
key - the name of the variablevalue - its valuepublic void removeVariable(String key)
key - the name of the varaible to remove.public Set<String> getVariableNames()
public String getVariableValue(String key)
key - the name of the variable to getpublic static void main(String[] args)
args - a list of strings to replace variables in (e.g. "\${os.name}
"\${java.version}")public String getRevision()
getRevision in interface RevisionHandlerCopyright © 2016 University of Waikato, Hamilton, NZ. All Rights Reserved.