Package freemarker.core

Examples of freemarker.core._ObjectBuilderSettingEvaluator$SettingExpression


    }

    private TemplateModelException createNullToPrimitiveArgumentException(int argIdx, Class targetType) {
        return new _TemplateModelException(new Object[] {
                _MethodUtil.invocationErrorMessageStart(member), " couldn't be called: The value of the ",
                new _DelayedOrdinal(new Integer(argIdx + 1)),
                " argument was null, but the target Java parameter type (", ClassUtil.getShortClassName(targetType),
                ") is primitive and so can't store null." });
    }
View Full Code Here


    }

    static EmptyMemberAndArguments noCompatibleOverload(int unwrappableIndex) {
        return new EmptyMemberAndArguments(
                new Object[] { "No compatible overloaded variation was found; can't convert (unwrap) the ",
                new _DelayedOrdinal(new Integer(unwrappableIndex)), " argument to the desired Java type." },
                false,
                null);
    }
View Full Code Here

                    if (tryOnly) {
                        return CAN_NOT_UNWRAP;
                    } else {
                        throw new _TemplateModelException(new Object[] {
                                "Failed to convert "new _DelayedFTLTypeDescription(seq),
                                " object to ", new _DelayedShortClassName(array.getClass()),
                                ": Problematic sequence item at index ", new Integer(i) ," with value type: ",
                                new _DelayedFTLTypeDescription(seqItem)});
                    }
                   
                }
View Full Code Here

            }
        } else {
            varargsRes = null;
        }
       
        _ErrorDescriptionBuilder edb = new _ErrorDescriptionBuilder(new Object[] {
                toCompositeErrorMessage(
                        (EmptyMemberAndArguments) fixArgsRes,
                        (EmptyMemberAndArguments) varargsRes,
                        tmArgs),
                "\nThe matching overload was searched among these members:\n",
                memberListToString()});
        if (!bugfixed) {
            edb.tip("You seem to use BeansWrapper with incompatibleImprovements set blow 2.3.21. If you think this "
                    + "error is unfounded, enabling 2.3.21 fixes may helps. See version history for more.");
        }
        throw new _TemplateModelException(edb);
    }
View Full Code Here

    throws TemplateException, IOException
    {
        // Determine the path
        final TemplateModel path = (TemplateModel)params.get("path");
        if(path == null) {
            throw new _MiscTemplateException(env, "Missing required parameter \"path\"");
        }
        if(!(path instanceof TemplateScalarModel)) {
            throw new _MiscTemplateException(env, new Object[] {
                    "Expected a scalar model. \"path\" is instead ",
                    new _DelayedFTLTypeDescription(path) });
        }
        final String strPath = ((TemplateScalarModel)path).getAsString();
        if(strPath == null) {
            throw new _MiscTemplateException(env, "String value of \"path\" parameter is null");
        }
       
        // See whether we need to use a custom response (if we're inside a TTM
        // or TDM or macro nested body, we'll need to as then the current
        // FM environment writer is not identical to HTTP servlet response
        // writer.
        final Writer envOut = env.getOut();
        final HttpServletResponse wrappedResponse;
        if(envOut == response.getWriter()) {
            // Don't bother wrapping if environment's writer is same as
            // response writer
            wrappedResponse = response;
        }
        else {
            final PrintWriter printWriter = (envOut instanceof PrintWriter) ?
                (PrintWriter)envOut :
                new PrintWriter(envOut);
            // Otherwise, create a response wrapper that will pass the
            // env writer, potentially first wrapping it in a print
            // writer when it ain't one already.
            wrappedResponse = new HttpServletResponseWrapper(response) {
                public PrintWriter getWriter() {
                    return printWriter;
                }
            };
        }

        // Determine inherit_params value
        final boolean inheritParams;
        final TemplateModel inheritParamsModel = (TemplateModel)params.get("inherit_params");
        if(inheritParamsModel == null) {
            // defaults to true when not specified
            inheritParams = true;
        }
        else {
            if(!(inheritParamsModel instanceof TemplateBooleanModel)) {
                throw new _MiscTemplateException(env, new Object[] {
                        "\"inherit_params\" should be a boolean but it's a(n) ",
                        inheritParamsModel.getClass().getName(), " instead" });
            }
            inheritParams = ((TemplateBooleanModel)inheritParamsModel).getAsBoolean();
        }
       
        // Get explicit params, if any
        final TemplateModel paramsModel = (TemplateModel)params.get("params");
       
        // Determine whether we need to wrap the request
        final HttpServletRequest wrappedRequest;
        if(paramsModel == null && inheritParams) {
            // Inherit original request params & no params explicitly
            // specified, so use the original request
            wrappedRequest = request;
        }
        else {
            // In any other case, use a custom request wrapper
            final Map paramsMap;
            if(paramsModel != null) {
                // Convert params to a Map
                final Object unwrapped = DeepUnwrap.unwrap(paramsModel);
                if(!(unwrapped instanceof Map)) {
                    throw new _MiscTemplateException(env, new Object[] {
                            "Expected \"params\" to unwrap into a java.util.Map. It unwrapped into ",
                            unwrapped.getClass().getName(), " instead." });
                }
                paramsMap = (Map)unwrapped;
            }
            else {
                paramsMap = Collections.EMPTY_MAP;
            }
            wrappedRequest = new CustomParamsRequest(request, paramsMap,
                    inheritParams);
        }
       
        // Finally, do the include
        try {
            request.getRequestDispatcher(strPath).include(wrappedRequest,
                    wrappedResponse);
        }
        catch (ServletException e) {
            throw new _MiscTemplateException(e, env);
        }
    }
View Full Code Here

                Object val = tryUnwrap(seqItem, componentType, 0, recursionStops);
                if(val == CAN_NOT_UNWRAP) {
                    if (tryOnly) {
                        return CAN_NOT_UNWRAP;
                    } else {
                        throw new _TemplateModelException(new Object[] {
                                "Failed to convert "new _DelayedFTLTypeDescription(seq),
                                " object to ", new _DelayedShortClassName(array.getClass()),
                                ": Problematic sequence item at index ", new Integer(i) ," with value type: ",
                                new _DelayedFTLTypeDescription(seqItem)});
                    }
View Full Code Here

                memberListToString()});
        if (!bugfixed) {
            edb.tip("You seem to use BeansWrapper with incompatibleImprovements set blow 2.3.21. If you think this "
                    + "error is unfounded, enabling 2.3.21 fixes may helps. See version history for more.");
        }
        throw new _TemplateModelException(edb);
    }
View Full Code Here

        }
        boolean isVarArg = _MethodUtil.isVarargs(member);
        int typesLen = argTypes.length;
        if(isVarArg) {
            if(typesLen - 1 > arguments.size()) {
                throw new _TemplateModelException(new Object[] {
                        _MethodUtil.invocationErrorMessageStart(member),
                        " takes at least ", new Integer(typesLen - 1),
                        typesLen - 1 == 1 ? " argument" : " arguments", ", but ",
                        new Integer(arguments.size()), " was given." });
            }
        }
        else if(typesLen != arguments.size()) {
            throw new _TemplateModelException(new Object[] {
                    _MethodUtil.invocationErrorMessageStart(member),
                    " takes ", new Integer(typesLen), typesLen == 1 ? " argument" : " arguments", ", but ",
                    new Integer(arguments.size()), " was given." });
        }
        
View Full Code Here

        return unwrappedArgs;
    }

    private TemplateModelException createArgumentTypeMismarchException(
            int argIdx, TemplateModel argVal, Class targetType) {
        return new _TemplateModelException(new Object[] {
                _MethodUtil.invocationErrorMessageStart(member), " couldn't be called: Can't convert the ",
                new _DelayedOrdinal(new Integer(argIdx + 1)),
                " argument's value to the target Java type, ", ClassUtil.getShortClassName(targetType),
                ". The type of the actual value was: ", new _DelayedFTLTypeDescription(argVal),
                });
View Full Code Here

                ". The type of the actual value was: ", new _DelayedFTLTypeDescription(argVal),
                });
    }

    private TemplateModelException createNullToPrimitiveArgumentException(int argIdx, Class targetType) {
        return new _TemplateModelException(new Object[] {
                _MethodUtil.invocationErrorMessageStart(member), " couldn't be called: The value of the ",
                new _DelayedOrdinal(new Integer(argIdx + 1)),
                " argument was null, but the target Java parameter type (", ClassUtil.getShortClassName(targetType),
                ") is primitive and so can't store null." });
    }
View Full Code Here

TOP

Related Classes of freemarker.core._ObjectBuilderSettingEvaluator$SettingExpression

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.