org.ow2.petals.component.framework.api.util
Class PropertiesUtil

java.lang.Object
  extended by org.ow2.petals.component.framework.api.util.PropertiesUtil

public class PropertiesUtil
extends Object

Utility to handle a CDK properties file.

Since:
1.0
Author:
ofabre - EBM Websourcing

Constructor Summary
PropertiesUtil()
           
 
Method Summary
static List<String> extractPlaceHolderKeys(String entryValue)
           
static void fillPlaceHolder(Properties fromProperties, Map<String,String> extensions)
           Replace place holders in the toProperties Properties object by values found in fromProperties Properties object.
static String fillPlaceHolder(String entryValue, List<String> placeHolderKeys, Properties fromProperties)
           
static void fillPlaceHolder(String propertiesFilePath, Map<String,String> extensions)
           Replace place holders in the toProperties Properties object by values found in external properties file denoted by the given propertiesFilePath.
static Properties loadProperties(String propertiesFilePath)
           Load a Properties object from a properties file path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesUtil

public PropertiesUtil()
Method Detail

loadProperties

public static final Properties loadProperties(String propertiesFilePath)
                                       throws PEtALSCDKException

Load a Properties object from a properties file path. The file path can be relative path based on Petals root path or a valid URL.

Exemples :
Relative path : /conf/external.properties
Absolute path : file:///C:/conf/external.properties
URL : ftp://user:pwd@host:port/external.properties

Parameters:
propertiesFilePath - The file path can be relative path based on Petals root path or a valid URL
Returns:
a Properties object fill with properties value found in the targeted file
Throws:
PEtALSCDKException - if error occurs when reading external properties file

fillPlaceHolder

public static void fillPlaceHolder(String propertiesFilePath,
                                   Map<String,String> extensions)
                            throws PEtALSCDKException

Replace place holders in the toProperties Properties object by values found in external properties file denoted by the given propertiesFilePath. Place holders look like : ${property.name.in.fromProperties.object}

Exemple :
toProperties property place holder : ${foo.bar}
External properties file property : foo.bar
Property with value ${foo.bar} in toProperties object will be overiden by the value of foo.bar property of the external properties file

Parameters:
propertiesFilePath - The file path can be relative path based on Petals root path or a valid URL

Exemples :
Relative path : /conf/external.properties
Absolute path : file:///C:/conf/external.properties
URL : ftp://user:pwd@host:port/external.properties

toProperties - a Map instance with some place holder as value to replace
Throws:
PEtALSCDKException - if error occurs when reading external properties file or if a property specified in toProperties cannot be found in external properties file

fillPlaceHolder

public static void fillPlaceHolder(Properties fromProperties,
                                   Map<String,String> extensions)

Replace place holders in the toProperties Properties object by values found in fromProperties Properties object. Place holders look like : ${property name in fromProperties object}

Exemple :
toProperties property place holder : ${foo.bar}
fromProperties property : foo.bar
Property with value ${foo.bar} in toProperties object will be overiden by the value of foo.bar property of the fromProperties object

Parameters:
fromProperties - properties that will replace place holders in toProperties object
toProperties - a Map instance with some place holder as value to replace
Throws:
PEtALSCDKException - if a property specified in toProperties cannot be found in fromProperties

extractPlaceHolderKeys

public static List<String> extractPlaceHolderKeys(String entryValue)

fillPlaceHolder

public static String fillPlaceHolder(String entryValue,
                                     List<String> placeHolderKeys,
                                     Properties fromProperties)


Copyright © 2005-2012 Petals Link (EBM Websourcing). All Rights Reserved.