org.jboss.util.property
Class FilePropertyReader

java.lang.Object
  extended byorg.jboss.util.property.FilePropertyReader
All Implemented Interfaces:
PropertyReader (src)
Direct Known Subclasses:
DefaultPropertyReader (src)

public class FilePropertyReader
extends java.lang.Object
implements PropertyReader (src)

Reads properties from one or more files.


Field Summary
protected  java.lang.String[] filenames
          Array of filenames to load properties from
 
Constructor Summary
FilePropertyReader(java.lang.String filename)
          Construct a FilePropertyReader with a single filename to read from.
FilePropertyReader(java.lang.String[] filenames)
          Construct a FilePropertyReader with an array of filenames to read from.
 
Method Summary
protected  java.io.InputStream getInputStream(java.lang.String filename)
          Get an input stream for the given filename.
protected  void loadProperties(java.util.Properties props, java.lang.String filename)
          Load properties from a file into a properties map.
 java.util.Map readProperties()
          Read properties from each specified filename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filenames

protected java.lang.String[] filenames
Array of filenames to load properties from

Constructor Detail

FilePropertyReader

public FilePropertyReader(java.lang.String[] filenames)
Construct a FilePropertyReader with an array of filenames to read from.

Parameters:
filenames - Filenames to load properties from

FilePropertyReader

public FilePropertyReader(java.lang.String filename)
Construct a FilePropertyReader with a single filename to read from.

Parameters:
filename - Filename to load properties from
Method Detail

getInputStream

protected java.io.InputStream getInputStream(java.lang.String filename)
                                      throws java.io.IOException
Get an input stream for the given filename.

Parameters:
filename - File name to get input stream for.
Returns:
Input stream for file.
Throws:
java.io.IOException - Failed to get input stream for file.

loadProperties

protected void loadProperties(java.util.Properties props,
                              java.lang.String filename)
                       throws java.io.IOException
Load properties from a file into a properties map.

Parameters:
props - Properties map to load properties into.
filename - Filename to read properties from.
Throws:
java.io.IOException - Failed to load properties from filename.
java.lang.IllegalArgumentException - Filename is invalid.

readProperties

public java.util.Map readProperties()
                             throws PropertyException (src) ,
                                    java.io.IOException
Read properties from each specified filename

Specified by:
readProperties in interface PropertyReader (src)
Returns:
Read properties
Throws:
PropertyException (src) - Failed to read properties.
java.io.IOException - I/O error while reading properties.