org.geotools.util
Class InterpolationProperties

Object
  extended by InterpolationProperties

public class InterpolationProperties
extends Object

Stores properties and provides 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 Earth Science and Resource Engineering), Niels Charlier (Curtin University of Technology)

Field Summary
protected  Properties theProperties
          the properties
 
Constructor Summary
InterpolationProperties()
          Create Empty
InterpolationProperties(Properties theProperties)
          Load with existing Properties
InterpolationProperties(String identifier)
          Load properties from a configuration file.
 
Method Summary
 String getProperty(String propName)
          Retrieve Property
 String interpolate(String input)
          Interpolate all the properties in the input string.
protected static Properties loadProperties(String identifier)
          Load properties from a configuration file.
static String readAll(InputStream input)
          Read everything from an input stream into a String, reconstructing line endings.
 void setProperty(String propName, String value)
          Set Property
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theProperties

protected Properties theProperties
the properties

Constructor Detail

InterpolationProperties

public InterpolationProperties(Properties theProperties)
Load with existing Properties

Parameters:
theProperties - properties

InterpolationProperties

public InterpolationProperties(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

InterpolationProperties

public InterpolationProperties()
Create Empty

Method Detail

setProperty

public void setProperty(String propName,
                        String value)
Set Property

Parameters:
propName - property name

getProperty

public String getProperty(String propName)
Retrieve Property

Parameters:
propName - property name
Returns:
property value

interpolate

public String interpolate(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

protected static Properties loadProperties(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 String readAll(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-2014 Geotools. All Rights Reserved.