|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectInterpolationProperties
public class InterpolationProperties
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.
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 |
---|
protected Properties theProperties
Constructor Detail |
---|
public InterpolationProperties(Properties theProperties)
theProperties
- propertiespublic InterpolationProperties(String identifier)
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:
identifier
- string used to construct property file namepublic InterpolationProperties()
Method Detail |
---|
public void setProperty(String propName, String value)
propName
- property namepublic String getProperty(String propName)
propName
- property name
public String interpolate(String input)
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.
properties
- properties to be interpolatedinput
- string on which interpolation is to be performed
protected static Properties loadProperties(String identifier)
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:
identifier
- string used to construct property file name
public static String readAll(InputStream input)
input
- the stream to be read
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |