本文整理了Java中freemarker.ext.util.WrapperTemplateModel
类的一些代码示例,展示了WrapperTemplateModel
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WrapperTemplateModel
类的具体详情如下:
包路径:freemarker.ext.util.WrapperTemplateModel
类名称:WrapperTemplateModel
[英]A generic interface for template models that wrap some underlying object, and wish to provide access to that wrapped object.
You may also want to implement freemarker.template.AdapterTemplateModel.
[中]一个通用接口,用于包装一些底层对象的模板模型,并希望提供对该包装对象的访问。
您可能还想实现freemarker。样板AdapterTemplateModel。
代码示例来源:origin: org.freemarker/freemarker
public static boolean isWrappedIterable(TemplateModel model) {
return model instanceof WrapperTemplateModel
&& ((WrapperTemplateModel) model).getWrappedObject() instanceof Iterable;
}
代码示例来源:origin: org.freemarker/freemarker
private static Class getUnwrappedClass(TemplateModel tm) {
Object unwrapped;
try {
if (tm instanceof WrapperTemplateModel) {
unwrapped = ((WrapperTemplateModel) tm).getWrappedObject();
} else if (tm instanceof AdapterTemplateModel) {
unwrapped = ((AdapterTemplateModel) tm).getAdaptedObject(Object.class);
} else {
unwrapped = null;
}
} catch (Throwable e) {
unwrapped = null;
}
return unwrapped != null ? unwrapped.getClass() : null;
}
代码示例来源:origin: org.freemarker/freemarker
return ((WrapperTemplateModel) tm).getWrappedObject();
代码示例来源:origin: org.freemarker/freemarker
Object wrapped = ((WrapperTemplateModel) model).getWrappedObject();
if (targetClass == Object.class || targetClass.isInstance(wrapped)) {
return wrapped;
代码示例来源:origin: org.freemarker/freemarker
return ((WrapperTemplateModel) model).getWrappedObject();
代码示例来源:origin: org.freemarker/freemarker
return Py.java2py(((WrapperTemplateModel) model).getWrappedObject());
代码示例来源:origin: org.freemarker/freemarker-gae
public static boolean isWrappedIterable(TemplateModel model) {
return model instanceof WrapperTemplateModel
&& ((WrapperTemplateModel) model).getWrappedObject() instanceof Iterable;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
public static boolean isWrappedIterable(TemplateModel model) {
return model instanceof WrapperTemplateModel
&& ((WrapperTemplateModel) model).getWrappedObject() instanceof Iterable;
}
代码示例来源:origin: gabrie-allaigre/sonar-gitlab-plugin
private Object execOneArg(Object arg) throws TemplateModelException {
if (arg instanceof WrapperTemplateModel && ((WrapperTemplateModel) arg).getWrappedObject() instanceof Map) {
Map<String, Object> map = (Map<String, Object>) ((WrapperTemplateModel) arg).getWrappedObject();
return markDownUtils.printIssue((Severity) (map.get("severity")), (String) map.get("message"), (String) map.get("ruleLink"), (String) map.get("url"), (String) map.get("componentKey"));
}
throw new TemplateModelException("Failed call accept 1 issue arg");
}
}
代码示例来源:origin: org.freemarker/freemarker-gae
private static Class getUnwrappedClass(TemplateModel tm) {
Object unwrapped;
try {
if (tm instanceof WrapperTemplateModel) {
unwrapped = ((WrapperTemplateModel) tm).getWrappedObject();
} else if (tm instanceof AdapterTemplateModel) {
unwrapped = ((AdapterTemplateModel) tm).getAdaptedObject(Object.class);
} else {
unwrapped = null;
}
} catch (Throwable e) {
unwrapped = null;
}
return unwrapped != null ? unwrapped.getClass() : null;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
private static Class getUnwrappedClass(TemplateModel tm) {
Object unwrapped;
try {
if (tm instanceof WrapperTemplateModel) {
unwrapped = ((WrapperTemplateModel) tm).getWrappedObject();
} else if (tm instanceof AdapterTemplateModel) {
unwrapped = ((AdapterTemplateModel) tm).getAdaptedObject(Object.class);
} else {
unwrapped = null;
}
} catch (Throwable e) {
unwrapped = null;
}
return unwrapped != null ? unwrapped.getClass() : null;
}
代码示例来源:origin: com.hazelcast.simulator/simulator
@Override
@SuppressWarnings("unchecked")
public Object exec(List list) throws TemplateModelException {
if (list.size() != 2) {
throw new TemplateModelException("Wrong number of arguments for method isAssignableFrom()."
+ " Method has two required parameters: [Class, Class]. Found: " + list.size());
}
Object arg1 = ((WrapperTemplateModel) list.get(0)).getWrappedObject();
if (!(arg1 instanceof Class)) {
throw new TemplateModelException("Wrong type of the first parameter."
+ " It should be Class. Found: " + arg1.getClass());
}
Object arg2 = ((WrapperTemplateModel) list.get(1)).getWrappedObject();
if (!(arg2 instanceof Class)) {
throw new TemplateModelException("Wrong type of the second parameter."
+ " It should be Class. Found: " + arg2.getClass());
}
return ((Class) arg2).isAssignableFrom((Class) arg1);
}
}
代码示例来源:origin: com.hazelcast.simulator/simulator
@Override
public Object exec(List list) throws TemplateModelException {
if (list.size() != 1) {
throw new TemplateModelException("Wrong number of arguments for method hasProbe()."
+ " Method has one required parameter: [Method]. Found: " + list.size());
}
Object arg1 = ((WrapperTemplateModel) list.get(0)).getWrappedObject();
if (!(arg1 instanceof Method)) {
throw new TemplateModelException("Wrong type of the first parameter."
+ " It should be Method. Found: " + arg1.getClass());
}
Method method = (Method) arg1;
for (Class paramType : method.getParameterTypes()) {
if (Probe.class.isAssignableFrom(paramType)) {
return true;
}
}
return false;
}
}
代码示例来源:origin: com.hazelcast.simulator/simulator
@Override
@SuppressWarnings("unchecked")
public Object exec(List list) throws TemplateModelException {
if (list.size() != 2) {
throw new TemplateModelException("Wrong number of arguments for method isAssignableFrom()."
+ " Method has two required parameters: [Class, SimpleNumber]. Found: " + list.size());
}
Object arg1 = ((WrapperTemplateModel) list.get(0)).getWrappedObject();
if (!(arg1 instanceof Method)) {
throw new TemplateModelException("Wrong type of the first parameter."
+ " It should be Method. Found: " + arg1.getClass());
}
Object arg2 = list.get(1);
if (!(arg2 instanceof SimpleNumber)) {
throw new TemplateModelException("Wrong type of the second parameter."
+ " It should be SimpleNumber. Found: " + arg2.getClass());
}
return timeStepModel.hasStartNanosAnnotation((Method) arg1, ((SimpleNumber) arg2).getAsNumber().intValue() - 1);
}
}
代码示例来源:origin: org.mybatis.scripting/mybatis-freemarker
value = null;
} else if (valueObject instanceof WrapperTemplateModel) {
value = ((WrapperTemplateModel) valueObject).getWrappedObject();
} else if (valueObject instanceof TemplateScalarModel) {
value = ((TemplateScalarModel) valueObject).getAsString();
代码示例来源:origin: com.haulmont.reports/reports-core
if (arguments.size() == 1) {
Object arg = arguments.get(0);
if (arg instanceof WrapperTemplateModel && ((WrapperTemplateModel) arg).getWrappedObject() instanceof Enum) {
return messages.getMessage((Enum) ((WrapperTemplateModel) arg).getWrappedObject());
} else {
throwIncorrectArgType("getMessage", 1, "Enum");
代码示例来源:origin: org.freemarker/com.springsource.freemarker
return ((WrapperTemplateModel)m).getWrappedObject();
代码示例来源:origin: org.freemarker/com.springsource.freemarker
Object wrapped = ((WrapperTemplateModel)model).getWrappedObject();
if(hint.isInstance(wrapped)) {
return wrapped;
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
return ((WrapperTemplateModel) tm).getWrappedObject();
代码示例来源:origin: org.freemarker/freemarker-gae
return ((WrapperTemplateModel) tm).getWrappedObject();
内容来源于网络,如有侵权,请联系作者删除!