fr.paris.lutece.util
Class PropertiesService

java.lang.Object
  extended by fr.paris.lutece.util.PropertiesService

public class PropertiesService
extends java.lang.Object

This class provides utility methods to read values of the properties stored in the .properties file of the application.


Constructor Summary
PropertiesService(java.lang.String strRootPath)
          Constructor should define the base root path for properties files
 
Method Summary
 void addPropertiesDirectory(java.lang.String strRelativePath)
          Add properties from all files found in a given directory
 void addPropertiesFile(java.lang.String strRelativePath, java.lang.String strFilename)
          Add properties from a properties file
 java.lang.String getProperty(java.lang.String strProperty)
          Returns the value of a variable defined in the .properties file of the application as a String
 java.lang.String getProperty(java.lang.String strProperty, java.lang.String strDefault)
          Returns the value of a variable defined in the .properties file of the application as a String
 int getPropertyInt(java.lang.String strProperty, int nDefault)
          Returns the value of a variable defined in the .properties file of the application as an int
 void reload(java.lang.String strFilename)
          Reload a properties file .
 void reloadAll()
          Reload all properties files
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesService

public PropertiesService(java.lang.String strRootPath)
Constructor should define the base root path for properties files

Parameters:
strRootPath - The root path
Method Detail

addPropertiesFile

public void addPropertiesFile(java.lang.String strRelativePath,
                              java.lang.String strFilename)
                       throws java.io.FileNotFoundException,
                              java.io.IOException
Add properties from a properties file

Parameters:
strRelativePath - Relative path from the root path
strFilename - The filename of the properties file (ie: config.properties)
Throws:
java.io.FileNotFoundException - If the file is not found
java.io.IOException - If an error occurs reading the file

addPropertiesDirectory

public void addPropertiesDirectory(java.lang.String strRelativePath)
                            throws java.io.FileNotFoundException,
                                   java.io.IOException
Add properties from all files found in a given directory

Parameters:
strRelativePath - Relative path from the root path
Throws:
java.io.FileNotFoundException - If the file is not found
java.io.IOException - If an error occurs reading the file

reload

public void reload(java.lang.String strFilename)
            throws java.io.FileNotFoundException,
                   java.io.IOException
Reload a properties file .

Parameters:
strFilename - The filename of the properties file
Throws:
java.io.FileNotFoundException - If the file is not found
java.io.IOException - If an error occurs reading the file

reloadAll

public void reloadAll()
               throws java.io.FileNotFoundException,
                      java.io.IOException
Reload all properties files

Throws:
java.io.FileNotFoundException - If the file is not found
java.io.IOException - If an error occurs reading the file

getProperty

public java.lang.String getProperty(java.lang.String strProperty)
Returns the value of a variable defined in the .properties file of the application as a String

Parameters:
strProperty - The variable name
Returns:
The variable value read in the properties file

getProperty

public java.lang.String getProperty(java.lang.String strProperty,
                                    java.lang.String strDefault)
Returns the value of a variable defined in the .properties file of the application as a String

Parameters:
strProperty - The variable name
strDefault - The default value which is returned if no value is found for the variable in the .properties file.
Returns:
The variable value read in the properties file

getPropertyInt

public int getPropertyInt(java.lang.String strProperty,
                          int nDefault)
Returns the value of a variable defined in the .properties file of the application as an int

Parameters:
strProperty - The variable name
nDefault - The default value which is returned if no value is found for the variable in the le downloadFile .properties. .properties file.
Returns:
The variable value read in the properties file


Copyright © 2007 Mairie de Paris. All Rights Reserved.