public class Environment extends java.lang.Object implements RevisionHandler
Constructor and Description |
---|
Environment() |
Modifier and Type | Method and Description |
---|---|
void |
addVariable(java.lang.String key,
java.lang.String value)
Add a variable to the internal map.
|
static boolean |
containsEnvVariables(java.lang.String source)
Tests for the presence of environment variables.
|
java.lang.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.
|
java.util.Set<java.lang.String> |
getVariableNames()
Get the names of the variables (keys) stored in the
internal map.
|
java.lang.String |
getVariableValue(java.lang.String key)
Get the value for a particular variable.
|
static void |
main(java.lang.String[] args)
Main method for testing this class.
|
void |
removeVariable(java.lang.String key)
Remove a named variable from the map.
|
java.lang.String |
substitute(java.lang.String source)
Substitute a variable names for their values in the given string.
|
public static Environment getSystemWide()
public static boolean containsEnvVariables(java.lang.String source)
source
- the string to testpublic java.lang.String substitute(java.lang.String source) throws java.lang.Exception
source
- the source string to replace variables injava.lang.Exception
- if an unknown variable name is encounteredpublic void addVariable(java.lang.String key, java.lang.String value)
key
- the name of the variablevalue
- its valuepublic void removeVariable(java.lang.String key)
key
- the name of the varaible to remove.public java.util.Set<java.lang.String> getVariableNames()
public java.lang.String getVariableValue(java.lang.String key)
key
- the name of the variable to getpublic static void main(java.lang.String[] args)
args
- a list of strings to replace variables in
(e.g. "\${os.name} "\${java.version}")public java.lang.String getRevision()
getRevision
in interface RevisionHandler