http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/MethodCall.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/MethodCall.java b/src/main/java/org/apache/freemarker/core/ast/MethodCall.java deleted file mode 100644 index 802fcda..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/MethodCall.java +++ /dev/null @@ -1,149 +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. - */ - -/* - * 22 October 1999: This class added by Holger Arendt. - */ - -package org.apache.freemarker.core.ast; - -import java.io.IOException; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; - -import org.apache.freemarker.core.TemplateException; -import org.apache.freemarker.core.model.TemplateMethodModel; -import org.apache.freemarker.core.model.TemplateMethodModelEx; -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.util._NullWriter; - - -/** - * A unary operator that calls a TemplateMethodModel. It associates with the - * <tt>Identifier</tt> or <tt>Dot</tt> to its left. - */ -final class MethodCall extends Expression { - - private final Expression target; - private final ListLiteral arguments; - - MethodCall(Expression target, ArrayList arguments) { - this(target, new ListLiteral(arguments)); - } - - private MethodCall(Expression target, ListLiteral arguments) { - this.target = target; - this.arguments = arguments; - } - - @Override - TemplateModel _eval(Environment env) throws TemplateException { - TemplateModel targetModel = target.eval(env); - if (targetModel instanceof TemplateMethodModel) { - TemplateMethodModel targetMethod = (TemplateMethodModel) targetModel; - List argumentStrings = - targetMethod instanceof TemplateMethodModelEx - ? arguments.getModelList(env) - : arguments.getValueList(env); - Object result = targetMethod.exec(argumentStrings); - return env.getObjectWrapper().wrap(result); - } else if (targetModel instanceof Macro) { - Macro func = (Macro) targetModel; - env.setLastReturnValue(null); - if (!func.isFunction()) { - throw new _MiscTemplateException(env, "A macro cannot be called in an expression. (Functions can be.)"); - } - Writer prevOut = env.getOut(); - try { - env.setOut(_NullWriter.INSTANCE); - env.invoke(func, null, arguments.items, null, null); - } catch (IOException e) { - // Should not occur - throw new TemplateException("Unexpected exception during function execution", e, env); - } finally { - env.setOut(prevOut); - } - return env.getLastReturnValue(); - } else { - throw new NonMethodException(target, targetModel, env); - } - } - - @Override - public String getCanonicalForm() { - StringBuilder buf = new StringBuilder(); - buf.append(target.getCanonicalForm()); - buf.append("("); - String list = arguments.getCanonicalForm(); - buf.append(list.substring(1, list.length() - 1)); - buf.append(")"); - return buf.toString(); - } - - @Override - String getNodeTypeSymbol() { - return "...(...)"; - } - - TemplateModel getConstantValue() { - return null; - } - - @Override - boolean isLiteral() { - return false; - } - - @Override - protected Expression deepCloneWithIdentifierReplaced_inner( - String replacedIdentifier, Expression replacement, ReplacemenetState replacementState) { - return new MethodCall( - target.deepCloneWithIdentifierReplaced(replacedIdentifier, replacement, replacementState), - (ListLiteral) arguments.deepCloneWithIdentifierReplaced(replacedIdentifier, replacement, replacementState)); - } - - @Override - int getParameterCount() { - return 1 + arguments.items.size(); - } - - @Override - Object getParameterValue(int idx) { - if (idx == 0) { - return target; - } else if (idx < getParameterCount()) { - return arguments.items.get(idx - 1); - } else { - throw new IndexOutOfBoundsException(); - } - } - - @Override - ParameterRole getParameterRole(int idx) { - if (idx == 0) { - return ParameterRole.CALLEE; - } else if (idx < getParameterCount()) { - return ParameterRole.ARGUMENT_VALUE; - } else { - throw new IndexOutOfBoundsException(); - } - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/MiscUtil.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/MiscUtil.java b/src/main/java/org/apache/freemarker/core/ast/MiscUtil.java deleted file mode 100644 index 87b21cf..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/MiscUtil.java +++ /dev/null @@ -1,69 +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 org.apache.freemarker.core.ast; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -/** - * Utilities that didn't fit elsewhere. - */ -class MiscUtil { - - // Can't be instatiated - private MiscUtil() { } - - static final String C_FALSE = "false"; - static final String C_TRUE = "true"; - - /** - * Returns the map entries in source code order of the Expression values. - */ - static List/*Map.Entry*/ sortMapOfExpressions(Map/*<?, Expression>*/ map) { - ArrayList res = new ArrayList(map.entrySet()); - Collections.sort(res, - new Comparator() { // for sorting to source code order - @Override - public int compare(Object o1, Object o2) { - Map.Entry ent1 = (Map.Entry) o1; - Expression exp1 = (Expression) ent1.getValue(); - - Map.Entry ent2 = (Map.Entry) o2; - Expression exp2 = (Expression) ent2.getValue(); - - int res = exp1.beginLine - exp2.beginLine; - if (res != 0) return res; - res = exp1.beginColumn - exp2.beginColumn; - if (res != 0) return res; - - if (ent1 == ent2) return 0; - - // Should never reach this - return ((String) ent1.getKey()).compareTo((String) ent1.getKey()); - } - - }); - return res; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/MixedContent.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/MixedContent.java b/src/main/java/org/apache/freemarker/core/ast/MixedContent.java deleted file mode 100644 index cee20f4..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/MixedContent.java +++ /dev/null @@ -1,102 +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 org.apache.freemarker.core.ast; - -import java.io.IOException; - -import org.apache.freemarker.core.TemplateException; - -/** - * Encapsulates an array of <tt>TemplateElement</tt> objects. - */ -final class MixedContent extends TemplateElement { - - MixedContent() { } - - @Override - TemplateElement postParseCleanup(boolean stripWhitespace) - throws ParseException { - super.postParseCleanup(stripWhitespace); - return getChildCount() == 1 ? getChild(0) : this; - } - - /** - * Processes the contents of the internal <tt>TemplateElement</tt> list, - * and outputs the resulting text. - */ - @Override - TemplateElement[] accept(Environment env) - throws TemplateException, IOException { - return getChildBuffer(); - } - - @Override - protected String dump(boolean canonical) { - if (canonical) { - return getChildrenCanonicalForm(); - } else { - if (getParentElement() == null) { - return "root"; - } - return getNodeTypeSymbol(); // MixedContent is uninteresting in a stack trace. - } - } - - @Override - protected boolean isOutputCacheable() { - int ln = getChildCount(); - for (int i = 0; i < ln; i++) { - if (!getChild(i).isOutputCacheable()) { - return false; - } - } - return true; - } - - @Override - String getNodeTypeSymbol() { - return "#mixed_content"; - } - - @Override - int getParameterCount() { - return 0; - } - - @Override - Object getParameterValue(int idx) { - throw new IndexOutOfBoundsException(); - } - - @Override - ParameterRole getParameterRole(int idx) { - throw new IndexOutOfBoundsException(); - } - - @Override - boolean isIgnorable(boolean stripWhitespace) { - return getChildCount() == 0; - } - - @Override - boolean isNestedBlockRepeater() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NestedContentNotSupportedException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NestedContentNotSupportedException.java b/src/main/java/org/apache/freemarker/core/ast/NestedContentNotSupportedException.java deleted file mode 100644 index 6dc4de0..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NestedContentNotSupportedException.java +++ /dev/null @@ -1,68 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.TemplateException; -import org.apache.freemarker.core.ast.Environment.NestedElementTemplateDirectiveBody; -import org.apache.freemarker.core.ast.ThreadInterruptionSupportTemplatePostProcessor.ThreadInterruptionCheck; -import org.apache.freemarker.core.model.TemplateDirectiveBody; -import org.apache.freemarker.core.util._StringUtil; - -/** - * [2.4] Should become public somehow; this is more intelligent than a {@code null} check, for example, when the body - * only contains a thread interruption check, it treats it as valid. Indicates that the directive shouldn't have - * nested content, but it had. This will probably become public when the directive/method stuff was reworked. - */ -class NestedContentNotSupportedException extends TemplateException { - - public static void check(TemplateDirectiveBody body) throws NestedContentNotSupportedException { - if (body == null) { - return; - } - if (body instanceof NestedElementTemplateDirectiveBody) { - TemplateElement[] tes = ((NestedElementTemplateDirectiveBody) body).getChildrenBuffer(); - if (tes == null || tes.length == 0 - || tes[0] instanceof ThreadInterruptionCheck && (tes.length == 1 || tes[1] == null)) { - return; - } - } - throw new NestedContentNotSupportedException(Environment.getCurrentEnvironment()); - } - - - private NestedContentNotSupportedException(Environment env) { - this(null, null, env); - } - - private NestedContentNotSupportedException(Exception cause, Environment env) { - this(null, cause, env); - } - - private NestedContentNotSupportedException(String description, Environment env) { - this(description, null, env); - } - - private NestedContentNotSupportedException(String description, Exception cause, Environment env) { - super( "Nested content (body) not supported." - + (description != null ? " " + _StringUtil.jQuote(description) : ""), - cause, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NewBI.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NewBI.java b/src/main/java/org/apache/freemarker/core/ast/NewBI.java deleted file mode 100644 index faa5893..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NewBI.java +++ /dev/null @@ -1,74 +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 org.apache.freemarker.core.ast; - -import java.util.List; - -import org.apache.freemarker.core.Template; -import org.apache.freemarker.core.TemplateException; -import org.apache.freemarker.core.model.ObjectWrapper; -import org.apache.freemarker.core.model.TemplateMethodModelEx; -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.model.impl._StaticObjectWrappers; -import org.apache.freemarker.core.model.impl.beans.BeanModel; -import org.apache.freemarker.core.model.impl.beans.BeansWrapper; - -/** - * A built-in that allows us to instantiate an instance of a java class. - * Usage is something like: <tt><#assign foobar = "foo.bar.MyClass"?new()></tt>; - */ -class NewBI extends BuiltIn { - - @Override - TemplateModel _eval(Environment env) - throws TemplateException { - return new ConstructorFunction(target.evalAndCoerceToPlainText(env), env, target.getTemplate()); - } - - class ConstructorFunction implements TemplateMethodModelEx { - - private final Class<?> cl; - private final Environment env; - - public ConstructorFunction(String classname, Environment env, Template template) throws TemplateException { - this.env = env; - cl = env.getNewBuiltinClassResolver().resolve(classname, env, template); - if (!TemplateModel.class.isAssignableFrom(cl)) { - throw new _MiscTemplateException(NewBI.this, env, - "Class ", cl.getName(), " does not implement org.apache.freemarker.core.TemplateModel"); - } - if (BeanModel.class.isAssignableFrom(cl)) { - throw new _MiscTemplateException(NewBI.this, env, - "Bean Models cannot be instantiated using the ?", key, " built-in"); - } - } - - @Override - public Object exec(List arguments) throws TemplateModelException { - ObjectWrapper ow = env.getObjectWrapper(); - BeansWrapper bw = - ow instanceof BeansWrapper - ? (BeansWrapper) ow - : _StaticObjectWrappers.BEANS_WRAPPER; - return bw.newInstance(cl, arguments); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NoAutoEscBlock.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NoAutoEscBlock.java b/src/main/java/org/apache/freemarker/core/ast/NoAutoEscBlock.java deleted file mode 100644 index 27dd39b..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NoAutoEscBlock.java +++ /dev/null @@ -1,79 +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 org.apache.freemarker.core.ast; - -import java.io.IOException; - -import org.apache.freemarker.core.TemplateException; - -/** - * An #noAutoEsc element - */ -final class NoAutoEscBlock extends TemplateElement { - - NoAutoEscBlock(TemplateElements children) { - setChildren(children); - } - - @Override - TemplateElement[] accept(Environment env) throws TemplateException, IOException { - return getChildBuffer(); - } - - @Override - protected String dump(boolean canonical) { - if (canonical) { - return "<" + getNodeTypeSymbol() + "\">" + getChildrenCanonicalForm() + "</" + getNodeTypeSymbol() + ">"; - } else { - return getNodeTypeSymbol(); - } - } - - @Override - String getNodeTypeSymbol() { - return "#noautoesc"; - } - - @Override - int getParameterCount() { - return 0; - } - - @Override - Object getParameterValue(int idx) { - throw new IndexOutOfBoundsException(); - } - - @Override - ParameterRole getParameterRole(int idx) { - throw new IndexOutOfBoundsException(); - } - - @Override - boolean isIgnorable(boolean stripWhitespace) { - return getChildCount() == 0; - } - - @Override - boolean isNestedBlockRepeater() { - return false; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NoEscapeBlock.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NoEscapeBlock.java b/src/main/java/org/apache/freemarker/core/ast/NoEscapeBlock.java deleted file mode 100644 index ca50548..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NoEscapeBlock.java +++ /dev/null @@ -1,79 +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 org.apache.freemarker.core.ast; - -import java.io.IOException; - -import org.apache.freemarker.core.TemplateException; - -/** - */ -class NoEscapeBlock extends TemplateElement { - - NoEscapeBlock(TemplateElements children) { - setChildren(children); - } - - @Override - TemplateElement[] accept(Environment env) throws TemplateException, IOException { - return getChildBuffer(); - } - - @Override - protected String dump(boolean canonical) { - if (canonical) { - return "<" + getNodeTypeSymbol() + '>' + getChildrenCanonicalForm() - + "</" + getNodeTypeSymbol() + '>'; - } else { - return getNodeTypeSymbol(); - } - } - - @Override - int getParameterCount() { - return 0; - } - - @Override - Object getParameterValue(int idx) { - throw new IndexOutOfBoundsException(); - } - - @Override - ParameterRole getParameterRole(int idx) { - throw new IndexOutOfBoundsException(); - } - - @Override - String getNodeTypeSymbol() { - return "#noescape"; - } - - @Override - boolean isOutputCacheable() { - return true; - } - - @Override - boolean isNestedBlockRepeater() { - return false; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonBooleanException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonBooleanException.java b/src/main/java/org/apache/freemarker/core/ast/NonBooleanException.java deleted file mode 100644 index d295eeb..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonBooleanException.java +++ /dev/null @@ -1,62 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateBooleanModel; -import org.apache.freemarker.core.model.TemplateModel; - -/** - * Indicates that a {@link TemplateBooleanModel} value was expected, but the value had a different type. - */ -public class NonBooleanException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { TemplateBooleanModel.class }; - - public NonBooleanException(Environment env) { - super(env, "Expecting boolean value here"); - } - - public NonBooleanException(String description, Environment env) { - super(env, description); - } - - NonBooleanException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonBooleanException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "boolean", EXPECTED_TYPES, env); - } - - NonBooleanException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "boolean", EXPECTED_TYPES, tip, env); - } - - NonBooleanException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "boolean", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonDateException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonDateException.java b/src/main/java/org/apache/freemarker/core/ast/NonDateException.java deleted file mode 100644 index 2b8e7d9..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonDateException.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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateDateModel; -import org.apache.freemarker.core.model.TemplateModel; - -/** - * Indicates that a {@link TemplateDateModel} value was expected, but the value had a different type. - */ -public class NonDateException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { TemplateDateModel.class }; - - public NonDateException(Environment env) { - super(env, "Expecting date/time value here"); - } - - public NonDateException(String description, Environment env) { - super(env, description); - } - - NonDateException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "date/time", EXPECTED_TYPES, env); - } - - NonDateException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "date/time", EXPECTED_TYPES, tip, env); - } - - NonDateException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "date/time", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonExtendedHashException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonExtendedHashException.java b/src/main/java/org/apache/freemarker/core/ast/NonExtendedHashException.java deleted file mode 100644 index b8e3822..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonExtendedHashException.java +++ /dev/null @@ -1,62 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateHashModelEx; -import org.apache.freemarker.core.model.TemplateModel; - -/** - * Indicates that a {@link TemplateHashModelEx} value was expected, but the value had a different type. - */ -public class NonExtendedHashException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { TemplateHashModelEx.class }; - - public NonExtendedHashException(Environment env) { - super(env, "Expecting extended hash value here"); - } - - public NonExtendedHashException(String description, Environment env) { - super(env, description); - } - - NonExtendedHashException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonExtendedHashException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "extended hash", EXPECTED_TYPES, env); - } - - NonExtendedHashException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "extended hash", EXPECTED_TYPES, tip, env); - } - - NonExtendedHashException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "extended hash", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonExtendedNodeException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonExtendedNodeException.java b/src/main/java/org/apache/freemarker/core/ast/NonExtendedNodeException.java deleted file mode 100644 index 16ec013..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonExtendedNodeException.java +++ /dev/null @@ -1,64 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateNodeModelEx; - -/** - * Indicates that a {@link TemplateNodeModelEx} value was expected, but the value had a different type. - * - * @since 2.3.26 - */ -public class NonExtendedNodeException extends UnexpectedTypeException { - - private static final Class<?>[] EXPECTED_TYPES = new Class[] { TemplateNodeModelEx.class }; - - public NonExtendedNodeException(Environment env) { - super(env, "Expecting extended node value here"); - } - - public NonExtendedNodeException(String description, Environment env) { - super(env, description); - } - - NonExtendedNodeException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonExtendedNodeException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "extended node", EXPECTED_TYPES, env); - } - - NonExtendedNodeException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "extended node", EXPECTED_TYPES, tip, env); - } - - NonExtendedNodeException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "extended node", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonHashException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonHashException.java b/src/main/java/org/apache/freemarker/core/ast/NonHashException.java deleted file mode 100644 index 0c64574..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonHashException.java +++ /dev/null @@ -1,64 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateHashModel; -import org.apache.freemarker.core.model.TemplateModel; - -/** - * Indicates that a {@link TemplateHashModel} value was expected, but the value had a different type. - * - * @since 2.3.21 - */ -public class NonHashException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { TemplateHashModel.class }; - - public NonHashException(Environment env) { - super(env, "Expecting hash value here"); - } - - public NonHashException(String description, Environment env) { - super(env, description); - } - - NonHashException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonHashException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "hash", EXPECTED_TYPES, env); - } - - NonHashException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "hash", EXPECTED_TYPES, tip, env); - } - - NonHashException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "hash", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonMarkupOutputException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonMarkupOutputException.java b/src/main/java/org/apache/freemarker/core/ast/NonMarkupOutputException.java deleted file mode 100644 index edf651c..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonMarkupOutputException.java +++ /dev/null @@ -1,63 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateModel; - -/** - * Indicates that a {@link TemplateMarkupOutputModel} value was expected, but the value had a different type. - * - * @since 2.3.24 - */ -public class NonMarkupOutputException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { TemplateMarkupOutputModel.class }; - - public NonMarkupOutputException(Environment env) { - super(env, "Expecting markup output value here"); - } - - public NonMarkupOutputException(String description, Environment env) { - super(env, description); - } - - NonMarkupOutputException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonMarkupOutputException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "markup output", EXPECTED_TYPES, env); - } - - NonMarkupOutputException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "markup output", EXPECTED_TYPES, tip, env); - } - - NonMarkupOutputException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "markup output", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonMethodException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonMethodException.java b/src/main/java/org/apache/freemarker/core/ast/NonMethodException.java deleted file mode 100644 index 5901175..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonMethodException.java +++ /dev/null @@ -1,64 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateMethodModel; -import org.apache.freemarker.core.model.TemplateModel; - -/** - * Indicates that a {@link TemplateMethodModel} value was expected, but the value had a different type. - * - * @since 2.3.21 - */ -public class NonMethodException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { TemplateMethodModel.class }; - - public NonMethodException(Environment env) { - super(env, "Expecting method value here"); - } - - public NonMethodException(String description, Environment env) { - super(env, description); - } - - NonMethodException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonMethodException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "method", EXPECTED_TYPES, env); - } - - NonMethodException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "method", EXPECTED_TYPES, tip, env); - } - - NonMethodException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "method", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonNamespaceException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonNamespaceException.java b/src/main/java/org/apache/freemarker/core/ast/NonNamespaceException.java deleted file mode 100644 index 94557f6..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonNamespaceException.java +++ /dev/null @@ -1,63 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateModel; - -/** - * Indicates that a {@link Environment.Namespace} value was expected, but the value had a different type. - * - * @since 2.3.21 - */ -class NonNamespaceException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { Environment.Namespace.class }; - - public NonNamespaceException(Environment env) { - super(env, "Expecting namespace value here"); - } - - public NonNamespaceException(String description, Environment env) { - super(env, description); - } - - NonNamespaceException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonNamespaceException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "namespace", EXPECTED_TYPES, env); - } - - NonNamespaceException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "namespace", EXPECTED_TYPES, tip, env); - } - - NonNamespaceException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "namespace", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonNodeException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonNodeException.java b/src/main/java/org/apache/freemarker/core/ast/NonNodeException.java deleted file mode 100644 index b0c3731..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonNodeException.java +++ /dev/null @@ -1,64 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateNodeModel; - -/** - * Indicates that a {@link TemplateNodeModel} value was expected, but the value had a different type. - * - * @since 2.3.21 - */ -public class NonNodeException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { TemplateNodeModel.class }; - - public NonNodeException(Environment env) { - super(env, "Expecting node value here"); - } - - public NonNodeException(String description, Environment env) { - super(env, description); - } - - NonNodeException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonNodeException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "node", EXPECTED_TYPES, env); - } - - NonNodeException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "node", EXPECTED_TYPES, tip, env); - } - - NonNodeException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "node", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonNumericalException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonNumericalException.java b/src/main/java/org/apache/freemarker/core/ast/NonNumericalException.java deleted file mode 100644 index f634b43..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonNumericalException.java +++ /dev/null @@ -1,74 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateNumberModel; - -/** - * Indicates that a {@link TemplateNumberModel} value was expected, but the value had a different type. - */ -public class NonNumericalException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { TemplateNumberModel.class }; - - public NonNumericalException(Environment env) { - super(env, "Expecting numerical value here"); - } - - public NonNumericalException(String description, Environment env) { - super(env, description); - } - - NonNumericalException(_ErrorDescriptionBuilder description, Environment env) { - super(env, description); - } - - NonNumericalException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "number", EXPECTED_TYPES, env); - } - - NonNumericalException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "number", EXPECTED_TYPES, tip, env); - } - - NonNumericalException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "number", EXPECTED_TYPES, tips, env); - } - - NonNumericalException( - String assignmentTargetVarName, TemplateModel model, String[] tips, Environment env) - throws InvalidReferenceException { - super(assignmentTargetVarName, model, "number", EXPECTED_TYPES, tips, env); - } - static NonNumericalException newMalformedNumberException(Expression blamed, String text, Environment env) { - return new NonNumericalException( - new _ErrorDescriptionBuilder("Can't convert this string to number: ", new _DelayedJQuote(text)) - .blame(blamed), - env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonSequenceException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonSequenceException.java b/src/main/java/org/apache/freemarker/core/ast/NonSequenceException.java deleted file mode 100644 index 2643855..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonSequenceException.java +++ /dev/null @@ -1,64 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateSequenceModel; - -/** - * Indicates that a {@link TemplateSequenceModel} value was expected, but the value had a different type. - * - * @since 2.3.21 - */ -public class NonSequenceException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { TemplateSequenceModel.class }; - - public NonSequenceException(Environment env) { - super(env, "Expecting sequence value here"); - } - - public NonSequenceException(String description, Environment env) { - super(env, description); - } - - NonSequenceException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonSequenceException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "sequence", EXPECTED_TYPES, env); - } - - NonSequenceException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "sequence", EXPECTED_TYPES, tip, env); - } - - NonSequenceException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "sequence", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonSequenceOrCollectionException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonSequenceOrCollectionException.java b/src/main/java/org/apache/freemarker/core/ast/NonSequenceOrCollectionException.java deleted file mode 100644 index 813c403..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonSequenceOrCollectionException.java +++ /dev/null @@ -1,92 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateCollectionModel; -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateSequenceModel; -import org.apache.freemarker.core.model.WrapperTemplateModel; -import org.apache.freemarker.core.util._CollectionUtil; - -/** - * Indicates that a {@link TemplateSequenceModel} or {@link TemplateCollectionModel} value was expected, but the value - * had a different type. - * - * @since 2.3.21 - */ -public class NonSequenceOrCollectionException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { - TemplateSequenceModel.class, TemplateCollectionModel.class - }; - private static final String ITERABLE_SUPPORT_HINT = "The problematic value is a java.lang.Iterable. Using " - + "DefaultObjectWrapper(..., iterableSupport=true) as the object_wrapper setting of the FreeMarker " - + "configuration should solve this."; - - public NonSequenceOrCollectionException(Environment env) { - super(env, "Expecting sequence or collection value here"); - } - - public NonSequenceOrCollectionException(String description, Environment env) { - super(env, description); - } - - NonSequenceOrCollectionException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonSequenceOrCollectionException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - this(blamed, model, _CollectionUtil.EMPTY_OBJECT_ARRAY, env); - } - - NonSequenceOrCollectionException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - this(blamed, model, new Object[] { tip }, env); - } - - NonSequenceOrCollectionException( - Expression blamed, TemplateModel model, Object[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "sequence or collection", EXPECTED_TYPES, extendTipsIfIterable(model, tips), env); - } - - private static Object[] extendTipsIfIterable(TemplateModel model, Object[] tips) { - if (isWrappedIterable(model)) { - final int tipsLen = tips != null ? tips.length : 0; - Object[] extendedTips = new Object[tipsLen + 1]; - for (int i = 0; i < tipsLen; i++) { - extendedTips[i] = tips[i]; - } - extendedTips[tipsLen] = ITERABLE_SUPPORT_HINT; - return extendedTips; - } else { - return tips; - } - } - - public static boolean isWrappedIterable(TemplateModel model) { - return model instanceof WrapperTemplateModel - && ((WrapperTemplateModel) model).getWrappedObject() instanceof Iterable; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonStringException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonStringException.java b/src/main/java/org/apache/freemarker/core/ast/NonStringException.java deleted file mode 100644 index d1eeb65..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonStringException.java +++ /dev/null @@ -1,74 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateBooleanModel; -import org.apache.freemarker.core.model.TemplateDateModel; -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateNumberModel; -import org.apache.freemarker.core.model.TemplateScalarModel; - -/** - * Indicates that a {@link TemplateScalarModel} value was expected (or maybe something that can be automatically coerced - * to that), but the value had a different type. - */ -public class NonStringException extends UnexpectedTypeException { - - static final String STRING_COERCABLE_TYPES_DESC - = "string or something automatically convertible to string (number, date or boolean)"; - - static final Class[] STRING_COERCABLE_TYPES = new Class[] { - TemplateScalarModel.class, TemplateNumberModel.class, TemplateDateModel.class, TemplateBooleanModel.class - }; - - private static final String DEFAULT_DESCRIPTION - = "Expecting " + NonStringException.STRING_COERCABLE_TYPES_DESC + " value here"; - - public NonStringException(Environment env) { - super(env, DEFAULT_DESCRIPTION); - } - - public NonStringException(String description, Environment env) { - super(env, description); - } - - NonStringException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonStringException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, NonStringException.STRING_COERCABLE_TYPES_DESC, STRING_COERCABLE_TYPES, env); - } - - NonStringException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, NonStringException.STRING_COERCABLE_TYPES_DESC, STRING_COERCABLE_TYPES, tip, env); - } - - NonStringException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, NonStringException.STRING_COERCABLE_TYPES_DESC, STRING_COERCABLE_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonStringOrTemplateOutputException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonStringOrTemplateOutputException.java b/src/main/java/org/apache/freemarker/core/ast/NonStringOrTemplateOutputException.java deleted file mode 100644 index 46740ad..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonStringOrTemplateOutputException.java +++ /dev/null @@ -1,77 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateScalarModel; - -/** - * Indicates that a {@link TemplateScalarModel} (or maybe something that can be automatically coerced - * to that) or {@link TemplateMarkupOutputModel} value was expected, but the value had a different type. - */ -public class NonStringOrTemplateOutputException extends UnexpectedTypeException { - - static final String STRING_COERCABLE_TYPES_OR_TOM_DESC - = NonStringException.STRING_COERCABLE_TYPES_DESC + ", or \"template output\" "; - - static final Class[] STRING_COERCABLE_TYPES_AND_TOM; - static { - STRING_COERCABLE_TYPES_AND_TOM = new Class[NonStringException.STRING_COERCABLE_TYPES.length + 1]; - int i; - for (i = 0; i < NonStringException.STRING_COERCABLE_TYPES.length; i++) { - STRING_COERCABLE_TYPES_AND_TOM[i] = NonStringException.STRING_COERCABLE_TYPES[i]; - } - STRING_COERCABLE_TYPES_AND_TOM[i] = TemplateMarkupOutputModel.class; - }; - - private static final String DEFAULT_DESCRIPTION - = "Expecting " + NonStringOrTemplateOutputException.STRING_COERCABLE_TYPES_OR_TOM_DESC + " value here"; - - public NonStringOrTemplateOutputException(Environment env) { - super(env, DEFAULT_DESCRIPTION); - } - - public NonStringOrTemplateOutputException(String description, Environment env) { - super(env, description); - } - - NonStringOrTemplateOutputException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonStringOrTemplateOutputException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, NonStringOrTemplateOutputException.STRING_COERCABLE_TYPES_OR_TOM_DESC, STRING_COERCABLE_TYPES_AND_TOM, env); - } - - NonStringOrTemplateOutputException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, NonStringOrTemplateOutputException.STRING_COERCABLE_TYPES_OR_TOM_DESC, STRING_COERCABLE_TYPES_AND_TOM, tip, env); - } - - NonStringOrTemplateOutputException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, NonStringOrTemplateOutputException.STRING_COERCABLE_TYPES_OR_TOM_DESC, STRING_COERCABLE_TYPES_AND_TOM, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NonUserDefinedDirectiveLikeException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NonUserDefinedDirectiveLikeException.java b/src/main/java/org/apache/freemarker/core/ast/NonUserDefinedDirectiveLikeException.java deleted file mode 100644 index 3d54a72..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NonUserDefinedDirectiveLikeException.java +++ /dev/null @@ -1,67 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.model.TemplateDirectiveModel; -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateTransformModel; - -/** - * Indicates that a {@link TemplateDirectiveModel} or {@link TemplateTransformModel} or {@link Macro} value was - * expected, but the value had a different type. - * - * @since 2.3.21 - */ -class NonUserDefinedDirectiveLikeException extends UnexpectedTypeException { - - private static final Class[] EXPECTED_TYPES = new Class[] { - TemplateDirectiveModel.class, TemplateTransformModel.class, Macro.class }; - - public NonUserDefinedDirectiveLikeException(Environment env) { - super(env, "Expecting user-defined directive, transform or macro value here"); - } - - public NonUserDefinedDirectiveLikeException(String description, Environment env) { - super(env, description); - } - - NonUserDefinedDirectiveLikeException(Environment env, _ErrorDescriptionBuilder description) { - super(env, description); - } - - NonUserDefinedDirectiveLikeException( - Expression blamed, TemplateModel model, Environment env) - throws InvalidReferenceException { - super(blamed, model, "user-defined directive, transform or macro", EXPECTED_TYPES, env); - } - - NonUserDefinedDirectiveLikeException( - Expression blamed, TemplateModel model, String tip, - Environment env) - throws InvalidReferenceException { - super(blamed, model, "user-defined directive, transform or macro", EXPECTED_TYPES, tip, env); - } - - NonUserDefinedDirectiveLikeException( - Expression blamed, TemplateModel model, String[] tips, Environment env) throws InvalidReferenceException { - super(blamed, model, "user-defined directive, transform or macro", EXPECTED_TYPES, tips, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NotExpression.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NotExpression.java b/src/main/java/org/apache/freemarker/core/ast/NotExpression.java deleted file mode 100644 index 626e422..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NotExpression.java +++ /dev/null @@ -1,75 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.TemplateException; - -final class NotExpression extends BooleanExpression { - - private final Expression target; - - NotExpression(Expression target) { - this.target = target; - } - - @Override - boolean evalToBoolean(Environment env) throws TemplateException { - return (!target.evalToBoolean(env)); - } - - @Override - public String getCanonicalForm() { - return "!" + target.getCanonicalForm(); - } - - @Override - String getNodeTypeSymbol() { - return "!"; - } - - @Override - boolean isLiteral() { - return target.isLiteral(); - } - - @Override - protected Expression deepCloneWithIdentifierReplaced_inner( - String replacedIdentifier, Expression replacement, ReplacemenetState replacementState) { - return new NotExpression( - target.deepCloneWithIdentifierReplaced(replacedIdentifier, replacement, replacementState)); - } - - @Override - int getParameterCount() { - return 1; - } - - @Override - Object getParameterValue(int idx) { - if (idx != 0) throw new IndexOutOfBoundsException(); - return target; - } - - @Override - ParameterRole getParameterRole(int idx) { - if (idx != 0) throw new IndexOutOfBoundsException(); - return ParameterRole.RIGHT_HAND_OPERAND; - } -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NumberLiteral.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NumberLiteral.java b/src/main/java/org/apache/freemarker/core/ast/NumberLiteral.java deleted file mode 100644 index 0960a76..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NumberLiteral.java +++ /dev/null @@ -1,94 +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 org.apache.freemarker.core.ast; - -import org.apache.freemarker.core.TemplateException; -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateNumberModel; -import org.apache.freemarker.core.model.impl.SimpleNumber; - -/** - * A simple implementation of the <tt>TemplateNumberModel</tt> - * interface. Note that this class is immutable. - */ -final class NumberLiteral extends Expression implements TemplateNumberModel { - - private final Number value; - - public NumberLiteral(Number value) { - this.value = value; - } - - @Override - TemplateModel _eval(Environment env) { - return new SimpleNumber(value); - } - - @Override - public String evalAndCoerceToPlainText(Environment env) throws TemplateException { - return env.formatNumberToPlainText(this, this, false); - } - - @Override - public Number getAsNumber() { - return value; - } - - String getName() { - return "the number: '" + value + "'"; - } - - @Override - public String getCanonicalForm() { - return value.toString(); - } - - @Override - String getNodeTypeSymbol() { - return getCanonicalForm(); - } - - @Override - boolean isLiteral() { - return true; - } - - @Override - protected Expression deepCloneWithIdentifierReplaced_inner( - String replacedIdentifier, Expression replacement, ReplacemenetState replacementState) { - return new NumberLiteral(value); - } - - @Override - int getParameterCount() { - return 0; - } - - @Override - Object getParameterValue(int idx) { - throw new IndexOutOfBoundsException(); - } - - @Override - ParameterRole getParameterRole(int idx) { - throw new IndexOutOfBoundsException(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/NumericalOutput.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/NumericalOutput.java b/src/main/java/org/apache/freemarker/core/ast/NumericalOutput.java deleted file mode 100644 index 1824b99..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/NumericalOutput.java +++ /dev/null @@ -1,173 +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 org.apache.freemarker.core.ast; - -import java.io.IOException; -import java.io.Writer; -import java.text.NumberFormat; -import java.util.Locale; - -import org.apache.freemarker.core.TemplateException; -import org.apache.freemarker.core.util.FTLUtil; - -/** - * An instruction that outputs the value of a numerical expression. - */ -final class NumericalOutput extends Interpolation { - - private final Expression expression; - private final boolean hasFormat; - private final int minFracDigits; - private final int maxFracDigits; - /** For OutputFormat-based auto-escaping */ - private final MarkupOutputFormat autoEscapeOutputFormat; - private volatile FormatHolder formatCache; // creating new NumberFormat is slow operation - - NumericalOutput(Expression expression, MarkupOutputFormat autoEscapeOutputFormat) { - this.expression = expression; - hasFormat = false; - minFracDigits = 0; - maxFracDigits = 0; - this.autoEscapeOutputFormat = autoEscapeOutputFormat; - } - - NumericalOutput(Expression expression, - int minFracDigits, int maxFracDigits, - MarkupOutputFormat autoEscapeOutputFormat) { - this.expression = expression; - hasFormat = true; - this.minFracDigits = minFracDigits; - this.maxFracDigits = maxFracDigits; - this.autoEscapeOutputFormat = autoEscapeOutputFormat; - } - - @Override - TemplateElement[] accept(Environment env) throws TemplateException, IOException { - String s = calculateInterpolatedStringOrMarkup(env); - Writer out = env.getOut(); - if (autoEscapeOutputFormat != null) { - autoEscapeOutputFormat.output(s, out); - } else { - out.write(s); - } - return null; - } - - @Override - protected String calculateInterpolatedStringOrMarkup(Environment env) throws TemplateException { - Number num = expression.evalToNumber(env); - - FormatHolder fmth = formatCache; // atomic sampling - if (fmth == null || !fmth.locale.equals(env.getLocale())) { - synchronized (this) { - fmth = formatCache; - if (fmth == null || !fmth.locale.equals(env.getLocale())) { - NumberFormat fmt = NumberFormat.getNumberInstance(env.getLocale()); - if (hasFormat) { - fmt.setMinimumFractionDigits(minFracDigits); - fmt.setMaximumFractionDigits(maxFracDigits); - } else { - fmt.setMinimumFractionDigits(0); - fmt.setMaximumFractionDigits(50); - } - fmt.setGroupingUsed(false); - formatCache = new FormatHolder(fmt, env.getLocale()); - fmth = formatCache; - } - } - } - // We must use Format even if hasFormat == false. - // Some locales may use non-Arabic digits, thus replacing the - // decimal separator in the result of toString() is not enough. - String s = fmth.format.format(num); - return s; - } - - @Override - protected String dump(boolean canonical, boolean inStringLiteral) { - StringBuilder buf = new StringBuilder("#{"); - final String exprCF = expression.getCanonicalForm(); - buf.append(inStringLiteral ? FTLUtil.escapeStringLiteralPart(exprCF, '"') : exprCF); - if (hasFormat) { - buf.append(" ; "); - buf.append("m"); - buf.append(minFracDigits); - buf.append("M"); - buf.append(maxFracDigits); - } - buf.append("}"); - return buf.toString(); - } - - @Override - String getNodeTypeSymbol() { - return "#{...}"; - } - - @Override - boolean heedsOpeningWhitespace() { - return true; - } - - @Override - boolean heedsTrailingWhitespace() { - return true; - } - - private static class FormatHolder { - final NumberFormat format; - final Locale locale; - - FormatHolder(NumberFormat format, Locale locale) { - this.format = format; - this.locale = locale; - } - } - - @Override - int getParameterCount() { - return 3; - } - - @Override - Object getParameterValue(int idx) { - switch (idx) { - case 0: return expression; - case 1: return Integer.valueOf(minFracDigits); - case 2: return Integer.valueOf(maxFracDigits); - default: throw new IndexOutOfBoundsException(); - } - } - - @Override - ParameterRole getParameterRole(int idx) { - switch (idx) { - case 0: return ParameterRole.CONTENT; - case 1: return ParameterRole.MINIMUM_DECIMALS; - case 2: return ParameterRole.MAXIMUM_DECIMALS; - default: throw new IndexOutOfBoundsException(); - } - } - - @Override - boolean isNestedBlockRepeater() { - return false; - } -}
