simple.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 simple.util.FileProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class FileProperties
extends java.util.Properties

The FileProperties object is used as a convienience class that is used to create a Properties object from a file path. This will automatically load the Java property file once instantiated. This is used so that the creation and use of a java.util.Properties file is much cleaner.

Author:
Niall Gallagher
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
FileProperties(java.io.File source)
          Constructor for the FileProperties object.
FileProperties(java.io.File base, java.lang.String source)
          Constructor for the FileProperties object.
FileProperties(java.lang.String source)
          Constructor for the FileProperties object.
 
Method Summary
 void load(java.io.InputStream source)
          This overloads the Properties.load so that XML properties can be loaded as well as standard properties.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
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
 

Constructor Detail

FileProperties

public FileProperties(java.lang.String source)
               throws java.io.IOException
Constructor for the FileProperties object. The constructor will use the specified file as the contents of its properties. The file name should be absolute, and in an OS specific format. For example "C:\data.properties" on a Windows filesystem, and "/pub/bin/data.properties" on UNIX.

Parameters:
source - this is the file that contains the properties
Throws:
java.io.IOException - if the properties can not be loaded

FileProperties

public FileProperties(java.io.File base,
                      java.lang.String source)
               throws java.io.IOException
Constructor for the FileProperties object. The constructor will use the specified base path to load the named properties file from. The file name given should be relative to the issued base path. This is a convinience method that enables the Java properties file to be loaded without the need to specify an OS specific file path.

Parameters:
base - this is the directory to loade the file from
source - this is the file that contains the properties
Throws:
java.io.IOException - if the properties can not be loaded

FileProperties

public FileProperties(java.io.File source)
               throws java.io.IOException
Constructor for the FileProperties object. The constructor will use the specified file as the contents of its properties. The file name should be absolute, and in an OS specific format. For example "C:\data.properties" on a Windows filesystem, and "/pub/bin/data.properties" on UNIX.

Parameters:
source - this is the file that contains the properties
Throws:
java.io.IOException - if the properties can not be loaded
Method Detail

load

public void load(java.io.InputStream source)
          throws java.io.IOException
This overloads the Properties.load so that XML properties can be loaded as well as standard properties. Once this method is invoked the stream is examined to see if the properties format is in XML. If the file is a valid XML file then the properties are loaded int he XML format. Otherwise they are loaded using the traditional format.

Overrides:
load in class java.util.Properties
Parameters:
source - the stream that contains the properties
Throws:
java.io.IOException