net.dpml.transit
Class Environment

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<Object,Object>
          extended by java.util.Properties
              extended by net.dpml.transit.Environment
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class Environment
extends Properties

Encapsulates operating system and shell specific access to environment variables.

Version:
1.1.0
Author:
Digital Product Meta Library
See Also:
Serialized Form

Field Summary
static String OSNAME
          os.name System property
static String USERNAME
          user.name System property
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
Environment()
          Creates a snapshot of the current shell environment variables for a user.
 
Method Summary
static String getEnvVariable(String name)
          Gets the value of a shell environment variable.
static Properties getEnvVariables()
          Gets all environment variables within a Properties instance where the key is the environment variable name and value is the value of the property.
static String getUserShell()
          Gets the user's shell executable.
static boolean isNetWare()
          Checks to see if the operating system is NetWare.
static boolean isOpenVMS()
          Checks to see if the operating system is OpenVMS.
static boolean isUnix()
          Checks to see if the operating system is a UNIX variant.
static boolean isWindows()
          Checks to see if the operating system is a Windows variant.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

OSNAME

public static final String OSNAME
os.name System property


USERNAME

public static final String USERNAME
user.name System property

Constructor Detail

Environment

public Environment()
            throws EnvironmentException
Creates a snapshot of the current shell environment variables for a user.

Throws:
EnvironmentException - if there is an error accessing the environment
Method Detail

getEnvVariable

public static String getEnvVariable(String name)
                             throws EnvironmentException
Gets the value of a shell environment variable.

Parameters:
name - the name of variable
Returns:
the String representation of an environment variable value
Throws:
EnvironmentException - if there is a problem accessing the environment

isUnix

public static boolean isUnix()
Checks to see if the operating system is a UNIX variant.

Returns:
true of the OS is a UNIX variant, false otherwise

isWindows

public static boolean isWindows()
Checks to see if the operating system is a Windows variant.

Returns:
true of the OS is a Windows variant, false otherwise

isNetWare

public static boolean isNetWare()
Checks to see if the operating system is NetWare.

Returns:
true of the OS is NetWare, false otherwise

isOpenVMS

public static boolean isOpenVMS()
Checks to see if the operating system is OpenVMS.

Returns:
true of the OS is a NetWare variant, false otherwise

getEnvVariables

public static Properties getEnvVariables()
                                  throws EnvironmentException
Gets all environment variables within a Properties instance where the key is the environment variable name and value is the value of the property.

Returns:
the environment variables and values as Properties
Throws:
EnvironmentException - if os is not recognized

getUserShell

public static String getUserShell()
                           throws EnvironmentException
Gets the user's shell executable.

Returns:
the shell executable for the user
Throws:
EnvironmentException - the there is a problem accessing shell information