本文整理汇总了Java中com.floreysoft.jmte.Engine类的典型用法代码示例。如果您正苦于以下问题:Java Engine类的具体用法?Java Engine怎么用?Java Engine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Engine类属于com.floreysoft.jmte包,在下文中一共展示了Engine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ConfigServer
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
@Inject
public ConfigServer(HBaseFrameworkConfig hbaseFrameworkConfig,
IPersistentStateStore persistenceStore) {
this.hbaseFrameworkConfig = hbaseFrameworkConfig;
this.persistenceStore = persistenceStore;
engine = new Engine();
server = new Server(hbaseFrameworkConfig.getConfigServerPort());
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(hbaseFrameworkConfig.getExecutorPath());
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{
resourceHandler, new ServeHbaseConfigHandler()});
server.setHandler(handlers);
try {
server.start();
} catch (Exception e) {
final String msg = "Unable to start jetty server";
log.error(msg, e);
throw new ConfigServerException(msg, e);
}
}
示例2: 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;
}
示例3: getStaticErrors
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
@Override
public List<ErrorEntry> getStaticErrors() {
final Engine engine = new Engine();
final JournalingErrorHandler errorHandler = new JournalingErrorHandler();
engine.setErrorHandler(errorHandler);
final ScopedMap scopedMap = new ScopedMap(Collections.EMPTY_MAP);
final Locale locale = Locale.getDefault();
this.context = new TemplateContext(this.template, locale, this.sourceName, scopedMap,
new DefaultModelAdaptor(), engine, errorHandler, null);
transformPure(this.context);
final List<ErrorEntry> staticErrors = new ArrayList<>();
for (ErrorEntry entry: errorHandler.entries) {
if (entry.errorMessage.isStatic) {
staticErrors.add(entry);
}
}
return staticErrors;
}
示例4: 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);
}
示例5: 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;
}
示例6: InterpretedTemplate
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
public InterpretedTemplate(String template, String sourceName, Engine engine) {
this.template = template;
this.engine = engine;
this.sourceName = sourceName;
tokenStream = new TokenStream(sourceName, template, engine
.getExprStartToken(), engine.getExprEndToken());
tokenStream.prefill();
}
示例7: 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) {
}
}
}
示例8: getUsedVariableDescriptions
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
@Override
public List<VariableDescription> getUsedVariableDescriptions() {
final List<VariableDescription> variableDescriptions = new ArrayList<>();
final Engine engine = new Engine();
engine.setErrorHandler(new JournalingErrorHandler());
final ScopedMap scopedMap = new ScopedMap(Collections.EMPTY_MAP);
final ProcessListener processListener = new ProcessListener() {
@Override
public void log(TemplateContext context, Token token, Action action) {
if (token instanceof ExpressionToken) {
final String name = ((ExpressionToken) token).getExpression();
String renderer = null;
String pattern = null;
VariableDescription.Context variableContext = null;
if (token instanceof StringToken) {
renderer = ((StringToken) token).getRendererName();
pattern = ((StringToken) token).getParameters();
variableContext = VariableDescription.Context.TEXT;
} else if (token instanceof IfToken) {
variableContext = VariableDescription.Context.IF;
} else if (token instanceof ForEachToken) {
variableContext = VariableDescription.Context.FOR_EACH;
}
if (!InterpretedTemplate.isLocal(context, name)) {
variableDescriptions.add(new VariableDescription(name, renderer, pattern, variableContext));
}
}
}
};
final Locale locale = Locale.getDefault();
this.context = new TemplateContext(this.template, locale, this.sourceName, scopedMap,
new DefaultModelAdaptor(), engine, engine.getErrorHandler(), processListener);
transformPure(this.context);
return variableDescriptions;
}
示例9: init
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.audit4j.core.Initializable#init()
*/
@Override
public void init() throws InitializationException {
engine = Engine.createCachingEngine();
JMTEDateRendrer dateRendrer = new JMTEDateRendrer();
dateRendrer.setDateFormat(dateFormat);
engine.registerRenderer(Date.class, dateRendrer);
}
示例10: MediaEntityExporter
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
protected MediaEntityExporter(Path templatePath, TemplateType type) throws Exception {
templateDir = templatePath;
// check if template exists and is valid
if (!Files.isDirectory(templateDir)) {
throw new Exception("illegal template path");
}
Path configFile = templateDir.resolve("template.conf");
if (!Files.exists(configFile)) {
throw new Exception("illegal template config");
}
// load settings from template
properties = new Properties();
BufferedInputStream stream = new BufferedInputStream(new FileInputStream(configFile.toFile()));
properties.load(stream);
stream.close();
// check needed settings
String typeInConfig = properties.getProperty("type");
if (!typeInConfig.equalsIgnoreCase(type.name())) {
throw new Exception("illegal template");
}
String listTemplateFile = properties.getProperty("list");
if (StringUtils.isBlank(listTemplateFile)) {
throw new Exception("illegal template");
}
// get other settings
String detailTemplateFile = properties.getProperty("detail");
fileExtension = properties.getProperty("extension");
if (StringUtils.isBlank(fileExtension)) {
fileExtension = "html";
}
// set up engine
engine = Engine.createCachingEngine();
if (fileExtension.equalsIgnoreCase("html")) {
engine.setEncoder(new HtmlEncoder()); // special char replacement
}
if (fileExtension.equalsIgnoreCase("xml")) {
engine.setEncoder(new XMLEncoder()); // special char replacement
}
// load list template from File
listTemplate = Utils.readFileToString(templateDir.resolve(listTemplateFile));
if (StringUtils.isNotBlank(detailTemplateFile)) {
detailTemplate = Utils.readFileToString(templateDir.resolve(detailTemplateFile));
}
}
示例11: AbstractCompiledTemplate
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
public AbstractCompiledTemplate(Engine engine) {
this.engine = engine;
}
示例12: setEngine
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
public void setEngine(Engine engine) {
this.engine = engine;
}
示例13: getEngine
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
public Engine getEngine() {
return engine;
}
示例14: SlackAlarmCallback
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
@Inject
public SlackAlarmCallback(Engine templateEngine) {
this.templateEngine = templateEngine;
}
示例15: setUp
import com.floreysoft.jmte.Engine; //导入依赖的package包/类
@Before
public void setUp() {
alarmCallback = new SlackAlarmCallback(Engine.createDefaultEngine());
}