Methods Summary |
---|
public java.lang.Object | getEnvironmentValue(java.lang.String key)returns the envrionment value by the given key
return environments.get(key);
|
public java.util.HashMap | getEnvironments()Returns an iterator over collection of Option objects.
return environments;
|
public static com.sun.enterprise.cli.framework.CommandEnvironment | getInstance()returns the instance of the CommandEnvironment
if (commandEnvironment == null)
{
commandEnvironment = new CommandEnvironment();
}
return commandEnvironment;
|
private java.lang.String | getLocalizedString(java.lang.String key)returns the localized string from framework's LocalStrings.properties.
Calls the LocalStringsManagerFactory.getFrameworkLocalStringsManager()
method, returns "Key not found" if it cannot find the key
try
{
final LocalStringsManager lsm =
LocalStringsManagerFactory.getFrameworkLocalStringsManager();
return lsm.getString(key);
}
catch (CommandValidationException cve)
{
return LocalStringsManager.DEFAULT_STRING_VALUE;
}
|
public int | getNumEnvironments()Returns the number of environments
return environments.size();
|
private java.util.Map | getSystemEnvironment()This method uses System.getenv() (resurrected in jdk 1.5) to gets os environments.
//get environment prefix from CLI Descriptor file.
final CLIDescriptorsReader cdr = CLIDescriptorsReader.getInstance();
String sPrefix = cdr.getEnvironmentPrefix();
//if not specified in descriptor file, then use the default value
sPrefix = sPrefix==null?ENVIRONMENT_PREFIX:sPrefix;
final Map<String, String> mEnv = System.getenv();
HashMap<String, String> hmEnv = new HashMap<String, String>();
final Iterator iterEnv = mEnv.keySet().iterator();
while( iterEnv.hasNext() )
{
final String sEnvKey = ( String )iterEnv.next();
if (sEnvKey.startsWith(sPrefix)) {
//extract the option name and convert it to lower case.
final String sOptionName = sEnvKey.substring(sPrefix.length()).toLowerCase();
//replace occurrences of '_' to '-' since option name can only contain '-'
//this is a CLIP requirement.
hmEnv.put(sOptionName.replace('_",'-"), (String)mEnv.get(sEnvKey));
}
}
return hmEnv;
|
private java.util.Map | getSystemEnvironmentNative()This method gets environment from os system environment
HashMap hashMap = new HashMap();
try
{
CLIDescriptorsReader cdr = CLIDescriptorsReader.getInstance();
String envPrefix = cdr.getEnvironmentPrefix();
//if not specified on descriptor file, then use the default value
envPrefix = envPrefix==null?ENVIRONMENT_PREFIX:envPrefix;
//get Global Env
final String[] strArray = new CliUtil().getEnv(envPrefix);
for (int ii=0; ii<strArray.length; ii++)
{
final int index = strArray[ii].indexOf("=");
// need to break up the string in strArray
// since the format is in name=value
final String sOptionName = strArray[ii].substring(envPrefix.length(),
index).toLowerCase();
hashMap.put( sOptionName.replace('_", '-"),
strArray[ii].substring(index+1));
}
}
catch (java.lang.UnsatisfiedLinkError e)
{
CLILogger.getInstance().printDebugMessage(e.getLocalizedMessage());
// Emit the warning message
CLILogger.getInstance().printWarning(getLocalizedString("UnableToReadEnv"));
}
return hashMap;
|
public java.lang.Object | removeEnvironment(java.lang.String name)This method removes environment
from the environment.
return environments.remove(name);
|
public void | setEnvironment(java.lang.String name, java.lang.String value)This method adds a name and value to the environment.
if ( environments.containsKey(name) )
{
environments.remove( name );
}
environments.put(name, value );
|
public java.lang.String | toString()This method returns a String format for list of environments in the
environment with its argument values.
String description = "";
final Iterator environIter = environments.keySet().iterator();
while( environIter.hasNext() )
{
String environKey = ( String )environIter.next();
description += " " + environKey + " = " +
(String)environments.get(environKey);
}
return description;
|