|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnl.knowledgeplaza.util.EnvironmentVariables
public class EnvironmentVariables
An helper class to handle environment variables when they're present on the underlying operating system. So far, the only supported operating system is Windows 2000 - but the underlying mechanism (based on running a 'set' command on the system shell) is easly usable for different o/s.
In order to add support for one OS, add the identification string and the associated shell command in the private getGenerator() method, and check that the parsing code in setBasedGenerator.getEnvironment() is correct for parsing the result.
A typical usage consists in just invoking
EnvironmentVariables.getInstance(). toSystemProperties();
and then browse the system properties for env. entries.
| Nested Class Summary | |
|---|---|
static interface |
EnvironmentVariables.Generator
A class implementing this interface is able to retrieve environment information in some way. |
static interface |
EnvironmentVariables.NameTransformer
Classes implementing this interface can transform environment names in a "canonical" form |
class |
EnvironmentVariables.SimpleNameTransformer
A NameTransformerwhich produces names in the style of typical java property names. |
| Constructor Summary | |
|---|---|
EnvironmentVariables()
Constructor for EnvironmentVariables. |
|
| Method Summary | |
|---|---|
Set |
envNames()
Return the set of environment variables names |
Set |
envPropertyNames()
Return the set of property names derived by the environment variables, as obtained by getEnvProperty() |
Properties |
getAsProperties()
Return a Properties object with the environment properties, whose names are names derived by the environment variables, as obtained by getEnvProperty() |
String |
getEnv(String name)
Return the value of the environemnt variable of the given name |
protected String |
getEnv(String name,
EnvironmentVariables.NameTransformer t)
Return the name of the given variable, after applying the given name transformation |
String |
getEnvProperty(String name)
Return the value of a property whose name is a transformation of an environment variable name according to a SimpleNameTransformer |
static EnvironmentVariables |
getInstance()
Return the single instance of this class |
static void |
main(String[] args)
Test |
void |
toSystemProperties()
Add properties obtained by getEnvProperty() to the system properties. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EnvironmentVariables()
| Method Detail |
|---|
protected String getEnv(String name,
EnvironmentVariables.NameTransformer t)
name transformation
name - the name of the required environment entryt - the transformation to apply
public String getEnv(String name)
name - the environemnt variable name
public String getEnvProperty(String name)
SimpleNameTransformer
name -
public Set envNames()
public Set envPropertyNames()
getEnvProperty()
public Properties getAsProperties()
getEnvProperty()
public void toSystemProperties()
getEnvProperty() to the system properties.
public static EnvironmentVariables getInstance()
public static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||