info.jonclark.util
Class PropertyUtils

java.lang.Object
  extended by info.jonclark.util.PropertyUtils

public class PropertyUtils
extends Object

Utilities for working with the java.util.Properties class.

Author:
Jonathan

Constructor Summary
PropertyUtils()
           
 
Method Summary
static Properties getProperties(String path)
           
static void saveProperties(String path, Properties prop)
           
static void validateProperties(Properties props, String[] mandatoryValues)
          Checks to see if a Properties object contains all mandatory values (so that you don't end up with any null Strings)
static
<T> void
validateProperties(Properties props, T[] mandatoryValues)
          Checks to see if a Properties object contains all mandatory values (so that you don't end up with any null Strings)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyUtils

public PropertyUtils()
Method Detail

getProperties

public static Properties getProperties(String path)
                                throws FileNotFoundException,
                                       IOException
Throws:
FileNotFoundException
IOException

validateProperties

public static void validateProperties(Properties props,
                                      String[] mandatoryValues)
                               throws PropertiesException
Checks to see if a Properties object contains all mandatory values (so that you don't end up with any null Strings)

Parameters:
props - The Properties object to be validated
mandatoryValues - A String array with all of the keys that must be contained within the Properties object.
Throws:
PropertiesException

validateProperties

public static <T> void validateProperties(Properties props,
                                          T[] mandatoryValues)
                               throws PropertiesException
Checks to see if a Properties object contains all mandatory values (so that you don't end up with any null Strings)

Parameters:
props - The Properties object to be validated
mandatoryValues - An array of objects whose toString() values must have matching keys contained within the Properties object.
Throws:
PropertiesException

saveProperties

public static void saveProperties(String path,
                                  Properties prop)
                           throws FileNotFoundException,
                                  IOException
Throws:
FileNotFoundException
IOException