class Util {

    public static String evalTokens (String str, Properties props) {
        if (str == null) return str;
        if (props == null) return str;
        String result = str;
        Matcher m = m_substitutePattern.matcher (str);
        while (m.find ()) {
            String subsKey = m.group (1);
            String tgt = TOKEN_BEGIN + subsKey + TOKEN_END;
            String tgtVal = props.getProperty (subsKey);
            if (tgtVal == null) {
                LOGGER.error (MessageFormat.format (
                        "Undefined Rainbow property for token substitution: \"{0}\" in \"{1}\"", subsKey, str));
            }
            else {
                result = result.replace (tgt, tgtVal);
            }
        }
        return result;
    }

}