|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sadun.util.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 NameTransformer which
produces names in the style of typical java property names. |
Constructor Summary | |
EnvironmentVariables()
Constructor for EnvironmentVariables. |
Method Summary | |
java.util.Set |
envNames()
Return the set of environment variables names |
java.util.Set |
envPropertyNames()
Return the set of property names derived by the environment variables, as obtained by getEnvProperty() |
java.util.Properties |
getAsProperties()
Return a Properties object with the environment properties, whose names are names derived by the environment variables, as obtained by getEnvProperty() |
java.lang.String |
getEnv(java.lang.String name)
Return the value of the environemnt variable of the given name |
protected java.lang.String |
getEnv(java.lang.String name,
EnvironmentVariables.NameTransformer t)
Return the name of the given variable, after applying the given name transformation |
java.lang.String |
getEnvProperty(java.lang.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 |
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 java.lang.String getEnv(java.lang.String name, EnvironmentVariables.NameTransformer t)
name transformation
name
- the name of the required environment entryt
- the transformation to apply
public java.lang.String getEnv(java.lang.String name)
name
- the environemnt variable name
public java.lang.String getEnvProperty(java.lang.String name)
SimpleNameTransformer
name
-
public java.util.Set envNames()
public java.util.Set envPropertyNames()
getEnvProperty()
public java.util.Properties getAsProperties()
getEnvProperty()
public void toSystemProperties()
getEnvProperty()
to the system properties.
public static EnvironmentVariables getInstance()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |