LangFtlUtil.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:scipio-erp 作者:
/**
 * Gets map keys, either as collection or Set.
 * <p>
 * WARN: auto-escaping is bypassed on all keys, caller handles.
 * (e.g. the object wrapper used to rewrap the result).
 * DEV NOTE: we MUST manually bypass auto-escaping for all on this one.
 */
public static Object getMapKeys(TemplateModel object) throws TemplateModelException {
    if (OfbizFtlObjectType.COMPLEXMAP.isObjectType(object)) {
        // WARN: bypasses auto-escaping
        Map<Object, Object> wrappedObject = UtilGenerics.cast(((WrapperTemplateModel) object).getWrappedObject());
        return wrappedObject.keySet();
    }
    else if (object instanceof TemplateHashModelEx) {
        // 2016-04-20: cannot do this because we MUST trigger bypass of auto-escaping,
        // so just do a deep unwrap, which automatically bypasses the escaping,
        // and then caller handles the result, which is probably an arraylist
        //return ((TemplateHashModelEx) object).keys();
        return unwrapAlways(((TemplateHashModelEx) object).keys());
    }
    else {
        throw new TemplateModelException("object is not a map or does not support key iteration");
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号