Package freemarker.template

Examples of freemarker.template.TemplateModel


        return unwrap(model, true);
    }
   
    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);
            }
View Full Code Here


    private static String resolveRelativeUri(String uri)
    throws
        TemplateModelException
    {
        TemplateModel reqHash =
            Environment.getCurrentEnvironment().getVariable(
                FreemarkerServlet.KEY_REQUEST_PRIVATE);
        if(reqHash instanceof HttpRequestHashModel) {
            HttpServletRequest req =
                ((HttpRequestHashModel)reqHash).getRequest();
View Full Code Here

        throws
        TemplateModelException
    {
        Class clazz = object.getClass();
        Map classInfo = wrapper.getClassKeyMap(clazz);
        TemplateModel retval = null;
       
        try
        {
            if(wrapper.isMethodsShadowItems())
            {
                Object fd = classInfo.get(key);
                if(fd != null)
                {
                    retval = invokeThroughDescriptor(fd, classInfo);
                } else {
                    retval = invokeGenericGet(classInfo, clazz, key);
                }
            }
            else
            {
                TemplateModel model = invokeGenericGet(classInfo, clazz, key);
                final TemplateModel nullModel = wrapper.wrap(null);
                if(model != nullModel && model != UNKNOWN)
                {
                    return model;
                }
                Object fd = classInfo.get(key);
View Full Code Here

        InvocationTargetException,
        TemplateModelException
    {
        // See if this particular instance has a cached implementation
        // for the requested feature descriptor
        TemplateModel member;
        synchronized(this) {
            if(memberMap != null) {
                member = (TemplateModel)memberMap.get(desc);
            }
            else {
                member = null;
            }
        }

        if(member != null)
            return member;

        TemplateModel retval = UNKNOWN;
        if(desc instanceof IndexedPropertyDescriptor)
        {
            Method readMethod =
                ((IndexedPropertyDescriptor)desc).getIndexedReadMethod();
            retval = member =
View Full Code Here

                buf = null;
            }
            else if ("tag".equals(qName)) {
                try {
                    Class tagClass = ClassUtil.forName(tagClassName);
                    TemplateModel impl;
                    if(Tag.class.isAssignableFrom(tagClass)) {
                        impl = new TagTransformModel(tagClass);
                    }
                    else {
                        impl = new SimpleTagDirectiveModel(tagClass);
View Full Code Here

        this.wrapper = wrapper;
    }

    public TemplateModel get(String key) throws TemplateModelException {
        synchronized(cache) {
            TemplateModel model = (TemplateModel)cache.get(key);
            if(model == null) {
                try {
                    Class clazz = ClassUtil.forName(key);
                    model = createModel(clazz);
                    // This is called so that we trigger the
View Full Code Here

        this.key = key;
    }

    TemplateModel _getAsTemplateModel(Environment env) throws TemplateException
    {
        TemplateModel leftModel = target.getAsTemplateModel(env);
        if(leftModel instanceof TemplateHashModel) {
            return ((TemplateHashModel) leftModel).get(key);
        }
        throw invalidTypeException(leftModel, target, env, "hash");
    }
View Full Code Here

        }
    }

    static FreeMarkerPageContext getCurrentPageContext() throws TemplateModelException {
        Environment env = Environment.getCurrentEnvironment();
        TemplateModel pageContextModel = env.getGlobalVariable(PageContext.PAGECONTEXT);
        if(pageContextModel instanceof FreeMarkerPageContext) {
            return (FreeMarkerPageContext)pageContextModel;
        }
        try {
            FreeMarkerPageContext pageContext =
View Full Code Here

abstract class NumericalBuiltins {
    abstract static class NumberBuiltIn extends BuiltIn {
        TemplateModel _getAsTemplateModel(Environment env)
                throws TemplateException
        {
            TemplateModel model = target.getAsTemplateModel(env);
            return calculateResult(EvaluationUtil.getNumber(model, target, env), model);
        }
View Full Code Here

    // Does both someNumber?long and someDate?long, thus it doesn't extend NumberBuiltIn
    static class longBI extends BuiltIn {
        TemplateModel _getAsTemplateModel(Environment env)
                throws TemplateException
        {
            TemplateModel model = target.getAsTemplateModel(env);
            if (!(model instanceof TemplateNumberModel)
                    && model instanceof TemplateDateModel) {
                Date date = EvaluationUtil.getDate((TemplateDateModel) model, target, env);
                return new SimpleNumber(date.getTime());
            } else {
View Full Code Here

TOP

Related Classes of freemarker.template.TemplateModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.