本文整理汇总了Java中freemarker.template.TemplateModel.NOTHING属性的典型用法代码示例。如果您正苦于以下问题:Java TemplateModel.NOTHING属性的具体用法?Java TemplateModel.NOTHING怎么用?Java TemplateModel.NOTHING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类freemarker.template.TemplateModel
的用法示例。
在下文中一共展示了TemplateModel.NOTHING属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
@Override
public TemplateModel get(String s) throws TemplateModelException {
Object value = null;
if ("topic".equals(s)) {
value = this.connectRecord.topic();
} else if ("partition".equals(s)) {
value = this.connectRecord.kafkaPartition();
} else if (null != (this.struct.schema().field(s))) {
value = this.struct.get(s);
}
if (null == value) {
return TemplateModel.NOTHING;
}
return wrap(value);
}
示例2: getWrappedObject
/**
* Gets BeanModel from FreeMarker context and returns the object that it wraps.
* @param varName the name of the variable in the FreeMarker context.
* @param env the FreeMarker Environment
*/
public static <T> T getWrappedObject(String varName, Environment env) {
Object obj = null;
try {
obj = env.getVariable(varName);
if (obj != null) {
if (obj == TemplateModel.NOTHING) {
obj = null;
} else if (obj instanceof BeanModel) {
BeanModel bean = (BeanModel) obj;
obj = bean.getWrappedObject();
} else if (obj instanceof SimpleScalar) {
obj = obj.toString();
}
}
} catch (TemplateModelException e) {
Debug.logInfo(e.getMessage(), module);
}
return UtilGenerics.<T>cast(obj);
}
示例3: overrideWithArgs
public static void overrideWithArgs(Map<String, Object> ctx, Map<String, Object> args) {
for (Map.Entry<String, Object> entry: args.entrySet()) {
String key = entry.getKey();
Object obj = entry.getValue();
//if (Debug.infoOn()) Debug.logInfo("in overrideWithArgs, key(3):" + key + " obj:" + obj + " class:" + obj.getClass().getName() , module);
if (obj != null) {
if (obj == TemplateModel.NOTHING) {
ctx.put(key, null);
} else {
Object unwrappedObj = unwrap(obj);
if (unwrappedObj == null) {
unwrappedObj = obj;
}
ctx.put(key, unwrappedObj.toString());
}
} else {
ctx.put(key, null);
}
}
}
示例4: exec
@Override
public Object exec(@SuppressWarnings("rawtypes") List list) throws TemplateModelException
{
RenderContext info = getSectionWriter();
Object wrapped = DeepUnwrap.unwrap((TemplateModel) list.get(0));
String type = list.get(1).toString();
SectionRenderable renderable = getSectionRenderable(info, wrapped, type, factory);
if( renderable == null )
{
return TemplateModel.NOTHING;
}
return renderable;
}
示例5: exec
@Override
public Object exec(List list) throws TemplateModelException
{
if( list.size() != 2 )
{
throw new RuntimeException("Needs a key and a value"); //$NON-NLS-1$
}
String key = (String) DeepUnwrap.unwrap((TemplateModel) list.get(0));
map.put(key, (TemplateModel) list.get(1));
return TemplateModel.NOTHING;
}
示例6: get
@Override
public TemplateModel get(String s) throws TemplateModelException {
Object value = values.get(s);
if (null == value) {
return TemplateModel.NOTHING;
} else {
return wrap(value);
}
}
示例7: unwrap
@SuppressWarnings("unchecked")
public static <T> T unwrap(Object o) {
Object returnObj = null;
if (o == TemplateModel.NOTHING) {
returnObj = null;
} else if (o instanceof SimpleScalar) {
returnObj = o.toString();
} else if (o instanceof BeanModel) {
returnObj = ((BeanModel) o).getWrappedObject();
}
return (T) returnObj;
}