org.icenigrid.gridsam.core.hostenv
Class ConfigUtil

java.lang.Object
  extended by org.icenigrid.gridsam.core.hostenv.ConfigUtil

public class ConfigUtil
extends java.lang.Object

Purpose:
A utility class to find out the ConfigUtilProvider and deal with configuration files. Logically a configuration has many items identified by itemID, and each item has some properties in key-value pair format.

Version:
1.0.1 2008-7-11
Author:
Liu Jie, Yongqiang Zou

Constructor Summary
ConfigUtil(java.lang.String configFileName)
          Construct the ConfigUtil object from a config file name.
 
Method Summary
 java.lang.String getConfigFileName()
          Get the config file name.
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Get a property value of the default item.
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue, java.lang.String itemID)
          Get the property value of a specific item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigUtil

public ConfigUtil(java.lang.String configFileName)
           throws JobManagerException
Construct the ConfigUtil object from a config file name.

Parameters:
configFileName - the config file name.
Throws:
JobManagerException - Cannot find 'gridsam.ConfigUtilProvider' from the the common configuration.
Method Detail

getConfigFileName

public java.lang.String getConfigFileName()
Get the config file name.

Returns:
the config file name.

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
                             throws JobManagerException
Get a property value of the default item.

Parameters:
key - the key or name of the property.
defaultValue - the default value of the property.
Returns:
The value of the property, if key don't exist in the config file, return defaultValue.
Throws:
JobManagerException - s

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue,
                                    java.lang.String itemID)
                             throws JobManagerException
Get the property value of a specific item.

Parameters:
key - the key or name of the property.
defaultValue - the default value of the property.
itemID - the itemID to identify the item.
Returns:
The value of the item property, if key don't exist in the config file, return defaultValue.
Throws:
JobManagerException - error happend when read config file.


Copyright © 2008. All Rights Reserved.