com.sun.enterprise.admin.cli
Class Environment

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

public final class Environment
extends 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 String PREFIX
           
 
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
 boolean debug()
           
 Set<Map.Entry<String,String>> entrySet()
          Return a set of all the entries, just like a Map does.
 String get(String name)
          Get the named environment entry.
 boolean getBooleanOption(String name)
          Return the value of the environment entry corresponding to the named option.
 File getDebugLogfile()
           
static String getDebugVar()
          Get the name of the environment variable used to set debugging on
 String getStringOption(String name)
          Return the value of the environment entry corresponding to the named option.
 boolean hasOption(String name)
          Is there an environment entry corresponding to the named option?
 String put(String name, String value)
          Set the named environment entry to the specified value.
 String putOption(String name, String value)
          Set the environment entry corresponding to the named option to the specified value.
 void remove(String name)
          Remove the name environment entry.
static void setPrefix(String p)
          Set the prefix for environment variables referenced from the system environment by Environment objects.
static void setShortPrefix(String p)
          Set the short prefix for environment variables referenced from the system enviornment by Environment objects.
 boolean trace()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFIX

public static String PREFIX
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

setPrefix

public static void setPrefix(String p)
Set the prefix for environment variables referenced from the system environment by Environment objects.

Parameters:
p - the new prefix

setShortPrefix

public static void setShortPrefix(String p)
Set the short prefix for environment variables referenced from the system enviornment by Environment objects. This effects methods such as debug(), trace(), etc.


getDebugVar

public static String getDebugVar()
Get the name of the environment variable used to set debugging on


getBooleanOption

public boolean getBooleanOption(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 String getStringOption(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(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 String get(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 String put(String name,
                  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(String name)
Remove the name environment entry.

Parameters:
name - the environment entry name

putOption

public String putOption(String name,
                        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 Set<Map.Entry<String,String>> entrySet()
Return a set of all the entries, just like a Map does.


debug

public boolean debug()

trace

public boolean trace()

getDebugLogfile

public File getDebugLogfile()


Copyright © 2012. All Rights Reserved.