com.sun.javatest.util
Class SysEnv

java.lang.Object
  extended by com.sun.javatest.util.SysEnv

public class SysEnv
extends java.lang.Object

A class to provide access to OS environment variables, by means of an external command which is executed. The command will be executed when the first access is made to the environment variables. The command name is determined as follows:

Note that the specified command will be invoked by Runtime.exec and must be capable or working as such. This may preclude direct use of builtin commands on some systems. For example, you cannot directly exec the Windows "set" command built in to the standard Windows command shell.

The command must print out a series of lines of the form name=value, one for each environment variable.


Constructor Summary
SysEnv()
           
 
Method Summary
static java.lang.String get(java.lang.String name)
          Get the value of a specified environment value.
static java.util.Map getAll()
          Get a map containing all of the environment variables in the current execution context.
static java.util.Map getAll(java.util.Map m)
          Get a map containing all of the environment variables in the current execution context.
static void setCommand(java.lang.String cmd)
          Set the command to be executed to access the OS environment variables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SysEnv

public SysEnv()
Method Detail

setCommand

public static void setCommand(java.lang.String cmd)
Set the command to be executed to access the OS environment variables. To be effective, this method must be set before any of the get methods,

Parameters:
cmd - the command to be executed

get

public static java.lang.String get(java.lang.String name)
Get the value of a specified environment value.

Parameters:
name - the name of the environment variable
Returns:
the value of the environment variable if set, or null if not

getAll

public static java.util.Map getAll()
Get a map containing all of the environment variables in the current execution context.

Returns:
a map containing all the known environment variables.

getAll

public static java.util.Map getAll(java.util.Map m)
Get a map containing all of the environment variables in the current execution context.

Parameters:
m - the map in which to put the names and values of all the environment variables in the current execution context.
Returns:
the argument map.


Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.