com.continuent.tungsten.common.commands
Class PropertyCommands

java.lang.Object
  extended by com.continuent.tungsten.common.commands.PropertyCommands

public class PropertyCommands
extends java.lang.Object

Methods to help loading manipulating a propertlies file

Version:
1.0
Author:
Joe Daly

Constructor Summary
PropertyCommands()
           
 
Method Summary
static java.util.Properties readPropertyFile(java.lang.String propertyFile)
          Loads a property file that in name=value.
static boolean updatePropertyInPropertyFile(java.lang.String property, java.lang.String value, java.lang.String propertyFile, boolean keepBackup, boolean add)
          Updates a property in a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyCommands

public PropertyCommands()
Method Detail

readPropertyFile

public static java.util.Properties readPropertyFile(java.lang.String propertyFile)
                                             throws java.lang.Exception
Loads a property file that in name=value. This is used rather then using the Properties.load(InputStream inStream) to allow paths on windows to be loaded without having to add \\ for paths.

Parameters:
propertyFile - the property file to read in.
Returns:
a listing of properties for the given property file
Throws:
java.lang.Exception - if the property file can not be loaded

updatePropertyInPropertyFile

public static boolean updatePropertyInPropertyFile(java.lang.String property,
                                                   java.lang.String value,
                                                   java.lang.String propertyFile,
                                                   boolean keepBackup,
                                                   boolean add)
                                            throws java.lang.Exception
Updates a property in a file.

Parameters:
property - the property to update
value - the value to update to
propertyFile - the file path
keepBackup - if an update was done, keep the old copy around
add - if the property does not exist append to the end of the file
Returns:
true if the file was update, false if the property did not exist and no update was done
Throws:
java.lang.Exception