Package freemarker.template

Examples of freemarker.template.TemplateModelException


                    break;
                }
            }
            if((method.getModifiers() & Modifier.STATIC) != 0)
            {
                throw new TemplateModelException("Method " + method +
                        " threw an exception", e);
            }
            else
            {
                StringBuffer buf = new StringBuffer();
                Object[] args = maa.getArgs();
                for(int i = 0; i < args.length; ++i)
                {
                    Object arg = args[i];
                    buf.append(arg == null ? "null" : arg.getClass().getName()).append(',');
                }
                throw new TemplateModelException("Method " + method +
                        " threw an exception when invoked on " + object +
                        " with arguments of types [" + buf + "]", e);
            }
        }
    }
View Full Code Here


                new SimpleNumber(new Integer(index))));
    }

    public int size() throws TemplateModelException
    {
        throw new TemplateModelException("?size is unsupported for: " +
                getClass().getName());
    }
View Full Code Here

        }
        boolean varArg = MethodUtilities.isVarArgs(member);
        int typeLen = argTypes.length;
        if(varArg) {
            if(typeLen - 1 > arguments.size()) {
                throw new TemplateModelException("Method " + member +
                        " takes at least " + (typeLen - 1) +
                        " arguments");
            }
        }
        else if(typeLen != arguments.size()) {
            throw new TemplateModelException("Method " + member +
                    " takes exactly " + typeLen + " arguments");
        }
        
        Object[] args = unwrapArguments(arguments, argTypes, wrapper);
        if(args != null) {
View Full Code Here

    private static Object unwrapArgument(TemplateModel model, Class type, BeansWrapper w)
    throws TemplateModelException {
        Object val = w.unwrapInternal(model, type);
        if(val == BeansWrapper.CAN_NOT_UNWRAP) {
            throw new TemplateModelException("Can not unwrap argument " +
                    model + " to " + type.getName());
        }
        return val;
    }
View Full Code Here

        }
       
        try {
            result = Pattern.compile(patternString, flags);
        } catch (PatternSyntaxException e) {
            throw new TemplateModelException(e);
        }
        synchronized (patternCache) {
            patternCache.put(patternKey, result);
        }
        return result;
View Full Code Here

                    public int size() throws TemplateModelException {
                        try {
                            return matcher.groupCount() + 1;
                        }
                        catch (Exception e) {
                            throw new TemplateModelException(e);
                        }
                    }
                    public TemplateModel get(int i) throws TemplateModelException {
                        try {
                            return new SimpleScalar(matcher.group(i));
                        }
                        catch (Exception e) {
                            throw new TemplateModelException(e);
                        }
                    }
                };
            }
            return groups;
View Full Code Here

                public boolean hasNext() {
                    return hasFindInfo;
                }
               
                public TemplateModel next() throws TemplateModelException {
                    if (!hasNext()) throw new TemplateModelException("No more matches");
                    Match result = new Match();
                    hasFindInfo = matcher.find();
                    return result;
                }
            };
View Full Code Here

//                throw new TemplateModelException("Index out of bounds: " + index);
            }
        }
        else
        {
            throw new TemplateModelException("Underlying collection is not a list, it's " + object.getClass().getName());
        }
    }
View Full Code Here

        }
       
        public Object exec(List args) throws TemplateModelException {
            int numArgs = args.size();
            if (numArgs == 0) {
                throw new TemplateModelException("Expecting at least one argument");
            }
            if (numArgs > 2) {
                throw new TemplateModelException("Expecting at most two argumnets");
            }
            String patternString = (String) args.get(0);
            long flags = numArgs > 1 ? parseFlagString((String) args.get(1)) : 0;
            if ((flags & RE_FLAG_FIRST_ONLY) != 0) {
                logFlagWarning("?match doesn't support the \"f\" flag.");
View Full Code Here

        }

        public Object exec(List args) throws TemplateModelException {
            int numArgs = args.size();
            if (numArgs < 2 || numArgs > 3) {
                throw new TemplateModelException(
                        "?replace(...) needs 2 or 3 arguments.");
            }
            String arg1 = (String) args.get(0);
            String arg2 = (String) args.get(1);
            long flags = numArgs > 2 ? parseFlagString((String) args.get(2)) : 0;
View Full Code Here

TOP

Related Classes of freemarker.template.TemplateModelException

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.