Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

hk.hku.cecid.phoenix.common.util
Class Property  view Property download Property.java

java.lang.Object
  extended byhk.hku.cecid.phoenix.common.util.Property
Direct Known Subclasses:
TextProperty, XMLProperty

public abstract class Property
extends java.lang.Object

This is an abstract class for property file reader. We may implement XML based, or plain text based, or encrypted property file reader out of this abstract class. This interface is defining some common methods needed by all kinds of property readers.

Version:
$Revision: 1.14 $

Field Summary
protected  java.util.Hashtable cache
          Cache of property values
protected static java.lang.String DEFAULT_FILENAME
          Default file name of property file
private static java.util.Hashtable loadedProps
          Singleton instance of text property object for each location
protected static java.lang.String PROP_HOME
          System property name for location property file
 
Constructor Summary
(package private) Property()
          Default constructor
 
Method Summary
abstract  java.lang.String get(java.lang.String path)
          Gets the property value given the path (key).
abstract  java.lang.String get(java.lang.String path, java.lang.String defaultValue)
          Gets the property value given the path (key).
protected  java.lang.String getFromCache(java.lang.String path)
          Gets the property value from cache.
abstract  java.lang.String[] getMultiple(java.lang.String path)
          Gets the property value given the path (key).
static Property load()
          Loads the default property object out of the default location.
static Property load(java.lang.String location)
          Loads the property object out of a given location.
protected static Property loadFromFullPath(java.lang.String location)
          Loads the property file based on a full path.
 void reload()
          Reloads the property file.
static Property reload(java.lang.String location)
          Reloads the property object out of a given location.
protected  void removeFromCache(java.lang.String path)
          Removes the property value from cache.
abstract  void save()
          Saves the property object to the same location when loading.
abstract  void save(java.lang.String location)
          Saves the property object to the specified location.
protected  void saveToCache(java.lang.String path, java.lang.String value)
          Saves the property value to cache.
abstract  void set(java.lang.String path, java.lang.String value)
          Sets the property value of the given path (key).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loadedProps

private static java.util.Hashtable loadedProps
Singleton instance of text property object for each location


cache

protected java.util.Hashtable cache
Cache of property values


PROP_HOME

protected static final java.lang.String PROP_HOME
System property name for location property file

See Also:
Constant Field Values

DEFAULT_FILENAME

protected static final java.lang.String DEFAULT_FILENAME
Default file name of property file

See Also:
Constant Field Values
Constructor Detail

Property

Property()
Default constructor

Method Detail

getFromCache

protected java.lang.String getFromCache(java.lang.String path)
Gets the property value from cache. Try to see if the property value has been retrieved previously.


saveToCache

protected void saveToCache(java.lang.String path,
                           java.lang.String value)
Saves the property value to cache.


removeFromCache

protected void removeFromCache(java.lang.String path)
Removes the property value from cache.


reload

public void reload()
Reloads the property file.


getMultiple

public abstract java.lang.String[] getMultiple(java.lang.String path)
Gets the property value given the path (key). Multiple values are referenced by the same path will be returned using a String array.


get

public abstract java.lang.String get(java.lang.String path)
Gets the property value given the path (key).


get

public abstract java.lang.String get(java.lang.String path,
                                     java.lang.String defaultValue)
Gets the property value given the path (key). If the property value is not found, the default value passed in is returned.


set

public abstract void set(java.lang.String path,
                         java.lang.String value)
Sets the property value of the given path (key).


save

public abstract void save()
                   throws java.io.IOException
Saves the property object to the same location when loading.


save

public abstract void save(java.lang.String location)
                   throws java.io.IOException
Saves the property object to the specified location.


load

public static Property load()
                     throws java.io.IOException
Loads the default property object out of the default location. The default filename is phoenix.properties.xml. We search for the default properties file in the following locations in that order: 1. The directory pointed by the system property prop.home 2. The directories in classpath 3. The current working directory 4. The current user's home directory


reload

public static Property reload(java.lang.String location)
                       throws java.io.IOException
Reloads the property object out of a given location. The property object will be reloaded even if it has been cached before. Currently only 2 types of property objects are supported: text-based and XML-based. The location is interpreted as file path in both cases. We search for the properties file in the following locations in that order: 1. The directory pointed by the system property prop.home 2. The directories in classpath 3. The current working directory 4. See if the location is a full path 5. The current user's home directory


load

public static Property load(java.lang.String location)
                     throws java.io.IOException
Loads the property object out of a given location. Currently only 2 types of property objects are supported: text-based and XML-based. The location is interpreted as file path in both cases. We search for the properties file in the following locations in that order: 1. The directory pointed by the system property prop.home 2. The directories in classpath 3. The current working directory 4. See if the location is a full path 5. The current user's home directory


loadFromFullPath

protected static Property loadFromFullPath(java.lang.String location)
                                    throws java.io.IOException
Loads the property file based on a full path. This function will dispatch the Property file type by the extension of the specified path.