org.geotools.data.complex.config
Class PropertyInterpolationUtils

java.lang.Object
  extended by org.geotools.data.complex.config.PropertyInterpolationUtils

public class PropertyInterpolationUtils
extends java.lang.Object

Utility methods to support interpolation of properties in a file.

Interpolation means the substitution of a string of the form ${some.property} with the value of the property called "some.property".

Interpolation is performed repeatedly, so can values can contain new interpolations. Infinite loops are supported. This is not a feature.

Author:
Ben Caradoc-Davies, CSIRO Exploration and Mining

Constructor Summary
PropertyInterpolationUtils()
           
 
Method Summary
static java.lang.String interpolate(java.util.Properties properties, java.lang.String input)
          Interpolate all the properties in the input string.
static java.util.Properties loadProperties(java.lang.String identifier)
          Load properties from a configuration file.
static java.lang.String readAll(java.io.InputStream input)
          Read everything from an input stream into a String, reconstructing line endings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyInterpolationUtils

public PropertyInterpolationUtils()
Method Detail

interpolate

public static java.lang.String interpolate(java.util.Properties properties,
                                           java.lang.String input)
Interpolate all the properties in the input string.

Properties are of the form ${some.property}, for which the value of property "some.property" is used.

It is an error for interpolated properties to not exist. A RuntimeException is thrown if the value of a referenced property is null.

Parameters:
properties - properties to be interpolated
input - string on which interpolation is to be performed
Returns:
string with all properties expanded

loadProperties

public static java.util.Properties loadProperties(java.lang.String identifier)
Load properties from a configuration file.

The name of the properties file is constructed by appending ".properties" to the identifier. If there is a system property with the name of this property file, it is used as a file to load, otherwise the property file is loaded from the root of the classpath.

For example, if the identifier is app-schema:

Before the properties are returned, all system properties are copied; this means that system properties override any properties in the configuration file.

Parameters:
identifier - string used to construct property file name
Returns:
loaded properties

readAll

public static java.lang.String readAll(java.io.InputStream input)
Read everything from an input stream into a String, reconstructing line endings.

Parameters:
input - the stream to be read
Returns:
a string that contains the content of input


Copyright © 1996-2010 Geotools. All Rights Reserved.