Hi,

Theres this code segment in org.wso2.carbon.email.sender component.

public static String replacePlaceHolders(String text, Map<String, String>
userParameters) {
        if (userParameters != null) {
            for (Map.Entry<String, String> entry :
userParameters.entrySet()) {
                String key = entry.getKey();
                *text = text.replaceAll("\\{" + key + "\\}",
entry.getValue());*
            }
        }
        return text;
    }


Above String.replaceAll() method throws exceptions when there are special
characters in the string which is being replaced with. i.e. In the above
sample it is entry.getValue(). An example is the $ sign. This can be avoided
by using \\$. But it is a headache.

Instead, String.replace() can be used and* it too replaces all the
occurrences* of the string being replaced. i.e. We can use

*text = text.replace("{" + key + "}", entry.getValue());

*Therefore, is it ok that I change the above method with the latter
mentioned one.

Thanks,
AmilaM.
*
*
_______________________________________________
Carbon-dev mailing list
Carbon-dev@wso2.org
http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev

Reply via email to