org.kuali.ole.utility
Class PropertyUtils

java.lang.Object
  extended by org.kuali.ole.utility.PropertyUtils

public class PropertyUtils
extends Object


Field Summary
static String CR
           
static String ENVIRONMENT_PROPERTY_PREFIX
           
static String LF
           
 
Constructor Summary
protected PropertyUtils()
           
 
Method Summary
protected static void addIfDifferent(String key, String oldValue, String newValue, Properties props)
          If newValue is different than oldValue, add key to the properties using newValue
static String flatten(String s)
          Replace carriage returns with CR.
static Properties getAllProperties(Properties properties)
          Return a properties object that aggregates the properties passed in with environment variables and system properties.
static Properties getAppEnvironmentProperties(List<String> locations)
          Load and resolve properties for an environment.
static Properties getEnvironmentProperties()
          Return environment variables as properties where each property is prefixed with "env"
static List<String> getLocations(String location, String systemProperty, String externalConfigFile)
          Return a list containing a pointer to the location of common properties + the explicit location they specified + the value of the system property (if the system property is set to a valid location)
static List<String> getSortedKeys(Properties properties)
          Return the keys from the properties as a sorted list.
static void overrideProperties(Properties props, String environment)
          Override property values for a given environment.
static void resolveProperties(Properties props)
          Resolve placeholders in the properties.
static boolean validate(String systemProperty)
          Return false if the system property is not set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENVIRONMENT_PROPERTY_PREFIX

public static final String ENVIRONMENT_PROPERTY_PREFIX
See Also:
Constant Field Values

CR

public static final String CR
See Also:
Constant Field Values

LF

public static final String LF
See Also:
Constant Field Values
Constructor Detail

PropertyUtils

protected PropertyUtils()
Method Detail

getLocations

public static final List<String> getLocations(String location,
                                              String systemProperty,
                                              String externalConfigFile)
Return a list containing a pointer to the location of common properties + the explicit location they specified + the value of the system property (if the system property is set to a valid location)


validate

public static final boolean validate(String systemProperty)
Return false if the system property is not set. Return true if the system property is set AND it points to a resource Spring resource loading can understand. Throw an IllegalArgumentException if the system property is set, but the location it points to does not exist.


getAppEnvironmentProperties

public static final Properties getAppEnvironmentProperties(List<String> locations)
                                                    throws IOException
Load and resolve properties for an environment. Properties are loaded from the list of locations. If there are environment specific properties, the default values are overridden with environment specific values. In the properties object returned by this method, any placeholders present in the property values will be fully resolved.

Throws:
IOException

getAllProperties

public static final Properties getAllProperties(Properties properties)
Return a properties object that aggregates the properties passed in with environment variables and system properties. Environment variables are included as properties prefixed with env. If there are duplicate property values, the system property value will always "win".


getSortedKeys

public static final List<String> getSortedKeys(Properties properties)
Return the keys from the properties as a sorted list.


resolveProperties

public static final void resolveProperties(Properties props)
Resolve placeholders in the properties. Properties are always resolved using the properties passed in plus environment variables and system properties.


overrideProperties

public static final void overrideProperties(Properties props,
                                            String environment)
Override property values for a given environment. For example, if batch.size=5 and dev.batch.size=10 are both provided and environment is dev, batch.size will be updated to 10


addIfDifferent

protected static final void addIfDifferent(String key,
                                           String oldValue,
                                           String newValue,
                                           Properties props)
If newValue is different than oldValue, add key to the properties using newValue


flatten

public static final String flatten(String s)
Replace carriage returns with CR. Replace linefeeds with LF.


getEnvironmentProperties

public static final Properties getEnvironmentProperties()
Return environment variables as properties where each property is prefixed with "env"



Copyright © 2004-2013 The Kuali Foundation. All Rights Reserved.