Examples of TemplateModelException


Examples of freemarker.template.TemplateModelException

                this.env = env;
            }

            public Object exec(List args) throws TemplateModelException {
                if (args.size() != 1) {
                    throw new TemplateModelException(
                        "?" + biName + "(...) expects exactly 1 argument, but had "
                        + args.size() + ".");
                }
               
                TemplateModel tzArgTM = (TemplateModel) args.get(0);
                TimeZone tzArg;
                Object adaptedObj;
                if (tzArgTM instanceof AdapterTemplateModel
                        && (adaptedObj =
                                ((AdapterTemplateModel) tzArgTM)
                                .getAdaptedObject(TimeZone.class))
                            instanceof TimeZone) {
                    tzArg = (TimeZone) adaptedObj;                   
                } else if (tzArgTM instanceof TemplateScalarModel) {
                    String tzName = ((TemplateScalarModel) tzArgTM).getAsString();
                    try {
                        tzArg = DateUtil.getTimeZone(tzName);
                    } catch (UnrecognizedTimeZoneException e) {
                        throw new TemplateModelException(
                                "The time zone string specified for ?" + biName +
                                "(...) is not recognized as a valid time zone name: " +
                                StringUtil.jQuote(tzName));
                    }
                } else {
                    throw new TemplateModelException(
                            "The argument to ?" + biName +
                            "(...) must be a String or a " +
                            "java.util.TimeZone but it was a " +
                            (tzArgTM != null ? tzArgTM.getClass().getName() : "null") +
                            ".");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.