com.sun.enterprise.admin.cli
Class Environment

java.lang.Object
  extended by com.sun.enterprise.admin.cli.Environment

public final class Environment
extends java.lang.Object

The environment variables for CLI commands. An instance of this class is passed to each command to give it access to environment variables. Command implementations should access environment information from this class rather than using System.getenv. In multimode, the export command may change environment variables in the instance of this class that is shared by all commands.

Author:
Bill Shannon

Field Summary
static java.lang.String AS_ADMIN_ENV_PREFIX
           
private  java.util.Map<java.lang.String,java.lang.String> env
           
 
Constructor Summary
Environment()
          Initialize the enviroment with all relevant system environment entries.
Environment(boolean ignoreEnvironment)
          Constructor that ignores the system environment, mostly used to enable repeatable tests.
 
Method Summary
 java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
          Return a set of all the entries, just like a Map does.
 java.lang.String get(java.lang.String name)
          Get the named environment entry.
 boolean getBooleanOption(java.lang.String name)
          Return the value of the environment entry corresponding to the named option.
 java.lang.String getStringOption(java.lang.String name)
          Return the value of the environment entry corresponding to the named option.
 boolean hasOption(java.lang.String name)
          Is there an environment entry corresponding to the named option?
private  java.lang.String optionToEnv(java.lang.String name)
          Convert an option name (e.g., "host") to an environment variable name (e.g., AS_ADMIN_HOST).
 java.lang.String put(java.lang.String name, java.lang.String value)
          Set the named environment entry to the specified value.
 java.lang.String putOption(java.lang.String name, java.lang.String value)
          Set the environment entry corresponding to the named option to the specified value.
 void remove(java.lang.String name)
          Remove the name environment entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AS_ADMIN_ENV_PREFIX

public static final java.lang.String AS_ADMIN_ENV_PREFIX
See Also:
Constant Field Values

env

private java.util.Map<java.lang.String,java.lang.String> env
Constructor Detail

Environment

public Environment()
Initialize the enviroment with all relevant system environment entries.


Environment

public Environment(boolean ignoreEnvironment)
Constructor that ignores the system environment, mostly used to enable repeatable tests.

Method Detail

getBooleanOption

public boolean getBooleanOption(java.lang.String name)
Return the value of the environment entry corresponding to the named option.

Parameters:
name - the option name
Returns:
the value of the corresponding environment entry

getStringOption

public java.lang.String getStringOption(java.lang.String name)
Return the value of the environment entry corresponding to the named option.

Parameters:
name - the option name
Returns:
the value of the corresponding environment entry

hasOption

public boolean hasOption(java.lang.String name)
Is there an environment entry corresponding to the named option?

Parameters:
name - the option name
Returns:
true if there's a corresponding environment entry

get

public java.lang.String get(java.lang.String name)
Get the named environment entry.

Parameters:
name - the name of the environment entry
Returns:
the value of the entry, or null if no such entry

put

public java.lang.String put(java.lang.String name,
                            java.lang.String value)
Set the named environment entry to the specified value.

Parameters:
name - the environment entry name
value - the value
Returns:
the previous value of the entry

remove

public void remove(java.lang.String name)
Remove the name environment entry.

Parameters:
name - the environment entry name

putOption

public java.lang.String putOption(java.lang.String name,
                                  java.lang.String value)
Set the environment entry corresponding to the named option to the specified value.

Parameters:
name - the option name
value - the value
Returns:
the previous value of the entry

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
Return a set of all the entries, just like a Map does.


optionToEnv

private java.lang.String optionToEnv(java.lang.String name)
Convert an option name (e.g., "host") to an environment variable name (e.g., AS_ADMIN_HOST).

Parameters:
name - the option name
Returns:
the environment variable name


Copyright © 2012 GlassFish Community. All Rights Reserved.