com.terapico.utils.MessageTemplateUtil Maven / Gradle / Ivy
The newest version!
package com.terapico.utils;
import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class MessageTemplateUtil {
public static class MessageTemplate {
protected Map declaration;
protected String template;
protected Map i18nTemplates;
public Map getDeclaration() {
return declaration;
}
public void setDeclaration(Map declaration) {
this.declaration = declaration;
}
public String getTemplate() {
return template;
}
public void setTemplate(String tempalte) {
this.template = tempalte;
}
public Map getI18nTemplates() {
return i18nTemplates;
}
public void setI18nTemplates(Map i18nTemplates) {
this.i18nTemplates = i18nTemplates;
}
}
protected static Map templates;
protected static Date loadedTime;
public static String getMessage(String templateName, Locale language, Map params) {
ensureTemplates();
MessageTemplate tmpl = templates.get(templateName);
if (tmpl == null) {
throw new RuntimeException("Template ["+templateName+"] not defined");
}
String templateStr = findTemplateString(tmpl, language);
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy