/** * Same as {@link #unwrap(TemplateModel)}, but it doesn't throw exception * if it doesn't know how to unwrap the model, but rather returns it as-is. * @since 2.3.14 */ public static Object permissiveUnwrap(TemplateModel model) throws TemplateModelException { return unwrap(model, true); }
/** * @deprecated the name of this method is mistyped. Use * {@link #permissiveUnwrap(TemplateModel)} instead. */ @Deprecated public static Object premissiveUnwrap(TemplateModel model) throws TemplateModelException { return unwrap(model, true); }
return unwrap(model, false);
private static Object unwrap(TemplateModel model, boolean permissive) throws TemplateModelException { Environment env = Environment.getCurrentEnvironment(); TemplateModel nullModel = null; if (env != null) { ObjectWrapper wrapper = env.getObjectWrapper(); if (wrapper != null) { nullModel = wrapper.wrap(null); } } return unwrap(model, nullModel, permissive); }
ArrayList list = new ArrayList(size); for (int i = 0; i < size; ++i) { list.add(unwrap(seq.get(i), nullModel, permissive)); TemplateModelIterator it = coll.iterator(); while (it.hasNext()) { list.add(unwrap(it.next(), nullModel, permissive)); KeyValuePair kvp = kvps.next(); map.put( unwrap(kvp.getKey(), nullModel, permissive), unwrap(kvp.getValue(), nullModel, permissive)); String key = (String) unwrap(keys.next(), nullModel, permissive); map.put(key, unwrap(hash.get(key), nullModel, permissive));
if (paramsModel != null) { final Object unwrapped = DeepUnwrap.unwrap(paramsModel); if (!(unwrapped instanceof Map)) { throw new _MiscTemplateException(env,
for (TemplateModelIterator it = keys.iterator(); it.hasNext();) { String attName = ((TemplateScalarModel) it.next()).getAsString(); Object attValue = DeepUnwrap.unwrap(attributeMap.get(attName)); template.setCustomAttribute(attName, attValue);
/** * Same as {@link #unwrap(TemplateModel)}, but it doesn't throw exception * if it doesn't know how to unwrap the model, but rather returns it as-is. * @since 2.3.14 */ public static Object permissiveUnwrap(TemplateModel model) throws TemplateModelException { return unwrap(model, true); }
/** * Same as {@link #unwrap(TemplateModel)}, but it doesn't throw exception * if it doesn't know how to unwrap the model, but rather returns it as-is. * @since 2.3.14 */ public static Object permissiveUnwrap(TemplateModel model) throws TemplateModelException { return unwrap(model, true); }
/** * @deprecated the name of this method is mistyped. Use * {@link #permissiveUnwrap(TemplateModel)} instead. */ public static Object premissiveUnwrap(TemplateModel model) throws TemplateModelException { return unwrap(model, true); }
@SuppressWarnings("rawtypes") @Override public Object exec(List arguments) throws TemplateModelException { Stub stub = (Stub) DeepUnwrap.unwrap((TemplateModel) arguments.get(0)); return getStubNameConsideringMultiple(stub); } }
/** * @deprecated the name of this method is mistyped. Use * {@link #permissiveUnwrap(TemplateModel)} instead. */ @Deprecated public static Object premissiveUnwrap(TemplateModel model) throws TemplateModelException { return unwrap(model, true); }
@SuppressWarnings("rawtypes") @Override public Object exec(List arguments) throws TemplateModelException { Stub stub = (Stub) DeepUnwrap.unwrap((TemplateModel) arguments.get(0)); String parentPath = (String) DeepUnwrap.unwrap((TemplateModel) arguments.get(1)); if (parentPath == null || StringUtils.isEmpty(parentPath)) { return getStubNameConsideringMultiple(stub); } return parentPath + "." + getStubNameConsideringMultiple(stub); } }
@Override protected void render(Map params, String body, Writer writer) throws Exception { validateParamsPresence(params, "print"); writer.write(params.get("print") == null ? "DebugTag: value 'print' is null!" : DeepUnwrap.unwrap((TemplateModel) params.get("print")).toString()); } }
protected Object mandatoryObject(Map<String, TemplateModel> params, String key) throws TemplateModelException { final TemplateModel model = _param(params, key, TemplateModel.class, true); return DeepUnwrap.unwrap(model); }
public static Object getObject(String paramString, Map<String, TemplateModel> paramMap) throws TemplateModelException { TemplateModel localTemplateModel = (TemplateModel) paramMap.get(paramString); if (localTemplateModel == null) return null; try { return DeepUnwrap.unwrap(localTemplateModel); } catch (TemplateModelException localTemplateModelException) { throw new TemplateModelException("The \"" + paramString + "\" parameter " + "must be a object."); } }
protected Object object(Map<String, TemplateModel> params, String key) throws TemplateModelException { final TemplateModel model = _param(params, key, TemplateModel.class, false); if (model == null) { return null; } return DeepUnwrap.unwrap(model); }
@SuppressWarnings("rawtypes") @Override public Object exec(List arguments) throws TemplateModelException { Stub stub = (Stub) DeepUnwrap.unwrap((TemplateModel) arguments.get(0)); String typeText = stub.getType().getSimpleName(); if (stub.isMultiOccurs()) { typeText += "[]"; } return typeText; } }
private static Object unwrap(TemplateModel model, boolean permissive) throws TemplateModelException { Environment env = Environment.getCurrentEnvironment(); TemplateModel nullModel = null; if(env != null) { ObjectWrapper wrapper = env.getObjectWrapper(); if(wrapper != null) { nullModel = wrapper.wrap(null); } } return unwrap(model, nullModel, permissive); }
private static Object unwrap(TemplateModel model, boolean permissive) throws TemplateModelException { Environment env = Environment.getCurrentEnvironment(); TemplateModel nullModel = null; if (env != null) { ObjectWrapper wrapper = env.getObjectWrapper(); if (wrapper != null) { nullModel = wrapper.wrap(null); } } return unwrap(model, nullModel, permissive); }