本文整理汇总了Java中com.floreysoft.jmte.Engine.transform方法的典型用法代码示例。如果您正苦于以下问题:Java Engine.transform方法的具体用法?Java Engine.transform怎么用?Java Engine.transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.floreysoft.jmte.Engine
的用法示例。
在下文中一共展示了Engine.transform方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import com.floreysoft.jmte.Engine; //导入方法依赖的package包/类
@Override
public String format(Locale locale) {
final ResourceBundle messages = ResourceBundle.getBundle(baseName, locale);
final String frameTemplate = getTemplate(messages, frameCode, "${prefix} ${location}: ${message}");
final String prefixTemplate = getTemplate(messages, prefixCode, "");
final String locationTemplate = getTemplate(messages, locationCode, "");
final String messageTemplate = getTemplate(messages, messageCode, "");
Engine engine = new Engine();
engine.setErrorHandler(new InternalErrorHandler());
argumentModel.put("prefix", engine.transform(prefixTemplate, argumentModel));
argumentModel.put("location", engine.transform(locationTemplate, argumentModel));
argumentModel.put("message", engine.transform(messageTemplate, argumentModel));
String transformed = engine.transform(frameTemplate, argumentModel);
return transformed;
}
示例2: send
import com.floreysoft.jmte.Engine; //导入方法依赖的package包/类
@Override
public void send(Message message) throws InterruptedException {
Iterator messageFields = message.getFields().entrySet().iterator();
Map<String, Object> model = new HashMap<>();
while (messageFields.hasNext()) {
Map.Entry pair = (Map.Entry) messageFields.next();
model.put(String.valueOf(pair.getKey()), String.valueOf(pair.getValue()));
}
Engine engine = new Engine();
String queryString = engine.transform(configuration.getString(Neo4jOutput.CK_NEO4J_QUERY), model);
List<HashMap<String, String>> query = parseQuery(queryString);
postQuery(query);
}
示例3: formatPlain
import com.floreysoft.jmte.Engine; //导入方法依赖的package包/类
@Override
public String formatPlain(Locale locale) {
final ResourceBundle messages = ResourceBundle.getBundle(baseName, locale);
final String messageTemplate = getTemplate(messages, messageCode, "");
Engine engine = new Engine();
engine.setErrorHandler(new InternalErrorHandler());
String transformed = engine.transform(messageTemplate, argumentModel);
return transformed;
}
示例4: transform
import com.floreysoft.jmte.Engine; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static String transform(File template, File propertiesFile,
String charsetName) throws UnsupportedEncodingException,
FileNotFoundException, IOException {
if (!template.exists()) {
throw new IllegalArgumentException(String.format(
"Tempalte file '%s' does not exist", template
.getCanonicalPath()));
}
if (!propertiesFile.exists()) {
throw new IllegalArgumentException(String.format(
"Properties file '%s' does not exist", propertiesFile
.getCanonicalPath()));
}
FileInputStream stream = null;
try {
String input = Util.fileToString(template, charsetName);
Engine engine = new Engine();
Properties properties = new Properties();
stream = new FileInputStream(propertiesFile);
properties.load(stream);
Map model = properties;
String transformed = engine.transform(input, model);
return transformed;
} finally {
try {
stream.close();
} catch (IOException e) {
}
}
}