Oracle

com.compoze.util
Class FileProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by com.compoze.util.ObjectProperties
                  extended by com.compoze.util.MutableProperties
                      extended by com.compoze.util.FileProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class FileProperties
extends MutableProperties
implements java.io.Serializable

A Properties object that gets its Properties from a file. It checks on the fly to see if the file has been modified to re-read the Properties.

See Also:
Properties, Serialized Form

Field Summary
protected static int DEFAULT_CHECK_INTERVAL
           
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
FileProperties(java.io.File propsFile)
          Constructor.
FileProperties(java.io.File propsFile, long lPropsFileCheckInterval)
          Constructor.
FileProperties(java.io.File propsFile, long lPropsFileCheckInterval, java.util.Properties defaults)
          Constructor.
FileProperties(java.io.File propsFile, java.util.Properties defaults)
          Constructor.
 
Method Summary
 java.lang.String getProperty(java.lang.String sKey)
          Get a property.
 java.lang.String getProperty(java.lang.String sKey, java.lang.String sDefaultValue)
          Get a property.
 void list(java.io.PrintStream out)
          Prints this property list out to the specified output stream.
 void list(java.io.PrintWriter writer)
          Prints this property list out to the specified output stream.
static void main(java.lang.String[] args)
          Exerciser.
 java.util.Enumeration propertyNames()
          Get an Enumeration of the property names.
 void refresh()
          Force a re-load of the properties.
 void setCheckInterval(long lCheckInterval)
          Set the check for updates interval for the file.
 
Methods inherited from class com.compoze.util.MutableProperties
setConfiguration
 
Methods inherited from class com.compoze.util.ObjectProperties
getBoolean, getBoolean, getByte, getByte, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, getString, getString, getStringArray, getStringArray, getStringArray, replaceSubstitutions
 
Methods inherited from class java.util.Properties
load, loadFromXML, save, setProperty, store, storeToXML, storeToXML
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CHECK_INTERVAL

protected static final int DEFAULT_CHECK_INTERVAL
See Also:
Constant Field Values
Constructor Detail

FileProperties

public FileProperties(java.io.File propsFile,
                      long lPropsFileCheckInterval)
Constructor.

Parameters:
propsFile - the file from which the Properties are read
lPropsFileCheckInterval - a checking interval (in milliseconds) for the file

FileProperties

public FileProperties(java.io.File propsFile,
                      long lPropsFileCheckInterval,
                      java.util.Properties defaults)
Constructor.

Parameters:
propsFile - the file from which the Properties are read
lPropsFileCheckInterval - a checking interval (in milliseconds) for the file
defaults - a list of defaults used when a Property is not found

FileProperties

public FileProperties(java.io.File propsFile)
Constructor.

Parameters:
propsFile - the file from which the Properties are read

FileProperties

public FileProperties(java.io.File propsFile,
                      java.util.Properties defaults)
Constructor.

Parameters:
propsFile - the file from which the Properties are read
defaults - a list of defaults used when a Property is not found
Method Detail

setCheckInterval

public void setCheckInterval(long lCheckInterval)
Set the check for updates interval for the file. The properties file will not be checked more than once during the specified interval.

Parameters:
lCheckInterval - interval to check (in milliseconds)

getProperty

public java.lang.String getProperty(java.lang.String sKey)
Get a property.

Overrides:
getProperty in class MutableProperties
Parameters:
sKey - the key to get the property for
Returns:
the value

getProperty

public java.lang.String getProperty(java.lang.String sKey,
                                    java.lang.String sDefaultValue)
Get a property.

Overrides:
getProperty in class MutableProperties
Parameters:
sKey - the key to get the property for
sDefaultValue - the default value in case the key is not found
Returns:
the value

list

public void list(java.io.PrintStream out)
Prints this property list out to the specified output stream. This method is useful for debugging.

Overrides:
list in class java.util.Properties
Parameters:
out - the PrintStream to write to

list

public void list(java.io.PrintWriter writer)
Prints this property list out to the specified output stream. This method is useful for debugging.

Overrides:
list in class java.util.Properties
Parameters:
writer - the Writer to write to

propertyNames

public java.util.Enumeration propertyNames()
Get an Enumeration of the property names.

Overrides:
propertyNames in class MutableProperties
Returns:
an enumeration of all the keys in this property list, including the keys in the default property list

refresh

public void refresh()
Force a re-load of the properties.


main

public static void main(java.lang.String[] args)
Exerciser.

Parameters:
args - arguments - first is properties file and each additional is a key

Oracle

Copyright ©1999-2008 Oracle All rights reserved.