当前位置: 首页>>代码示例>>Java>>正文


Java Engine.setErrorHandler方法代码示例

本文整理汇总了Java中com.floreysoft.jmte.Engine.setErrorHandler方法的典型用法代码示例。如果您正苦于以下问题:Java Engine.setErrorHandler方法的具体用法?Java Engine.setErrorHandler怎么用?Java Engine.setErrorHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.floreysoft.jmte.Engine的用法示例。


在下文中一共展示了Engine.setErrorHandler方法的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;

}
 
开发者ID:onyxbits,项目名称:Droidentify,代码行数:19,代码来源:ResourceBundleMessage.java

示例2: 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;
}
 
开发者ID:DJCordhose,项目名称:jmte,代码行数:20,代码来源:InterpretedTemplate.java

示例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;
}
 
开发者ID:onyxbits,项目名称:Droidentify,代码行数:11,代码来源:ResourceBundleMessage.java

示例4: 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;
}
 
开发者ID:DJCordhose,项目名称:jmte,代码行数:40,代码来源:InterpretedTemplate.java


注:本文中的com.floreysoft.jmte.Engine.setErrorHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。