isc.util
Class AppProperties

java.lang.Object
  extended by isc.util.AppProperties

public class AppProperties
extends java.lang.Object

Abstraction class for managing properties.

Author:
John Casey
  • DNA_sensor - Aug 12, 2005

  • Field Summary
    protected  java.lang.String cfgFile
              Config file name default
    protected static java.util.Properties globalProperties
               
    protected static boolean initialized
               
    protected static java.io.FileInputStream inStream
               
     
    Constructor Summary
    AppProperties()
              Create a new AppProperties
    AppProperties(java.lang.String fname)
              Create a new AppProperties with default configuration filename
     
    Method Summary
     java.lang.String getConfigFName()
              Get the name of the current config file
     java.util.Properties getProperties()
              Get all of the properties currently set
     java.lang.String getProperty(java.lang.String key)
              Return the property associated with the key
     java.lang.String getProperty(java.lang.String key, java.lang.String value)
              Return the property associated with the key or default value
    protected  void initialize()
              Initialize this class as static
     boolean isLoaded()
              Check whether this config file has been load into memory
     void load()
              Load the default config file nae
     void load(java.lang.String fname)
              Loads a specified filename containing the properties
     void put(java.lang.String s1, java.lang.String s2)
              Set a property
    protected  void setInStream()
              Open the config file
     void setLoggingProperty(java.lang.String s1, java.lang.String s2)
              Set/reset a log4j property.
    protected  void setSystemProperties()
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    globalProperties

    protected static java.util.Properties globalProperties

    initialized

    protected static boolean initialized

    cfgFile

    protected java.lang.String cfgFile
    Config file name default


    inStream

    protected static java.io.FileInputStream inStream
    Constructor Detail

    AppProperties

    public AppProperties()
    Create a new AppProperties


    AppProperties

    public AppProperties(java.lang.String fname)
    Create a new AppProperties with default configuration filename

    Method Detail

    load

    public void load(java.lang.String fname)
              throws java.lang.Exception
    Loads a specified filename containing the properties

    Parameters:
    fname - Name of the config file
    Throws:
    java.lang.Exception - if not a valid file

    load

    public void load()
              throws java.lang.Exception
    Load the default config file nae

    Throws:
    java.lang.Exception - if the file does not exist

    getProperty

    public java.lang.String getProperty(java.lang.String key)
    Return the property associated with the key

    Parameters:
    key - Key of the property
    Returns:
    The property value

    getProperty

    public java.lang.String getProperty(java.lang.String key,
                                        java.lang.String value)
    Return the property associated with the key or default value

    Parameters:
    key - Key of the property
    Value - Default Value if key does not exist
    Returns:
    The property value

    isLoaded

    public boolean isLoaded()
    Check whether this config file has been load into memory

    Returns:
    True if it has been loaded

    getConfigFName

    public java.lang.String getConfigFName()
    Get the name of the current config file

    Returns:
    The name of the config file

    setInStream

    protected void setInStream()
                        throws java.io.FileNotFoundException
    Open the config file

    Throws:
    java.io.FileNotFoundException - if the file does not exist

    initialize

    protected void initialize()
                       throws java.lang.Exception
    Initialize this class as static

    Throws:
    java.lang.Exception - if it could not be initialized

    put

    public void put(java.lang.String s1,
                    java.lang.String s2)
    Set a property

    Parameters:
    s1 - Hash key of the property
    s2 - property value

    setLoggingProperty

    public void setLoggingProperty(java.lang.String s1,
                                   java.lang.String s2)
    Set/reset a log4j property. Key must begin with "log4j."

    Parameters:
    s1 - Hash key of the log4j property
    s2 - value of the property
    See Also:
    Log4j

    getProperties

    public java.util.Properties getProperties()
    Get all of the properties currently set

    Returns:
    the properties

    setSystemProperties

    protected void setSystemProperties()