freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [45/54] [partial] incubator-freemarker git commit: Top level package name change to org.apache.freemarker, and some of of the internal package structure changes. Other smaller cleanup. To be continued...
Date Thu, 16 Feb 2017 23:09:10 GMT
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/BuiltInWithParseTimeParameters.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInWithParseTimeParameters.java b/src/main/java/freemarker/core/BuiltInWithParseTimeParameters.java
deleted file mode 100644
index 1820d98..0000000
--- a/src/main/java/freemarker/core/BuiltInWithParseTimeParameters.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package freemarker.core;
-
-import java.util.List;
-
-
-abstract class BuiltInWithParseTimeParameters extends SpecialBuiltIn {
-
-    abstract void bindToParameters(List/*<Expression>*/ parameters, Token openParen, Token closeParen)
-            throws ParseException;
-
-    @Override
-    public String getCanonicalForm() {
-        StringBuilder buf = new StringBuilder();
-        
-        buf.append(super.getCanonicalForm());
-        
-        buf.append("(");
-        List/*<Expression>*/args = getArgumentsAsList();
-        int size = args.size();
-        for (int i = 0; i < size; i++) {
-            if (i != 0) {
-                buf.append(", ");
-            }
-            Expression arg = (Expression) args.get(i);
-            buf.append(arg.getCanonicalForm());
-        }
-        buf.append(")");
-        
-        return buf.toString();
-    }
-    
-    @Override
-    String getNodeTypeSymbol() {
-        return super.getNodeTypeSymbol() + "(...)";
-    }        
-    
-    @Override
-    int getParameterCount() {
-        return super.getParameterCount() + getArgumentsCount();
-    }
-
-    @Override
-    Object getParameterValue(int idx) {
-        final int superParamCnt = super.getParameterCount();
-        if (idx < superParamCnt) {
-            return super.getParameterValue(idx); 
-        }
-        
-        final int argIdx = idx - superParamCnt;
-        return getArgumentParameterValue(argIdx);
-    }
-    
-    @Override
-    ParameterRole getParameterRole(int idx) {
-        final int superParamCnt = super.getParameterCount();
-        if (idx < superParamCnt) {
-            return super.getParameterRole(idx); 
-        }
-        
-        if (idx - superParamCnt < getArgumentsCount()) {
-            return ParameterRole.ARGUMENT_VALUE;
-        } else {
-            throw new IndexOutOfBoundsException();
-        }
-    }
-
-    protected ParseException newArgumentCountException(String ordinalityDesc, Token openParen, Token closeParen) {
-        return new ParseException(
-                "?" + key + "(...) " + ordinalityDesc + " parameters", this.getTemplate(),
-                openParen.beginLine, openParen.beginColumn,
-                closeParen.endLine, closeParen.endColumn);
-    }
-
-    @Override
-    protected Expression deepCloneWithIdentifierReplaced_inner(
-            String replacedIdentifier, Expression replacement, ReplacemenetState replacementState) {
-        final Expression clone = super.deepCloneWithIdentifierReplaced_inner(replacedIdentifier, replacement, replacementState);
-        cloneArguments(clone, replacedIdentifier, replacement, replacementState);
-        return clone;
-    }
-
-    protected abstract List getArgumentsAsList();
-    
-    protected abstract int getArgumentsCount();
-
-    protected abstract Expression getArgumentParameterValue(int argIdx);
-    
-    protected abstract void cloneArguments(Expression clone, String replacedIdentifier,
-            Expression replacement, ReplacemenetState replacementState);
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/BuiltInsForDates.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForDates.java b/src/main/java/freemarker/core/BuiltInsForDates.java
deleted file mode 100644
index af81a3d..0000000
--- a/src/main/java/freemarker/core/BuiltInsForDates.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package freemarker.core;
-
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-
-import freemarker.template.AdapterTemplateModel;
-import freemarker.template.SimpleDate;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateDateModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateMethodModelEx;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-import freemarker.template.TemplateScalarModel;
-import freemarker.template._TemplateAPI;
-import freemarker.template.utility.DateUtil;
-import freemarker.template.utility.UnrecognizedTimeZoneException;
-
-/**
- * A holder for built-ins that operate exclusively on date left-hand values.
- */
-class BuiltInsForDates {
-    
-    static class dateType_if_unknownBI extends BuiltIn {
-        
-        private final int dateType;
-
-        dateType_if_unknownBI(int dateType) {
-            this.dateType = dateType;
-        }
-
-        @Override
-        TemplateModel _eval(Environment env)
-                throws TemplateException {
-            TemplateModel model = target.eval(env);
-            if (model instanceof TemplateDateModel) {
-                TemplateDateModel tdm = (TemplateDateModel) model;
-                int tdmDateType = tdm.getDateType();
-                if (tdmDateType != TemplateDateModel.UNKNOWN) {
-                    return tdm;
-                }
-                return new SimpleDate(EvalUtil.modelToDate(tdm, target), dateType);
-            } else {
-                throw BuiltInForDate.newNonDateException(env, model, target);
-            }
-        }
-
-        protected TemplateModel calculateResult(Date date, int dateType, Environment env) throws TemplateException {
-            // TODO Auto-generated method stub
-            return null;
-        }
-        
-    }
-    
-    /**
-     * Implements {@code ?iso(timeZone)}.
-     */
-    static class iso_BI extends AbstractISOBI {
-        
-        class Result implements TemplateMethodModelEx {
-            private final Date date;
-            private final int dateType;
-            private final Environment env;
-            
-            Result(Date date, int dateType, Environment env) {
-                this.date = date;
-                this.dateType = dateType;
-                this.env = env;
-            }
-
-            public Object exec(List args) throws TemplateModelException {
-                checkMethodArgCount(args, 1);
-                
-                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 = EvalUtil.modelToString((TemplateScalarModel) tzArgTM, null, null);
-                    try {
-                        tzArg = DateUtil.getTimeZone(tzName);
-                    } catch (UnrecognizedTimeZoneException e) {
-                        throw new _TemplateModelException(
-                                "The time zone string specified for ?", key,
-                                "(...) is not recognized as a valid time zone name: ",
-                                new _DelayedJQuote(tzName));
-                    }
-                } else {
-                    throw MessageUtil.newMethodArgUnexpectedTypeException(
-                            "?" + key, 0, "string or java.util.TimeZone", tzArgTM);
-                }
-                
-                return new SimpleScalar(DateUtil.dateToISO8601String(
-                        date,
-                        dateType != TemplateDateModel.TIME,
-                        dateType != TemplateDateModel.DATE,
-                        shouldShowOffset(date, dateType, env),
-                        accuracy,
-                        tzArg, 
-                        env.getISOBuiltInCalendarFactory()));
-            }
-            
-        }
-
-        iso_BI(Boolean showOffset, int accuracy) {
-            super(showOffset, accuracy);
-        }
-        
-        @Override
-        protected TemplateModel calculateResult(
-                Date date, int dateType, Environment env)
-        throws TemplateException {
-            checkDateTypeNotUnknown(dateType);
-            return new Result(date, dateType, env);
-        }
-        
-    }
-
-    /**
-     * Implements {@code ?iso_utc} and {@code ?iso_local} variants, but not
-     * {@code ?iso(timeZone)}.
-     */
-    static class iso_utc_or_local_BI extends AbstractISOBI {
-        
-        private final boolean useUTC;
-        
-        iso_utc_or_local_BI(Boolean showOffset, int accuracy, boolean useUTC) {
-            super(showOffset, accuracy);
-            this.useUTC = useUTC;
-        }
-
-        @Override
-        protected TemplateModel calculateResult(
-                Date date, int dateType, Environment env)
-        throws TemplateException {
-            checkDateTypeNotUnknown(dateType);
-            return new SimpleScalar(DateUtil.dateToISO8601String(
-                    date,
-                    dateType != TemplateDateModel.TIME,
-                    dateType != TemplateDateModel.DATE,
-                    shouldShowOffset(date, dateType, env),
-                    accuracy,
-                    useUTC
-                            ? DateUtil.UTC
-                            : env.shouldUseSQLDTTZ(date.getClass())
-                                    ? env.getSQLDateAndTimeTimeZone()
-                                    : env.getTimeZone(),
-                    env.getISOBuiltInCalendarFactory()));
-        }
-
-    }
-    
-    // Can't be instantiated
-    private BuiltInsForDates() { }
-
-    static abstract class AbstractISOBI extends BuiltInForDate {
-        protected final Boolean showOffset;
-        protected final int accuracy;
-    
-        protected AbstractISOBI(Boolean showOffset, int accuracy) {
-            this.showOffset = showOffset;
-            this.accuracy = accuracy;
-        }
-        
-        protected void checkDateTypeNotUnknown(int dateType)
-        throws TemplateException {
-            if (dateType == TemplateDateModel.UNKNOWN) {
-                throw new _MiscTemplateException(new _ErrorDescriptionBuilder(
-                            "The value of the following has unknown date type, but ?", key,
-                            " needs a value where it's known if it's a date (no time part), time, or date-time value:"                        
-                        ).blame(target).tip(MessageUtil.UNKNOWN_DATE_TYPE_ERROR_TIP));
-            }
-        }
-    
-        protected boolean shouldShowOffset(Date date, int dateType, Environment env) {
-            if (dateType == TemplateDateModel.DATE) {
-                return false;  // ISO 8061 doesn't allow zone for date-only values
-            } else if (this.showOffset != null) {
-                return this.showOffset.booleanValue();
-            } else {
-                // java.sql.Time values meant to carry calendar field values only, so we don't show offset for them.
-                return !(date instanceof java.sql.Time
-                        && _TemplateAPI.getTemplateLanguageVersionAsInt(this) >= _TemplateAPI.VERSION_INT_2_3_21);
-            }
-        }
-        
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/BuiltInsForHashes.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForHashes.java b/src/main/java/freemarker/core/BuiltInsForHashes.java
deleted file mode 100644
index 79d63de..0000000
--- a/src/main/java/freemarker/core/BuiltInsForHashes.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package freemarker.core;
-
-import freemarker.template.TemplateCollectionModel;
-import freemarker.template.TemplateHashModelEx;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-import freemarker.template.TemplateSequenceModel;
-
-/**
- * A holder for builtins that operate exclusively on hash left-hand value.
- */
-class BuiltInsForHashes {
-
-    static class keysBI extends BuiltInForHashEx {
-
-        @Override
-        TemplateModel calculateResult(TemplateHashModelEx hashExModel, Environment env)
-                throws TemplateModelException, InvalidReferenceException {
-            TemplateCollectionModel keys = hashExModel.keys();
-            if (keys == null) throw newNullPropertyException("keys", hashExModel, env);
-            return keys instanceof TemplateSequenceModel ? keys : new CollectionAndSequence(keys);
-        }
-        
-    }
-    
-    static class valuesBI extends BuiltInForHashEx {
-        @Override
-        TemplateModel calculateResult(TemplateHashModelEx hashExModel, Environment env)
-                throws TemplateModelException, InvalidReferenceException {
-            TemplateCollectionModel values = hashExModel.values();
-            if (values == null) throw newNullPropertyException("values", hashExModel, env);
-            return values instanceof TemplateSequenceModel ? values : new CollectionAndSequence(values);
-        }
-    }
-
-    // Can't be instantiated
-    private BuiltInsForHashes() { }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/BuiltInsForLoopVariables.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForLoopVariables.java b/src/main/java/freemarker/core/BuiltInsForLoopVariables.java
deleted file mode 100644
index 8c680a5..0000000
--- a/src/main/java/freemarker/core/BuiltInsForLoopVariables.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package freemarker.core;
-
-import java.util.List;
-
-import freemarker.core.IteratorBlock.IterationContext;
-import freemarker.template.SimpleNumber;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateBooleanModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateMethodModelEx;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-
-
-class BuiltInsForLoopVariables {
-    
-    static class indexBI extends BuiltInForLoopVariable {
-
-        @Override
-        TemplateModel calculateResult(IterationContext iterCtx, Environment env) throws TemplateException {
-            return new SimpleNumber(iterCtx.getIndex());
-        }
-        
-    }
-    
-    static class counterBI extends BuiltInForLoopVariable {
-
-        @Override
-        TemplateModel calculateResult(IterationContext iterCtx, Environment env) throws TemplateException {
-            return new SimpleNumber(iterCtx.getIndex() + 1);
-        }
-        
-    }
-
-    static abstract class BooleanBuiltInForLoopVariable extends BuiltInForLoopVariable {
-
-        @Override
-        final TemplateModel calculateResult(IterationContext iterCtx, Environment env) throws TemplateException {
-            return calculateBooleanResult(iterCtx, env) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-
-        protected abstract boolean calculateBooleanResult(IterationContext iterCtx, Environment env);
-        
-    }
-    
-    static class has_nextBI extends BooleanBuiltInForLoopVariable {
-
-        @Override
-        protected boolean calculateBooleanResult(IterationContext iterCtx, Environment env) {
-            return iterCtx.hasNext();
-        }
-
-    }
-
-    static class is_lastBI extends BooleanBuiltInForLoopVariable {
-
-        @Override
-        protected boolean calculateBooleanResult(IterationContext iterCtx, Environment env) {
-            return !iterCtx.hasNext();
-        }
-        
-    }
-
-    static class is_firstBI extends BooleanBuiltInForLoopVariable {
-
-        @Override
-        protected boolean calculateBooleanResult(IterationContext iterCtx, Environment env) {
-            return iterCtx.getIndex() == 0;
-        }
-        
-    }
-
-    static class is_odd_itemBI extends BooleanBuiltInForLoopVariable {
-
-        @Override
-        protected boolean calculateBooleanResult(IterationContext iterCtx, Environment env) {
-            return iterCtx.getIndex() % 2 == 0;
-        }
-        
-    }
-
-    static class is_even_itemBI extends BooleanBuiltInForLoopVariable {
-
-        @Override
-        protected boolean calculateBooleanResult(IterationContext iterCtx, Environment env) {
-            return iterCtx.getIndex() % 2 != 0;
-        }
-        
-    }
-    
-    static class item_parityBI extends BuiltInForLoopVariable {
-        
-        private static final SimpleScalar ODD = new SimpleScalar("odd");
-        private static final SimpleScalar EVEN = new SimpleScalar("even");
-
-        @Override
-        TemplateModel calculateResult(IterationContext iterCtx, Environment env) throws TemplateException {
-            return iterCtx.getIndex() % 2 == 0 ? ODD: EVEN;
-        }
-        
-    }
-
-    static class item_parity_capBI extends BuiltInForLoopVariable {
-        
-        private static final SimpleScalar ODD = new SimpleScalar("Odd");
-        private static final SimpleScalar EVEN = new SimpleScalar("Even");
-
-        @Override
-        TemplateModel calculateResult(IterationContext iterCtx, Environment env) throws TemplateException {
-            return iterCtx.getIndex() % 2 == 0 ? ODD: EVEN;
-        }
-        
-    }
-
-    static class item_cycleBI extends BuiltInForLoopVariable {
-
-        private class BIMethod implements TemplateMethodModelEx {
-            
-            private final IterationContext iterCtx;
-    
-            private BIMethod(IterationContext iterCtx) {
-                this.iterCtx = iterCtx;
-            }
-    
-            public Object exec(List args) throws TemplateModelException {
-                checkMethodArgCount(args, 1, Integer.MAX_VALUE);
-                return args.get(iterCtx.getIndex() % args.size());
-            }
-        }
-        
-        @Override
-        TemplateModel calculateResult(IterationContext iterCtx, Environment env) throws TemplateException {
-            return new BIMethod(iterCtx);
-        }
-        
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/BuiltInsForMarkupOutputs.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForMarkupOutputs.java b/src/main/java/freemarker/core/BuiltInsForMarkupOutputs.java
deleted file mode 100644
index fede7b0..0000000
--- a/src/main/java/freemarker/core/BuiltInsForMarkupOutputs.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package freemarker.core;
-
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-
-/**
- * A holder for builtins that operate exclusively on markup output left-hand value.
- */
-class BuiltInsForMarkupOutputs {
-    
-    static class markup_stringBI extends BuiltInForMarkupOutput {
-
-        @Override
-        protected TemplateModel calculateResult(TemplateMarkupOutputModel model) throws TemplateModelException {
-            return new SimpleScalar(model.getOutputFormat().getMarkupString(model));
-        }
-        
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java b/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
deleted file mode 100644
index bb0c0c0..0000000
--- a/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
+++ /dev/null
@@ -1,759 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package freemarker.core;
-
-import java.util.Date;
-import java.util.List;
-
-import freemarker.ext.beans.OverloadedMethodsModel;
-import freemarker.ext.beans.SimpleMethodModel;
-import freemarker.template.SimpleDate;
-import freemarker.template.SimpleNumber;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateBooleanModel;
-import freemarker.template.TemplateCollectionModel;
-import freemarker.template.TemplateCollectionModelEx;
-import freemarker.template.TemplateDateModel;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateHashModel;
-import freemarker.template.TemplateHashModelEx;
-import freemarker.template.TemplateMethodModel;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-import freemarker.template.TemplateModelWithAPISupport;
-import freemarker.template.TemplateNodeModel;
-import freemarker.template.TemplateNumberModel;
-import freemarker.template.TemplateScalarModel;
-import freemarker.template.TemplateSequenceModel;
-import freemarker.template.TemplateTransformModel;
-import freemarker.template._TemplateAPI;
-
-/**
- * A holder for builtins that didn't fit into any other category.
- */
-class BuiltInsForMultipleTypes {
-
-    static class cBI extends AbstractCBI implements ICIChainMember {
-        
-        static class BIBeforeICE2d3d21 extends AbstractCBI {
-
-            @Override
-            protected TemplateModel formatNumber(Environment env, TemplateModel model) throws TemplateModelException {
-                Number num = EvalUtil.modelToNumber((TemplateNumberModel) model, target);
-                if (num instanceof Integer || num instanceof Long) {
-                    // Accelerate these fairly common cases
-                    return new SimpleScalar(num.toString());
-                } else {
-                    return new SimpleScalar(env.getCNumberFormat().format(num));
-                }
-            }
-            
-        }
-        
-        private final BIBeforeICE2d3d21 prevICIObj = new BIBeforeICE2d3d21();
-
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel model = target.eval(env);
-            if (model instanceof TemplateNumberModel) {
-                return formatNumber(env, model);
-            } else if (model instanceof TemplateBooleanModel) {
-                return new SimpleScalar(((TemplateBooleanModel) model).getAsBoolean()
-                        ? MiscUtil.C_TRUE : MiscUtil.C_FALSE);
-            } else {
-                throw new UnexpectedTypeException(
-                        target, model,
-                        "number or boolean", new Class[] { TemplateNumberModel.class, TemplateBooleanModel.class },
-                        env);
-            }
-        }
-
-        @Override
-        protected TemplateModel formatNumber(Environment env, TemplateModel model) throws TemplateModelException {
-            Number num = EvalUtil.modelToNumber((TemplateNumberModel) model, target);
-            if (num instanceof Integer || num instanceof Long) {
-                // Accelerate these fairly common cases
-                return new SimpleScalar(num.toString());
-            } else if (num instanceof Double) {
-                double n = num.doubleValue();
-                if (n == Double.POSITIVE_INFINITY) {
-                    return new SimpleScalar("INF");
-                }
-                if (n == Double.NEGATIVE_INFINITY) {
-                    return new SimpleScalar("-INF");
-                }
-                if (Double.isNaN(n)) {
-                    return new SimpleScalar("NaN");
-                }
-                // Deliberately falls through
-            } else if (num instanceof Float) {
-                float n = num.floatValue();
-                if (n == Float.POSITIVE_INFINITY) {
-                    return new SimpleScalar("INF");
-                }
-                if (n == Float.NEGATIVE_INFINITY) {
-                    return new SimpleScalar("-INF");
-                }
-                if (Float.isNaN(n)) {
-                    return new SimpleScalar("NaN");
-                }
-                // Deliberately falls through
-            }
-        
-            return new SimpleScalar(env.getCNumberFormat().format(num));
-        }
-
-        @Override
-        public int getMinimumICIVersion() {
-            return _TemplateAPI.VERSION_INT_2_3_21;
-        }
-        
-        @Override
-        public Object getPreviousICIChainMember() {
-            return prevICIObj;
-        }
-        
-    }
-
-    static class dateBI extends BuiltIn {
-        private class DateParser
-        implements
-            TemplateDateModel,
-            TemplateMethodModel,
-            TemplateHashModel {
-            private final String text;
-            private final Environment env;
-            private final TemplateDateFormat defaultFormat;
-            private TemplateDateModel cachedValue;
-            
-            DateParser(String text, Environment env)
-            throws TemplateException {
-                this.text = text;
-                this.env = env;
-                this.defaultFormat = env.getTemplateDateFormat(dateType, Date.class, target, false);
-            }
-            
-            @Override
-            public Object exec(List args) throws TemplateModelException {
-                checkMethodArgCount(args, 0, 1);
-                return args.size() == 0 ? getAsDateModel() : get((String) args.get(0));
-            }
-            
-            @Override
-            public TemplateModel get(String pattern) throws TemplateModelException {
-                TemplateDateFormat format;
-                try {
-                    format = env.getTemplateDateFormat(pattern, dateType, Date.class, target, dateBI.this, true);
-                } catch (TemplateException e) {
-                    // `e` should always be a TemplateModelException here, but to be sure: 
-                    throw _CoreAPI.ensureIsTemplateModelException("Failed to get format", e); 
-                }
-                return toTemplateDateModel(parse(format));
-            }
-
-            private TemplateDateModel toTemplateDateModel(Object date) throws _TemplateModelException {
-                if (date instanceof Date) {
-                    return new SimpleDate((Date) date, dateType);
-                } else {
-                    TemplateDateModel tm = (TemplateDateModel) date;
-                    if (tm.getDateType() != dateType) {
-                        throw new _TemplateModelException("The result of the parsing was of the wrong date type.");
-                    }
-                    return tm;
-                }
-            }
-
-            private TemplateDateModel getAsDateModel() throws TemplateModelException {
-                if (cachedValue == null) {
-                    cachedValue = toTemplateDateModel(parse(defaultFormat));
-                }
-                return cachedValue;
-            }
-            
-            @Override
-            public Date getAsDate() throws TemplateModelException {
-                return getAsDateModel().getAsDate();
-            }
-    
-            @Override
-            public int getDateType() {
-                return dateType;
-            }
-    
-            @Override
-            public boolean isEmpty() {
-                return false;
-            }
-    
-            private Object parse(TemplateDateFormat df)
-            throws TemplateModelException {
-                try {
-                    return df.parse(text, dateType);
-                } catch (TemplateValueFormatException e) {
-                    throw new _TemplateModelException(e,
-                            "The string doesn't match the expected date/time/date-time format. "
-                            + "The string to parse was: ", new _DelayedJQuote(text), ". ",
-                            "The expected format was: ", new _DelayedJQuote(df.getDescription()), ".",
-                            e.getMessage() != null ? "\nThe nested reason given follows:\n" : "",
-                            e.getMessage() != null ? e.getMessage() : "");
-                }
-            }
-            
-        }
-        
-        private final int dateType;
-        
-        dateBI(int dateType) {
-            this.dateType = dateType;
-        }
-        
-        @Override
-        TemplateModel _eval(Environment env)
-                throws TemplateException {
-            TemplateModel model = target.eval(env);
-            if (model instanceof TemplateDateModel) {
-                TemplateDateModel dmodel = (TemplateDateModel) model;
-                int dtype = dmodel.getDateType();
-                // Any date model can be coerced into its own type
-                if (dateType == dtype) {
-                    return model;
-                }
-                // unknown and datetime can be coerced into any date type
-                if (dtype == TemplateDateModel.UNKNOWN || dtype == TemplateDateModel.DATETIME) {
-                    return new SimpleDate(dmodel.getAsDate(), dateType);
-                }
-                throw new _MiscTemplateException(this,
-                            "Cannot convert ", TemplateDateModel.TYPE_NAMES.get(dtype),
-                            " to ", TemplateDateModel.TYPE_NAMES.get(dateType));
-            }
-            // Otherwise, interpret as a string and attempt 
-            // to parse it into a date.
-            String s = target.evalAndCoerceToPlainText(env);
-            return new DateParser(s, env);
-        }
-
-    }
-
-    static class apiBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            if (!env.isAPIBuiltinEnabled()) {
-                throw new _MiscTemplateException(this,
-                        "Can't use ?api, because the \"", Configurable.API_BUILTIN_ENABLED_KEY,
-                        "\" configuration setting is false. Think twice before you set it to true though. Especially, "
-                        + "it shouldn't abussed for modifying Map-s and Collection-s.");
-            }
-            final TemplateModel tm = target.eval(env);
-            if (!(tm instanceof TemplateModelWithAPISupport)) {
-                target.assertNonNull(tm, env);
-                throw new APINotSupportedTemplateException(env, target, tm);
-            }
-            return ((TemplateModelWithAPISupport) tm).getAPI();
-        }
-    }
-
-    static class has_apiBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            final TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return tm instanceof TemplateModelWithAPISupport ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-    
-    static class is_booleanBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateBooleanModel)  ?
-                TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_collectionBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateCollectionModel) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_collection_exBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateCollectionModelEx) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_dateLikeBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateDateModel)  ?
-                TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_dateOfTypeBI extends BuiltIn {
-        
-        private final int dateType;
-        
-        is_dateOfTypeBI(int dateType) {
-            this.dateType = dateType;
-        }
-
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateDateModel) && ((TemplateDateModel) tm).getDateType() == dateType
-                ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_directiveBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            // WRONG: it also had to check Macro.isFunction()
-            return (tm instanceof TemplateTransformModel || tm instanceof Macro || tm instanceof TemplateDirectiveModel) ?
-                TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_enumerableBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateSequenceModel || tm instanceof TemplateCollectionModel)
-                    && (_TemplateAPI.getTemplateLanguageVersionAsInt(this) < _TemplateAPI.VERSION_INT_2_3_21
-                        // These implement TemplateSequenceModel, yet they can't be #list-ed:
-                        || !(tm instanceof SimpleMethodModel || tm instanceof OverloadedMethodsModel))
-                    ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_hash_exBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateHashModelEx) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_hashBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateHashModel) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_indexableBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateSequenceModel) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_macroBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            // WRONG: it also had to check Macro.isFunction()
-            return (tm instanceof Macro)  ?
-                TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_markup_outputBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateMarkupOutputModel)  ?
-                TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-    
-    static class is_methodBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateMethodModel)  ?
-                TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_nodeBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateNodeModel)  ?
-                TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_numberBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateNumberModel)  ?
-                TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_sequenceBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateSequenceModel
-                        && (
-                            !(tm instanceof OverloadedMethodsModel || tm instanceof SimpleMethodModel)
-                            || !env.isIcI2324OrLater())
-                        )
-                        ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_stringBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateScalarModel)  ?
-                TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class is_transformBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            target.assertNonNull(tm, env);
-            return (tm instanceof TemplateTransformModel)  ?
-                TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    static class namespaceBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel tm = target.eval(env);
-            if (!(tm instanceof Macro)) {
-                throw new UnexpectedTypeException(
-                        target, tm,
-                        "macro or function", new Class[] { Macro.class },
-                        env);
-            } else {
-                return env.getMacroNamespace((Macro) tm);
-            }
-        }
-    }
-
-    static class sizeBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel model = target.eval(env);
-
-            final int size;
-            if (model instanceof TemplateSequenceModel) {
-                size = ((TemplateSequenceModel) model).size();
-            } else if (model instanceof TemplateCollectionModelEx) {
-                size = ((TemplateCollectionModelEx) model).size();
-            } else if (model instanceof TemplateHashModelEx) {
-                size = ((TemplateHashModelEx) model).size();
-            } else {
-                throw new UnexpectedTypeException(
-                        target, model,
-                        "extended-hash or sequence or extended collection",
-                        new Class[] {
-                                TemplateHashModelEx.class,
-                                TemplateSequenceModel.class,
-                                TemplateCollectionModelEx.class
-                        },
-                        env);
-            }
-            return new SimpleNumber(size);
-        }
-    }
-    
-    static class stringBI extends BuiltIn {
-        
-        private class BooleanFormatter
-        implements 
-            TemplateScalarModel, 
-            TemplateMethodModel {
-            private final TemplateBooleanModel bool;
-            private final Environment env;
-            
-            BooleanFormatter(TemplateBooleanModel bool, Environment env) {
-                this.bool = bool;
-                this.env = env;
-            }
-    
-            @Override
-            public Object exec(List args) throws TemplateModelException {
-                checkMethodArgCount(args, 2);
-                return new SimpleScalar((String) args.get(bool.getAsBoolean() ? 0 : 1));
-            }
-    
-            @Override
-            public String getAsString() throws TemplateModelException {
-                // Boolean should have come first... but that change would be non-BC. 
-                if (bool instanceof TemplateScalarModel) {
-                    return ((TemplateScalarModel) bool).getAsString();
-                } else {
-                    try {
-                        return env.formatBoolean(bool.getAsBoolean(), true);
-                    } catch (TemplateException e) {
-                        throw new TemplateModelException(e);
-                    }
-                }
-            }
-        }
-    
-        private class DateFormatter
-        implements
-            TemplateScalarModel,
-            TemplateHashModel,
-            TemplateMethodModel {
-            private final TemplateDateModel dateModel;
-            private final Environment env;
-            private final TemplateDateFormat defaultFormat;
-            private String cachedValue;
-    
-            DateFormatter(TemplateDateModel dateModel, Environment env)
-            throws TemplateException {
-                this.dateModel = dateModel;
-                this.env = env;
-                
-                final int dateType = dateModel.getDateType();
-                this.defaultFormat = dateType == TemplateDateModel.UNKNOWN
-                        ? null  // Lazy unknown type error in getAsString()
-                        : env.getTemplateDateFormat(
-                                dateType, EvalUtil.modelToDate(dateModel, target).getClass(), target, true);
-            }
-    
-            @Override
-            public Object exec(List args) throws TemplateModelException {
-                checkMethodArgCount(args, 1);
-                return formatWith((String) args.get(0));
-            }
-
-            @Override
-            public TemplateModel get(String key)
-            throws TemplateModelException {
-                return formatWith(key);
-            }
-
-            private TemplateModel formatWith(String key)
-            throws TemplateModelException {
-                try {
-                    return new SimpleScalar(env.formatDateToPlainText(dateModel, key, target, stringBI.this, true));
-                } catch (TemplateException e) {
-                    // `e` should always be a TemplateModelException here, but to be sure: 
-                    throw _CoreAPI.ensureIsTemplateModelException("Failed to format value", e); 
-                }
-            }
-            
-            @Override
-            public String getAsString()
-            throws TemplateModelException {
-                if (cachedValue == null) {
-                    if (defaultFormat == null) {
-                        if (dateModel.getDateType() == TemplateDateModel.UNKNOWN) {
-                            throw MessageUtil.newCantFormatUnknownTypeDateException(target, null);
-                        } else {
-                            throw new BugException();
-                        }
-                    }
-                    try {
-                        cachedValue = EvalUtil.assertFormatResultNotNull(defaultFormat.formatToPlainText(dateModel));
-                    } catch (TemplateValueFormatException e) {
-                        try {
-                            throw MessageUtil.newCantFormatDateException(defaultFormat, target, e, true);
-                        } catch (TemplateException e2) {
-                            // `e` should always be a TemplateModelException here, but to be sure: 
-                            throw _CoreAPI.ensureIsTemplateModelException("Failed to format date/time/datetime", e2); 
-                        }
-                    }
-                }
-                return cachedValue;
-            }
-    
-            @Override
-            public boolean isEmpty() {
-                return false;
-            }
-        }
-        
-        private class NumberFormatter
-        implements
-            TemplateScalarModel,
-            TemplateHashModel,
-            TemplateMethodModel {
-            private final TemplateNumberModel numberModel;
-            private final Number number;
-            private final Environment env;
-            private final TemplateNumberFormat defaultFormat;
-            private String cachedValue;
-    
-            NumberFormatter(TemplateNumberModel numberModel, Environment env) throws TemplateException {
-                this.env = env;
-                
-                // As we format lazily, we need a snapshot of the format inputs:
-                this.numberModel = numberModel;
-                number = EvalUtil.modelToNumber(numberModel, target);  // for BackwardCompatibleTemplateNumberFormat-s
-                try {
-                    defaultFormat = env.getTemplateNumberFormat(stringBI.this, true);
-                } catch (TemplateException e) {
-                    // `e` should always be a TemplateModelException here, but to be sure: 
-                    throw _CoreAPI.ensureIsTemplateModelException("Failed to get default number format", e); 
-                }
-            }
-    
-            @Override
-            public Object exec(List args) throws TemplateModelException {
-                checkMethodArgCount(args, 1);
-                return get((String) args.get(0));
-            }
-    
-            @Override
-            public TemplateModel get(String key) throws TemplateModelException {
-                TemplateNumberFormat format;
-                try {
-                    format = env.getTemplateNumberFormat(key, stringBI.this, true);
-                } catch (TemplateException e) {
-                    // `e` should always be a TemplateModelException here, but to be sure: 
-                    throw _CoreAPI.ensureIsTemplateModelException("Failed to get number format", e); 
-                }
-                
-                String result;
-                try {
-                    if (format instanceof BackwardCompatibleTemplateNumberFormat) {
-                        result = env.formatNumberToPlainText(number, (BackwardCompatibleTemplateNumberFormat) format, target);
-                    } else {
-                        result = env.formatNumberToPlainText(numberModel, format, target, true);
-                    }
-                } catch (TemplateException e) {
-                    // `e` should always be a TemplateModelException here, but to be sure: 
-                    throw _CoreAPI.ensureIsTemplateModelException("Failed to format number", e); 
-                }
-                
-                return new SimpleScalar(result);
-            }
-            
-            @Override
-            public String getAsString() throws TemplateModelException {
-                if (cachedValue == null) {
-                    try {
-                        if (defaultFormat instanceof BackwardCompatibleTemplateNumberFormat) {
-                            cachedValue = env.formatNumberToPlainText(
-                                    number, (BackwardCompatibleTemplateNumberFormat) defaultFormat, target);
-                        } else {
-                            cachedValue = env.formatNumberToPlainText(numberModel, defaultFormat, target, true);
-                        }
-                    } catch (TemplateException e) {
-                        // `e` should always be a TemplateModelException here, but to be sure: 
-                        throw _CoreAPI.ensureIsTemplateModelException("Failed to format number", e); 
-                    }
-                }
-                return cachedValue;
-            }
-    
-            @Override
-            public boolean isEmpty() {
-                return false;
-            }
-        }
-    
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel model = target.eval(env);
-            if (model instanceof TemplateNumberModel) {
-                TemplateNumberModel numberModel = (TemplateNumberModel) model;
-                Number num = EvalUtil.modelToNumber(numberModel, target);
-                return new NumberFormatter(numberModel, env);
-            } else if (model instanceof TemplateDateModel) {
-                TemplateDateModel dm = (TemplateDateModel) model;
-                return new DateFormatter(dm, env);
-            } else if (model instanceof SimpleScalar) {
-                return model;
-            } else if (model instanceof TemplateBooleanModel) {
-                return new BooleanFormatter((TemplateBooleanModel) model, env);
-            } else if (model instanceof TemplateScalarModel) {
-                return new SimpleScalar(((TemplateScalarModel) model).getAsString());
-            } else {            
-                throw new UnexpectedTypeException(
-                        target, model,
-                        "number, date, boolean or string",
-                        new Class[] {
-                            TemplateNumberModel.class, TemplateDateModel.class, TemplateBooleanModel.class,
-                            TemplateScalarModel.class
-                        },
-                        env);
-            }
-        }
-    }
-
-    // Can't be instantiated
-    private BuiltInsForMultipleTypes() { }
-
-    static abstract class AbstractCBI extends BuiltIn {
-        
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel model = target.eval(env);
-            if (model instanceof TemplateNumberModel) {
-                return formatNumber(env, model);
-            } else if (model instanceof TemplateBooleanModel) {
-                return new SimpleScalar(((TemplateBooleanModel) model).getAsBoolean()
-                        ? MiscUtil.C_TRUE : MiscUtil.C_FALSE);
-            } else {
-                throw new UnexpectedTypeException(
-                        target, model,
-                        "number or boolean", new Class[] { TemplateNumberModel.class, TemplateBooleanModel.class },
-                        env);
-            }
-        }
-    
-        protected abstract TemplateModel formatNumber(Environment env, TemplateModel model) throws TemplateModelException;
-        
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/BuiltInsForNodes.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForNodes.java b/src/main/java/freemarker/core/BuiltInsForNodes.java
deleted file mode 100644
index 9b72f8e..0000000
--- a/src/main/java/freemarker/core/BuiltInsForNodes.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package freemarker.core;
-
-import java.util.List;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import freemarker.ext.dom._ExtDomApi;
-import freemarker.template.SimpleScalar;
-import freemarker.template.SimpleSequence;
-import freemarker.template.TemplateMethodModel;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-import freemarker.template.TemplateNodeModel;
-import freemarker.template.TemplateNodeModelEx;
-
-/**
- * A holder for builtins that operate exclusively on (XML-)node left-hand value.
- */
-class BuiltInsForNodes {
-    
-    static class ancestorsBI extends BuiltInForNode {
-       @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
-           AncestorSequence result = new AncestorSequence(env);
-           TemplateNodeModel parent = nodeModel.getParentNode();
-           while (parent != null) {
-               result.add(parent);
-               parent = parent.getParentNode();
-           }
-           return result;
-       }
-    }
-    
-    static class childrenBI extends BuiltInForNode {
-       @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
-            return nodeModel.getChildNodes();
-       }
-    }
-    
-    static class node_nameBI extends BuiltInForNode {
-       @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
-            return new SimpleScalar(nodeModel.getNodeName());
-       }
-    }
-    
-    
-    static class node_namespaceBI extends BuiltInForNode {
-        @Override
-        TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
-            String nsURI = nodeModel.getNodeNamespace();
-            return nsURI == null ? null : new SimpleScalar(nsURI);
-        }
-    }
-    
-    static class node_typeBI extends BuiltInForNode {
-       @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
-            return new SimpleScalar(nodeModel.getNodeType());
-        }
-    }
-
-    static class parentBI extends BuiltInForNode {
-       @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
-            return nodeModel.getParentNode();
-       }
-    }
-    
-    static class rootBI extends BuiltInForNode {
-       @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
-            TemplateNodeModel result = nodeModel;
-            TemplateNodeModel parent = nodeModel.getParentNode();
-            while (parent != null) {
-                result = parent;
-                parent = result.getParentNode();
-            }
-            return result;
-       }
-    }
-
-    static class previousSiblingBI extends BuiltInForNodeEx {
-        @Override
-        TemplateModel calculateResult(TemplateNodeModelEx nodeModel, Environment env) throws TemplateModelException {
-            return nodeModel.getPreviousSibling();
-        }
-    }
-
-    static class nextSiblingBI extends  BuiltInForNodeEx {
-        @Override
-        TemplateModel calculateResult(TemplateNodeModelEx nodeModel, Environment env) throws TemplateModelException {
-            return nodeModel.getNextSibling();
-        }
-    }
-    
-    // Can't be instantiated
-    private BuiltInsForNodes() { }
-
-    static class AncestorSequence extends SimpleSequence implements TemplateMethodModel {
-        
-        @SuppressFBWarnings(value="SE_BAD_FIELD",
-                justification="Can't make this Serializable, and not extneding SimpleSequence would be non-BC.")
-        private Environment env;
-        
-        AncestorSequence(Environment env) {
-            this.env = env;
-        }
-        
-        public Object exec(List names) throws TemplateModelException {
-            if (names == null || names.isEmpty()) {
-                return this;
-            }
-            AncestorSequence result = new AncestorSequence(env);
-            for (int i = 0; i < size(); i++) {
-                TemplateNodeModel tnm = (TemplateNodeModel) get(i);
-                String nodeName = tnm.getNodeName();
-                String nsURI = tnm.getNodeNamespace();
-                if (nsURI == null) {
-                    if (names.contains(nodeName)) {
-                        result.add(tnm);
-                    }
-                } else {
-                    for (int j = 0; j < names.size(); j++) {
-                        if (_ExtDomApi.matchesName((String) names.get(j), nodeName, nsURI, env)) {
-                            result.add(tnm);
-                            break;
-                        }
-                    }
-                }
-            }
-            return result;
-        }
-    }    
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/BuiltInsForNumbers.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForNumbers.java b/src/main/java/freemarker/core/BuiltInsForNumbers.java
deleted file mode 100644
index 2a3bb31..0000000
--- a/src/main/java/freemarker/core/BuiltInsForNumbers.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package freemarker.core;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Date;
-
-import freemarker.template.SimpleDate;
-import freemarker.template.SimpleNumber;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateBooleanModel;
-import freemarker.template.TemplateDateModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-import freemarker.template.TemplateNumberModel;
-import freemarker.template.utility.NumberUtil;
-import freemarker.template.utility.StringUtil;
-
-/**
- * A holder for builtins that operate exclusively on number left-hand value.
- */
-class BuiltInsForNumbers {
-
-    private static abstract class abcBI extends BuiltInForNumber {
-
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateModelException {
-            final int n;
-            try {
-                n = NumberUtil.toIntExact(num);
-            } catch (ArithmeticException e) {
-                throw new _TemplateModelException(target,
-                        "The left side operand value isn't compatible with ?", key, ": ", e.getMessage());
-         
-            }
-            if (n <= 0) {
-                throw new _TemplateModelException(target,
-                        "The left side operand of to ?", key, " must be at least 1, but was ", Integer.valueOf(n), ".");
-            }
-            return new SimpleScalar(toABC(n));
-        }
-
-        protected abstract String toABC(int n);
-        
-    }
-
-    static class lower_abcBI extends abcBI {
-
-        @Override
-        protected String toABC(int n) {
-            return StringUtil.toLowerABC(n);
-        }
-        
-    }
-
-    static class upper_abcBI extends abcBI {
-
-        @Override
-        protected String toABC(int n) {
-            return StringUtil.toUpperABC(n);
-        }
-        
-    }
-    
-    static class absBI extends BuiltInForNumber {
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateModelException {
-            if (num instanceof Integer) {
-                int n = ((Integer) num).intValue();
-                if (n < 0) {
-                    return new SimpleNumber(-n);
-                } else {
-                    return model;
-                }
-            } else if (num instanceof BigDecimal) {
-                BigDecimal n = (BigDecimal) num;
-                if (n.signum() < 0) {
-                    return new SimpleNumber(n.negate());
-                } else {
-                    return model;
-                }
-            } else if (num instanceof Double) {
-                double n = ((Double) num).doubleValue();
-                if (n < 0) {
-                    return new SimpleNumber(-n);
-                } else {
-                    return model;
-                }
-            } else if (num instanceof Float) {
-                float n = ((Float) num).floatValue();
-                if (n < 0) {
-                    return new SimpleNumber(-n);
-                } else {
-                    return model;
-                }
-            } else if (num instanceof Long) {
-                long n = ((Long) num).longValue();
-                if (n < 0) {
-                    return new SimpleNumber(-n);
-                } else {
-                    return model;
-                }
-            } else if (num instanceof Short) {
-                short n = ((Short) num).shortValue();
-                if (n < 0) {
-                    return new SimpleNumber(-n);
-                } else {
-                    return model;
-                }
-            } else if (num instanceof Byte) {
-                byte n = ((Byte) num).byteValue();
-                if (n < 0) {
-                    return new SimpleNumber(-n);
-                } else {
-                    return model;
-                }
-            } else if (num instanceof BigInteger) {
-                BigInteger n = (BigInteger) num;
-                if (n.signum() < 0) {
-                    return new SimpleNumber(n.negate());
-                } else {
-                    return model;
-                }
-            } else {
-                throw new _TemplateModelException("Unsupported number class: ", num.getClass());
-            }            
-        }
-    }
-    
-    static class byteBI extends BuiltInForNumber {
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) {
-            if (num instanceof Byte) {
-                return model;
-            }
-            return new SimpleNumber(Byte.valueOf(num.byteValue()));
-        }
-    }
-
-    static class ceilingBI extends BuiltInForNumber {
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) {
-            return new SimpleNumber(new BigDecimal(num.doubleValue()).divide(BIG_DECIMAL_ONE, 0, BigDecimal.ROUND_CEILING));
-        }
-    }
-
-    static class doubleBI extends BuiltInForNumber {
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) {
-            if (num instanceof Double) {
-                return model;
-            }
-            return new SimpleNumber(num.doubleValue());
-        }
-    }
-
-    static class floatBI extends BuiltInForNumber {
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) {
-            if (num instanceof Float) {
-                return model;
-            }
-            return new SimpleNumber(num.floatValue());
-        }
-    }
-
-    static class floorBI extends BuiltInForNumber {
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) {
-            return new SimpleNumber(new BigDecimal(num.doubleValue()).divide(BIG_DECIMAL_ONE, 0, BigDecimal.ROUND_FLOOR));
-        }
-    }
-
-    static class intBI extends BuiltInForNumber {
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) {
-            if (num instanceof Integer) {
-                return model;
-            }
-            return new SimpleNumber(num.intValue());
-        }
-    }
-
-    static class is_infiniteBI extends BuiltInForNumber {
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateModelException {
-            return NumberUtil.isInfinite(num) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-
-    static class is_nanBI extends BuiltInForNumber {
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateModelException {
-            return NumberUtil.isNaN(num) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
-        }
-    }
-
-    // Does both someNumber?long and someDate?long, thus it doesn't extend NumberBuiltIn
-    static class longBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env)
-                throws TemplateException {
-            TemplateModel model = target.eval(env);
-            if (!(model instanceof TemplateNumberModel)
-                    && model instanceof TemplateDateModel) {
-                Date date = EvalUtil.modelToDate((TemplateDateModel) model, target);
-                return new SimpleNumber(date.getTime());
-            } else {
-                Number num = target.modelToNumber(model, env);
-                if (num instanceof Long) {
-                    return model;
-                }
-                return new SimpleNumber(num.longValue());
-            }
-        }
-    }
-
-    static class number_to_dateBI extends BuiltInForNumber {
-        
-        private final int dateType;
-        
-        number_to_dateBI(int dateType) {
-            this.dateType = dateType;
-        }
-        
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model)
-        throws TemplateModelException {
-            return new SimpleDate(new Date(safeToLong(num)), dateType);
-        }
-    }
-
-    static class roundBI extends BuiltInForNumber {
-        private static final BigDecimal half = new BigDecimal("0.5");
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) {
-            return new SimpleNumber(new BigDecimal(num.doubleValue()).add(half).divide(BIG_DECIMAL_ONE, 0, BigDecimal.ROUND_FLOOR));
-        }
-    }
-    
-    static class shortBI extends BuiltInForNumber {
-        @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) {
-            if (num instanceof Short) {
-                return model;
-            }
-            return new SimpleNumber(Short.valueOf(num.shortValue()));
-        }
-    }
-
-    private static final long safeToLong(Number num) throws TemplateModelException {
-        if (num instanceof Double) {
-            double d = Math.round(((Double) num).doubleValue());
-            if (d > Long.MAX_VALUE || d < Long.MIN_VALUE) {
-                throw new _TemplateModelException(
-                        "Number doesn't fit into a 64 bit signed integer (long): ", Double.valueOf(d));
-            } else {
-                return (long) d;
-            }
-        } else if (num instanceof Float) {
-            float f = Math.round(((Float) num).floatValue());
-            if (f > Long.MAX_VALUE || f < Long.MIN_VALUE) {
-                throw new _TemplateModelException(
-                        "Number doesn't fit into a 64 bit signed integer (long): ", Float.valueOf(f));
-            } else {
-                return (long) f;
-            }
-        } else if (num instanceof BigDecimal) {
-            BigDecimal bd = ((BigDecimal) num).setScale(0, BigDecimal.ROUND_HALF_UP);
-            if (bd.compareTo(BIG_DECIMAL_LONG_MAX) > 0 || bd.compareTo(BIG_DECIMAL_LONG_MIN) < 0) {
-                throw new _TemplateModelException("Number doesn't fit into a 64 bit signed integer (long): ", bd);
-            } else {
-                return bd.longValue();
-            }
-        } else if (num instanceof BigInteger) {
-            BigInteger bi = (BigInteger) num;
-            if (bi.compareTo(BIG_INTEGER_LONG_MAX) > 0 || bi.compareTo(BIG_INTEGER_LONG_MIN) < 0) {
-                throw new _TemplateModelException("Number doesn't fit into a 64 bit signed integer (long): ", bi);
-            } else {
-                return bi.longValue();
-            }
-        } else if (num instanceof Long || num instanceof Integer || num instanceof Byte || num instanceof Short) {
-            return num.longValue();
-        } else {
-            // Should add Atomic* types in 2.4...
-            throw new _TemplateModelException("Unsupported number type: ", num.getClass());
-        }
-    }
-    
-    private static final BigDecimal BIG_DECIMAL_ONE = new BigDecimal("1");
-    private static final BigDecimal BIG_DECIMAL_LONG_MIN = BigDecimal.valueOf(Long.MIN_VALUE); 
-    private static final BigDecimal BIG_DECIMAL_LONG_MAX = BigDecimal.valueOf(Long.MAX_VALUE);
-    private static final BigInteger BIG_INTEGER_LONG_MIN = BigInteger.valueOf(Long.MIN_VALUE); 
-    
-    private static final BigInteger BIG_INTEGER_LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE);
-    
-    // Can't be instantiated
-    private BuiltInsForNumbers() { }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/BuiltInsForOutputFormatRelated.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForOutputFormatRelated.java b/src/main/java/freemarker/core/BuiltInsForOutputFormatRelated.java
deleted file mode 100644
index 8c8da51..0000000
--- a/src/main/java/freemarker/core/BuiltInsForOutputFormatRelated.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package freemarker.core;
-
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-class BuiltInsForOutputFormatRelated {
-
-    static class no_escBI extends AbstractConverterBI {
-
-        @Override
-        protected TemplateModel calculateResult(String lho, MarkupOutputFormat outputFormat, Environment env)
-                throws TemplateException {
-            return outputFormat.fromMarkup(lho);
-        }
-        
-    }
-
-    static class escBI extends AbstractConverterBI {
-
-        @Override
-        protected TemplateModel calculateResult(String lho, MarkupOutputFormat outputFormat, Environment env)
-                throws TemplateException {
-            return outputFormat.fromPlainTextByEscaping(lho);
-        }
-        
-    }
-    
-    static abstract class AbstractConverterBI extends MarkupOutputFormatBoundBuiltIn {
-
-        @Override
-        protected TemplateModel calculateResult(Environment env) throws TemplateException {
-            TemplateModel lhoTM = target.eval(env);
-            Object lhoMOOrStr = EvalUtil.coerceModelToStringOrMarkup(lhoTM, target, null, env);
-            MarkupOutputFormat contextOF = outputFormat;
-            if (lhoMOOrStr instanceof String) { // TemplateMarkupOutputModel
-                return calculateResult((String) lhoMOOrStr, contextOF, env);
-            } else {
-                TemplateMarkupOutputModel lhoMO = (TemplateMarkupOutputModel) lhoMOOrStr;
-                MarkupOutputFormat lhoOF = lhoMO.getOutputFormat();
-                // ATTENTION: Keep this logic in sync. with ${...}'s logic!
-                if (lhoOF == contextOF || contextOF.isOutputFormatMixingAllowed()) {
-                    // bypass
-                    return lhoMO;
-                } else {
-                    // ATTENTION: Keep this logic in sync. with ${...}'s logic!
-                    String lhoPlainTtext = lhoOF.getSourcePlainText(lhoMO);
-                    if (lhoPlainTtext == null) {
-                        throw new _TemplateModelException(target,
-                                "The left side operand of ?", key, " is in ", new _DelayedToString(lhoOF),
-                                " format, which differs from the current output format, ",
-                                new _DelayedToString(contextOF), ". Conversion wasn't possible.");
-                    }
-                    // Here we know that lho is escaped plain text. So we re-escape it to the current format and
-                    // bypass it, just as if the two output formats were the same earlier.
-                    return contextOF.fromPlainTextByEscaping(lhoPlainTtext);
-                }
-            }
-        }
-        
-        protected abstract TemplateModel calculateResult(String lho, MarkupOutputFormat outputFormat, Environment env)
-                throws TemplateException;
-        
-    }
-    
-}


Mime
View raw message