org.apache.avalon.util.env
Class Env

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byjava.util.Properties
              extended byorg.apache.avalon.util.env.Env
All Implemented Interfaces:
Cloneable, Map, Serializable

public class Env
extends Properties

Encapsulates operating system and shell specific access to environment variables. TODO cleanup exception handling which is now in an odd state (constructors) need to be added and or changed.

Version:
$Revision: 1.3 $
Author:
Alex Karasulu, Stephen McConnell
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
Env()
          Creates a snapshot of the current shell environment variables for a user.
 
Method Summary
static String getEnvVariable(String a_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 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, propertyNames, save, setProperty, store
 
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

Env

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

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

getEnvVariable

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

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

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

getEnvVariables

public static Properties getEnvVariables()
                                  throws EnvAccessException
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:
EnvAccessException

getUserShell

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

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


Copyright © Apache Software Foundation. All Rights Reserved.