Class MCRTextResolver

java.lang.Object
org.mycore.common.MCRTextResolver
Direct Known Subclasses:
MCRPropertiesResolver

public class MCRTextResolver extends Object

This class parses and resolve strings which contains variables. To add a variable call addVariable.

The algorithm is optimized that each character is touched only once.

To resolve a string a valid syntax is required:

{}: Use curly brackets for variables or properties. For example "{var1}" or "{MCR.basedir}"

[]: Use squared brackets to define a condition. All data within squared brackets is only used if the internal variables are not null and not empty. For example "[hello {lastName}]" is only resolved if the value of "lastName" is not null and not empty. Otherwise the whole content in the squared brackets are ignored.

\: Use the escape character to use all predefined characters.

Sample:
"Lastname: {lastName}[, Firstname: {firstName}]"

Author:
Matthias Eichner