• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java NamedRenderer类的典型用法和代码示例

java 1次浏览

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

NamedRenderer类属于com.floreysoft.jmte包,在下文中一共展示了NamedRenderer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: resolveNamedRenderer

点赞 2

import com.floreysoft.jmte.NamedRenderer; //导入依赖的package包/类
private NamedRenderer resolveNamedRenderer(TemplateContext context) {
	if (this.rendererName != null && !this.rendererName.equals("")) {
		return context.resolveNamedRenderer(rendererName);
	} else {
		return null;
	}
}
 

开发者ID:DJCordhose,
项目名称:jmte,
代码行数:8,
代码来源:StringToken.java

示例2: resolveNamedRenderer

点赞 2

import com.floreysoft.jmte.NamedRenderer; //导入依赖的package包/类
private NamedRenderer resolveNamedRenderer(TemplateContext context) {
    if (this.rendererName != null && !this.rendererName.equals("")) {
        return context.resolveNamedRenderer(rendererName);
    } else {
        return null;
    }
}
 

开发者ID:DJCordhose,
项目名称:jmte,
代码行数:8,
代码来源:IfCmpRendererToken.java

示例3: evaluate

点赞 2

import com.floreysoft.jmte.NamedRenderer; //导入依赖的package包/类
@Override
public Object evaluate(TemplateContext context) {
    final Object value = evaluatePlain(context);
    final String string;
    final NamedRenderer rendererForName = this.resolveNamedRenderer(context);
    if (rendererForName != null) {
        string = rendererForName.render(value, this.parameters, context.locale, context.model);
    } else {
        string = value == null ? null : value.toString();
    }
    final boolean condition = getOperand().equals(string);
    final Object evaluated = negated ? !condition : condition;
    return evaluated;
}
 

开发者ID:DJCordhose,
项目名称:jmte,
代码行数:15,
代码来源:IfCmpRendererToken.java

示例4: evaluate

点赞 2

import com.floreysoft.jmte.NamedRenderer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object evaluate(TemplateContext context) {
	boolean rawRendering = false;
	final Object value = evaluatePlain(context);

	final String renderedResult;
	if (value == null || value.equals("")) {
		renderedResult = defaultValue != null ? defaultValue : "";
	} else {
		String namedRendererResult = null;
		if (rendererName != null && !rendererName.equals("")) {
			final NamedRenderer rendererForName = context
					.resolveNamedRenderer(rendererName);
			if (rendererForName != null) {
				if (rendererForName instanceof RawRenderer) {
					rawRendering = true;
				}
				namedRendererResult = rendererForName.render(value, parameters, context.locale);
			}
		}
		if (namedRendererResult != null) {
			renderedResult = namedRendererResult;
		} else {
			final Renderer<Object> rendererForClass = (Renderer<Object>) context
					.resolveRendererForClass(value.getClass());
			if (rendererForClass != null) {
				if (rendererForClass instanceof RawRenderer) {
					rawRendering = true;
				}
				renderedResult = rendererForClass.render(value, context.locale);
			} else {
				renderedResult = value.toString();
			}
		}
	}

	if (renderedResult == null || renderedResult.equals("")) {
		return renderedResult;
	} else {
		final String prefixedRenderedResult = (prefix != null ? prefix : "") + renderedResult + (suffix != null ? suffix : "");
		Encoder encoder = context.getEncoder();
		if (!rawRendering && encoder != null) {
			final String encodedPrefixedRenderedResult = encoder.encode(prefixedRenderedResult);
			return encodedPrefixedRenderedResult;
		} else {
			return prefixedRenderedResult;
		}
	}
}
 

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

示例5: evaluate

点赞 2

import com.floreysoft.jmte.NamedRenderer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object evaluate(TemplateContext context) {

	// step 1: get value or default
	final Object value = resolveDefault(evaluatePlain(context));

	// step 2: using named renderer (if present), type renderer (if present), just toString (if not null) or null (in that order)
	// if there is a renderer, determine if it outputs a raw value
	final String renderedResult;
	boolean rawRendering = false;
	final NamedRenderer rendererForName = this.resolveNamedRenderer(context);
	if (rendererForName != null && (value != null || rendererForName instanceof NullRenderer)) {
		if (rendererForName instanceof RawRenderer) {
			rawRendering = true;
		}
		renderedResult = rendererForName.render(value, parameters, context.locale, context.model);
	} else if (value != null) {
		final Renderer<Object> rendererForClass = (Renderer<Object>) context
				.resolveRendererForClass(value.getClass());
		if (rendererForClass != null) {
			if (rendererForClass instanceof RawRenderer) {
				rawRendering = true;
			}
			renderedResult = rendererForClass.render(value, context.locale, context.model);
		} else {
			renderedResult = value.toString();
		}
	} else {
		renderedResult = null;
	}

	// shortcut: if rendered result is empty, do not perform subsequent steps
	if (renderedResult == null || renderedResult.equals("")) {
		return "";
	}

	// step 3: apply prefix / suffix
	final String prefixedRenderedResult = (prefix != null ? prefix : "") + renderedResult + (suffix != null ? suffix : "");

	// step 4: encode if there is an encoder and it is not rendered as raw
	final Encoder encoder = context.getEncoder();
	if (!rawRendering && encoder != null) {
		final String encodedPrefixedRenderedResult = encoder.encode(prefixedRenderedResult);
		return encodedPrefixedRenderedResult;
	} else {
		return prefixedRenderedResult;
	}
}
 

开发者ID:DJCordhose,
项目名称:jmte,
代码行数:50,
代码来源:StringToken.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)