|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.cruisecontrol.util.OSEnvironment
A simple utility class for obtaining and parsing system environment variables. It has been tested on Windows 2000, Windows XP, Solaris, and HP-UX, though it should work with any Win32 (95+) or Unix based palatform.
| Constructor Summary | |
OSEnvironment()
Constructor Creates an instance of OSEnvironment, queries the OS to discover it's environment variables and makes them available through the getter methods |
|
| Method Summary | |
void |
add(java.lang.String variable,
java.lang.String value)
Adds a variable to this representation of the environment. |
java.util.List |
getEnvironment()
Returns all environment variables which were set at the time the class was instantiated, as well as any which have been added programatically. |
java.lang.String |
getVariable(java.lang.String variable)
Gets the value of an environment variable. |
java.lang.String |
getVariable(java.lang.String variable,
java.lang.String defaultValue)
Gets the value of an environment variable. |
java.lang.String |
getVariableIgnoreCase(java.lang.String variable)
Gets the value of an environment variable. |
java.lang.String[] |
toArray()
Returns all environment variables which were set at the time the class was instantiated, as well as any which have been added programatically. |
java.lang.String |
toString()
Returns a String |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public OSEnvironment()
| Method Detail |
public java.lang.String getVariable(java.lang.String variable)
variable - The variable for which you wish the value
null if not foundgetVariable(String variable, String defaultValue)
public java.lang.String getVariable(java.lang.String variable,
java.lang.String defaultValue)
variable - the variable for which you wish the valuedefaultValue - The value to return if the variable is not set in the
environment.
public java.lang.String getVariableIgnoreCase(java.lang.String variable)
getVariable() instead.
variable - the variable for which you wish the valuegetVariable(String variable),
getVariable(String variable, String defaultValue)
public void add(java.lang.String variable,
java.lang.String value)
variable - the variable to setvalue - the value of the variablepublic java.util.List getEnvironment()
List of all environment variables. The
List is made up of Strings of the
form "variable=value".toArray()public java.lang.String[] toArray()
String[] containing all environment variables.
The Strings are of the form "variable=value".
This is the format expected by
java.lang.Runtime.exec().Runtimepublic java.lang.String toString()
String representation of the
environment.
- Returns:
- A
String representation of the environment
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||