http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/MarkupOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/MarkupOutputFormat.java b/src/main/java/freemarker/core/MarkupOutputFormat.java deleted file mode 100644 index b058591..0000000 --- a/src/main/java/freemarker/core/MarkupOutputFormat.java +++ /dev/null @@ -1,132 +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.io.IOException; -import java.io.Writer; - -import freemarker.template.Configuration; -import freemarker.template.TemplateModelException; - -/** - * Superclass of {@link OutputFormat}-s that represent a "markup" format, which is any format where certain character - * sequences have special meaning and thus may need escaping. (Escaping is important for FreeMarker, as typically it has - * to insert non-markup text from the data-model into the output markup. See also: - * {@link Configuration#setOutputFormat(OutputFormat)}.) - * - * <p> - * An {@link OutputFormat} subclass always has a corresponding {@link TemplateMarkupOutputModel} subclass pair (like - * {@link HTMLOutputFormat} has {@link TemplateHTMLOutputModel}). The {@link OutputFormat} implements the operations - * related to {@link TemplateMarkupOutputModel} objects of that kind, while the {@link TemplateMarkupOutputModel} only - * encapsulates the data (the actual markup or text). - * - * <p> - * To implement a custom output format, you may want to extend {@link CommonMarkupOutputFormat}. - * - * @param <MO> - * The {@link TemplateMarkupOutputModel} class this output format can deal with. - * - * @since 2.3.24 - */ -public abstract class MarkupOutputFormat<MO extends TemplateMarkupOutputModel> extends OutputFormat { - - protected MarkupOutputFormat() { - // Only to decrease visibility - } - - /** - * Converts a {@link String} that's assumed to be plain text to {@link TemplateMarkupOutputModel}, by escaping any - * special characters in the plain text. This corresponds to {@code ?esc}, or, to outputting with auto-escaping if - * that wasn't using {@link #output(String, Writer)} as an optimization. - * - * @see #escapePlainText(String) - * @see #getSourcePlainText(TemplateMarkupOutputModel) - */ - public abstract MO fromPlainTextByEscaping(String textToEsc) throws TemplateModelException; - - /** - * Wraps a {@link String} that's already markup to {@link TemplateMarkupOutputModel} interface, to indicate its - * format. This corresponds to {@code ?noEsc}. (This methods is allowed to throw {@link TemplateModelException} if - * the parameter markup text is malformed, but it's unlikely that an implementation chooses to parse the parameter - * until, and if ever, that becomes necessary.) - * - * @see #getMarkupString(TemplateMarkupOutputModel) - */ - public abstract MO fromMarkup(String markupText) throws TemplateModelException; - - /** - * Prints the parameter model to the output. - */ - public abstract void output(MO mo, Writer out) throws IOException, TemplateModelException; - - /** - * Equivalent to calling {@link #fromPlainTextByEscaping(String)} and then - * {@link #output(TemplateMarkupOutputModel, Writer)}, but the implementation may uses a more efficient solution. - */ - public abstract void output(String textToEsc, Writer out) throws IOException, TemplateModelException; - - /** - * If this {@link TemplateMarkupOutputModel} was created with {@link #fromPlainTextByEscaping(String)}, it returns - * the original plain text, otherwise it returns {@code null}. Useful for converting between different types - * of markups, as if the source format can be converted to plain text without loss, then that just has to be - * re-escaped with the target format to do the conversion. - */ - public abstract String getSourcePlainText(MO mo) throws TemplateModelException; - - /** - * Returns the content as markup text; never {@code null}. If this {@link TemplateMarkupOutputModel} was created - * with {@link #fromMarkup(String)}, it might returns the original markup text literally, but this is not required - * as far as the returned markup means the same. If this {@link TemplateMarkupOutputModel} wasn't created - * with {@link #fromMarkup(String)} and it doesn't yet have the markup, it has to generate the markup now. - */ - public abstract String getMarkupString(MO mo) throws TemplateModelException; - - /** - * Returns a {@link TemplateMarkupOutputModel} that contains the content of both {@link TemplateMarkupOutputModel} - * objects concatenated. - */ - public abstract MO concat(MO mo1, MO mo2) throws TemplateModelException; - - /** - * Should give the same result as {@link #fromPlainTextByEscaping(String)} and then - * {@link #getMarkupString(TemplateMarkupOutputModel)}, but the implementation may uses a more efficient solution. - */ - public abstract String escapePlainText(String plainTextContent) throws TemplateModelException; - - /** - * Returns if the markup is empty (0 length). This is used by at least {@code ?hasContent}. - */ - public abstract boolean isEmpty(MO mo) throws TemplateModelException; - - /** - * Tells if a string built-in that can't handle a {@link TemplateMarkupOutputModel} left hand operand can bypass - * this object as is. A typical such case would be when a {@link TemplateHTMLOutputModel} of "HTML" format bypasses - * {@code ?html}. - */ - public abstract boolean isLegacyBuiltInBypassed(String builtInName) throws TemplateModelException; - - /** - * Tells if by default auto-escaping should be on for this format. It should be {@code true} if you need to escape - * on most of the places where you insert values. - * - * @see Configuration#setAutoEscapingPolicy(int) - */ - public abstract boolean isAutoEscapedByDefault(); - -}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/MarkupOutputFormatBoundBuiltIn.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/MarkupOutputFormatBoundBuiltIn.java b/src/main/java/freemarker/core/MarkupOutputFormatBoundBuiltIn.java deleted file mode 100644 index 5780124..0000000 --- a/src/main/java/freemarker/core/MarkupOutputFormatBoundBuiltIn.java +++ /dev/null @@ -1,46 +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; -import freemarker.template.utility.NullArgumentException; - -abstract class MarkupOutputFormatBoundBuiltIn extends SpecialBuiltIn { - - protected MarkupOutputFormat outputFormat; - - void bindToMarkupOutputFormat(MarkupOutputFormat outputFormat) { - NullArgumentException.check(outputFormat); - this.outputFormat = outputFormat; - } - - @Override - TemplateModel _eval(Environment env) throws TemplateException { - if (outputFormat == null) { - // The parser should prevent this situation - throw new NullPointerException("outputFormat was null"); - } - return calculateResult(env); - } - - protected abstract TemplateModel calculateResult(Environment env) - throws TemplateException; - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/MessageUtil.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/MessageUtil.java b/src/main/java/freemarker/core/MessageUtil.java deleted file mode 100644 index 3aebacc..0000000 --- a/src/main/java/freemarker/core/MessageUtil.java +++ /dev/null @@ -1,352 +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.ArrayList; - -import freemarker.template.Template; -import freemarker.template.TemplateException; -import freemarker.template.TemplateModel; -import freemarker.template.TemplateModelException; -import freemarker.template.utility.StringUtil; - -/** - * Utilities for creating error messages (and other messages). - */ -class MessageUtil { - - static final String UNKNOWN_DATE_TO_STRING_ERROR_MESSAGE - = "Can't convert the date-like value to string because it isn't " - + "known if it's a date (no time part), time or date-time value."; - - static final String UNKNOWN_DATE_PARSING_ERROR_MESSAGE - = "Can't parse the string to date-like value because it isn't " - + "known if it's desired result should be a date (no time part), a time, or a date-time value."; - - static final String UNKNOWN_DATE_TYPE_ERROR_TIP = - "Use ?date, ?time, or ?datetime to tell FreeMarker the exact type."; - - static final Object[] UNKNOWN_DATE_TO_STRING_TIPS = { - UNKNOWN_DATE_TYPE_ERROR_TIP, - "If you need a particular format only once, use ?string(pattern), like ?string('dd.MM.yyyy HH:mm:ss'), " - + "to specify which fields to display. " - }; - - static final String EMBEDDED_MESSAGE_BEGIN = "---begin-message---\n"; - - static final String EMBEDDED_MESSAGE_END = "\n---end-message---"; - - // Can't be instantiated - private MessageUtil() { } - - static String formatLocationForSimpleParsingError(Template template, int line, int column) { - return formatLocation("in", template, line, column); - } - - static String formatLocationForSimpleParsingError(String templateSourceName, int line, int column) { - return formatLocation("in", templateSourceName, line, column); - } - - static String formatLocationForDependentParsingError(Template template, int line, int column) { - return formatLocation("on", template, line, column); - } - - static String formatLocationForDependentParsingError(String templateSourceName, int line, int column) { - return formatLocation("on", templateSourceName, line, column); - } - - static String formatLocationForEvaluationError(Template template, int line, int column) { - return formatLocation("at", template, line, column); - } - - static String formatLocationForEvaluationError(Macro macro, int line, int column) { - Template t = macro.getTemplate(); - return formatLocation("at", t != null ? t.getSourceName() : null, macro.getName(), macro.isFunction(), line, column); - } - - static String formatLocationForEvaluationError(String templateSourceName, int line, int column) { - return formatLocation("at", templateSourceName, line, column); - } - - private static String formatLocation(String preposition, Template template, int line, int column) { - return formatLocation(preposition, template != null ? template.getSourceName() : null, line, column); - } - - private static String formatLocation(String preposition, String templateSourceName, int line, int column) { - return formatLocation( - preposition, templateSourceName, - null, false, - line, column); - } - - private static String formatLocation( - String preposition, String templateSourceName, - String macroOrFuncName, boolean isFunction, - int line, int column) { - String templateDesc; - if (line < 0) { - templateDesc = "?eval-ed string"; - macroOrFuncName = null; - } else { - templateDesc = templateSourceName != null - ? "template " + StringUtil.jQuoteNoXSS(templateSourceName) - : "nameless template"; - } - return "in " + templateDesc - + (macroOrFuncName != null - ? " in " + (isFunction ? "function " : "macro ") + StringUtil.jQuote(macroOrFuncName) - : "") - + " " - + preposition + " " + formatPosition(line, column); - } - - static String formatPosition(int line, int column) { - return "line " + (line >= 0 ? line : line - (TemplateObject.RUNTIME_EVAL_LINE_DISPLACEMENT - 1)) - + ", column " + column; - } - - /** - * Returns a single line string that is no longer than {@code maxLength}. - * If will truncate the string at line-breaks too. - * The truncation is always signaled with a a {@code "..."} at the end of the result string. - */ - static String shorten(String s, int maxLength) { - if (maxLength < 5) maxLength = 5; - - boolean isTruncated = false; - - int brIdx = s.indexOf('\n'); - if (brIdx != -1) { - s = s.substring(0, brIdx); - isTruncated = true; - }; - brIdx = s.indexOf('\r'); - if (brIdx != -1) { - s = s.substring(0, brIdx); - isTruncated = true; - } - - if (s.length() > maxLength) { - s = s.substring(0, maxLength - 3); - isTruncated = true; - } - - if (!isTruncated) { - return s; - } else { - if (s.endsWith(".")) { - if (s.endsWith("..")) { - if (s.endsWith("...")) { - return s; - } else { - return s + "."; - } - } else { - return s + ".."; - } - } else { - return s + "..."; - } - } - } - - static StringBuilder appendExpressionAsUntearable(StringBuilder sb, Expression argExp) { - boolean needParen = - !(argExp instanceof NumberLiteral) - && !(argExp instanceof StringLiteral) - && !(argExp instanceof BooleanLiteral) - && !(argExp instanceof ListLiteral) - && !(argExp instanceof HashLiteral) - && !(argExp instanceof Identifier) - && !(argExp instanceof Dot) - && !(argExp instanceof DynamicKeyName) - && !(argExp instanceof MethodCall) - && !(argExp instanceof BuiltIn); - if (needParen) sb.append('('); - sb.append(argExp.getCanonicalForm()); - if (needParen) sb.append(')'); - return sb; - } - - static TemplateModelException newArgCntError(String methodName, int argCnt, int expectedCnt) { - return newArgCntError(methodName, argCnt, expectedCnt, expectedCnt); - } - - static TemplateModelException newArgCntError(String methodName, int argCnt, int minCnt, int maxCnt) { - ArrayList/*<Object>*/ desc = new ArrayList(20); - - desc.add(methodName); - - desc.add("("); - if (maxCnt != 0) desc.add("..."); - desc.add(") expects "); - - if (minCnt == maxCnt) { - if (maxCnt == 0) { - desc.add("no"); - } else { - desc.add(Integer.valueOf(maxCnt)); - } - } else if (maxCnt - minCnt == 1) { - desc.add(Integer.valueOf(minCnt)); - desc.add(" or "); - desc.add(Integer.valueOf(maxCnt)); - } else { - desc.add(Integer.valueOf(minCnt)); - if (maxCnt != Integer.MAX_VALUE) { - desc.add(" to "); - desc.add(Integer.valueOf(maxCnt)); - } else { - desc.add(" or more (unlimited)"); - } - } - desc.add(" argument"); - if (maxCnt > 1) desc.add("s"); - - desc.add(" but has received "); - if (argCnt == 0) { - desc.add("none"); - } else { - desc.add(Integer.valueOf(argCnt)); - } - desc.add("."); - - return new _TemplateModelException(desc.toArray()); - } - - static TemplateModelException newMethodArgMustBeStringException(String methodName, int argIdx, TemplateModel arg) { - return newMethodArgUnexpectedTypeException(methodName, argIdx, "string", arg); - } - - static TemplateModelException newMethodArgMustBeNumberException(String methodName, int argIdx, TemplateModel arg) { - return newMethodArgUnexpectedTypeException(methodName, argIdx, "number", arg); - } - - static TemplateModelException newMethodArgMustBeBooleanException(String methodName, int argIdx, TemplateModel arg) { - return newMethodArgUnexpectedTypeException(methodName, argIdx, "boolean", arg); - } - - static TemplateModelException newMethodArgMustBeExtendedHashException( - String methodName, int argIdx, TemplateModel arg) { - return newMethodArgUnexpectedTypeException(methodName, argIdx, "extended hash", arg); - } - - static TemplateModelException newMethodArgMustBeSequenceException( - String methodName, int argIdx, TemplateModel arg) { - return newMethodArgUnexpectedTypeException(methodName, argIdx, "sequence", arg); - } - - static TemplateModelException newMethodArgMustBeSequenceOrCollectionException( - String methodName, int argIdx, TemplateModel arg) { - return newMethodArgUnexpectedTypeException(methodName, argIdx, "sequence or collection", arg); - } - - static TemplateModelException newMethodArgUnexpectedTypeException( - String methodName, int argIdx, String expectedType, TemplateModel arg) { - return new _TemplateModelException( - methodName, "(...) expects ", new _DelayedAOrAn(expectedType), " as argument #", Integer.valueOf(argIdx + 1), - ", but received ", new _DelayedAOrAn(new _DelayedFTLTypeDescription(arg)), "."); - } - - /** - * The type of the argument was good, but it's value wasn't. - */ - static TemplateModelException newMethodArgInvalidValueException( - String methodName, int argIdx, Object... details) { - return new _TemplateModelException( - methodName, "(...) argument #", Integer.valueOf(argIdx + 1), - " had invalid value: ", details); - } - - /** - * The type of the argument was good, but the values of two or more arguments are inconsistent with each other. - */ - static TemplateModelException newMethodArgsInvalidValueException( - String methodName, Object... details) { - return new _TemplateModelException(methodName, "(...) arguments have invalid value: ", details); - } - - static TemplateException newInstantiatingClassNotAllowedException(String className, Environment env) { - return new _MiscTemplateException(env, - "Instantiating ", className, " is not allowed in the template for security reasons."); - } - - static _TemplateModelException newCantFormatUnknownTypeDateException( - Expression dateSourceExpr, UnknownDateTypeFormattingUnsupportedException cause) { - return new _TemplateModelException(cause, null, new _ErrorDescriptionBuilder( - MessageUtil.UNKNOWN_DATE_TO_STRING_ERROR_MESSAGE) - .blame(dateSourceExpr) - .tips(MessageUtil.UNKNOWN_DATE_TO_STRING_TIPS)); - } - - static TemplateException newCantFormatDateException(TemplateDateFormat format, Expression dataSrcExp, - TemplateValueFormatException e, boolean useTempModelExc) { - _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder( - "Failed to format date/time/datetime with format ", new _DelayedJQuote(format.getDescription()), ": ", - e.getMessage()) - .blame(dataSrcExp); - return useTempModelExc - ? new _TemplateModelException(e, (Environment) null, desc) - : new _MiscTemplateException(e, (Environment) null, desc); - } - - static TemplateException newCantFormatNumberException(TemplateNumberFormat format, Expression dataSrcExp, - TemplateValueFormatException e, boolean useTempModelExc) { - _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder( - "Failed to format number with format ", new _DelayedJQuote(format.getDescription()), ": ", - e.getMessage()) - .blame(dataSrcExp); - return useTempModelExc - ? new _TemplateModelException(e, (Environment) null, desc) - : new _MiscTemplateException(e, (Environment) null, desc); - } - - /** - * @return "a" or "an" or "a(n)" (or "" for empty string) for an FTL type name - */ - static String getAOrAn(String s) { - if (s == null) return null; - if (s.length() == 0) return ""; - - char fc = Character.toLowerCase(s.charAt(0)); - if (fc == 'a' || fc == 'e' || fc == 'i') { - return "an"; - } else if (fc == 'h') { - String ls = s.toLowerCase(); - if (ls.startsWith("has") || ls.startsWith("hi")) { - return "a"; - } else if (ls.startsWith("ht")) { - return "an"; - } else { - return "a(n)"; - } - } else if (fc == 'u' || fc == 'o') { - return "a(n)"; - } else { - char sc = (s.length() > 1) ? s.charAt(1) : '\0'; - if (fc == 'x' && !(sc == 'a' || sc == 'e' || sc == 'i' || sc == 'a' || sc == 'o' || sc == 'u')) { - return "an"; - } else { - return "a"; - } - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/MethodCall.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/MethodCall.java b/src/main/java/freemarker/core/MethodCall.java deleted file mode 100644 index 1cb42de..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import java.io.IOException; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; - -import freemarker.template.TemplateException; -import freemarker.template.TemplateMethodModel; -import freemarker.template.TemplateMethodModelEx; -import freemarker.template.TemplateModel; -import freemarker.template.utility.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/ecb4e230/src/main/java/freemarker/core/MiscUtil.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/MiscUtil.java b/src/main/java/freemarker/core/MiscUtil.java deleted file mode 100644 index bb65fb3..0000000 --- a/src/main/java/freemarker/core/MiscUtil.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 freemarker.core; - -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 - 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/ecb4e230/src/main/java/freemarker/core/MixedContent.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/MixedContent.java b/src/main/java/freemarker/core/MixedContent.java deleted file mode 100644 index 3306988..0000000 --- a/src/main/java/freemarker/core/MixedContent.java +++ /dev/null @@ -1,118 +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.io.IOException; - -import freemarker.template.TemplateException; - -/** - * Encapsulates an array of <tt>TemplateElement</tt> objects. - */ -final class MixedContent extends TemplateElement { - - MixedContent() { } - - /** - * @deprecated Use {@link #addChild(TemplateElement)} instead. - */ - @Deprecated - void addElement(TemplateElement element) { - addChild(element); - } - - /** - * @deprecated Use {@link #addChild(int, TemplateElement)} instead. - */ - @Deprecated - void addElement(int index, TemplateElement element) { - addChild(index, element); - } - - @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/ecb4e230/src/main/java/freemarker/core/NestedContentNotSupportedException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NestedContentNotSupportedException.java b/src/main/java/freemarker/core/NestedContentNotSupportedException.java deleted file mode 100644 index a667af1..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.core.Environment.NestedElementTemplateDirectiveBody; -import freemarker.core.ThreadInterruptionSupportTemplatePostProcessor.ThreadInterruptionCheck; -import freemarker.template.TemplateDirectiveBody; -import freemarker.template.TemplateException; -import freemarker.template.utility.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/ecb4e230/src/main/java/freemarker/core/NewBI.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NewBI.java b/src/main/java/freemarker/core/NewBI.java deleted file mode 100644 index 611921c..0000000 --- a/src/main/java/freemarker/core/NewBI.java +++ /dev/null @@ -1,72 +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.ext.beans.BeanModel; -import freemarker.ext.beans.BeansWrapper; -import freemarker.template.ObjectWrapper; -import freemarker.template.Template; -import freemarker.template.TemplateException; -import freemarker.template.TemplateMethodModelEx; -import freemarker.template.TemplateModel; -import freemarker.template.TemplateModelException; - -/** - * 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 freemarker.template.TemplateModel"); - } - if (BeanModel.class.isAssignableFrom(cl)) { - throw new _MiscTemplateException(NewBI.this, env, - "Bean Models cannot be instantiated using the ?", key, " built-in"); - } - } - - public Object exec(List arguments) throws TemplateModelException { - ObjectWrapper ow = env.getObjectWrapper(); - BeansWrapper bw = - ow instanceof BeansWrapper - ? (BeansWrapper) ow - : BeansWrapper.getDefaultInstance(); - return bw.newInstance(cl, arguments); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/NoAutoEscBlock.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NoAutoEscBlock.java b/src/main/java/freemarker/core/NoAutoEscBlock.java deleted file mode 100644 index 7e07bca..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import java.io.IOException; - -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NoEscapeBlock.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NoEscapeBlock.java b/src/main/java/freemarker/core/NoEscapeBlock.java deleted file mode 100644 index 6ac3960..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import java.io.IOException; - -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonBooleanException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonBooleanException.java b/src/main/java/freemarker/core/NonBooleanException.java deleted file mode 100644 index bebd595..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.TemplateBooleanModel; -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonDateException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonDateException.java b/src/main/java/freemarker/core/NonDateException.java deleted file mode 100644 index e967412..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.TemplateDateModel; -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonExtendedHashException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonExtendedHashException.java b/src/main/java/freemarker/core/NonExtendedHashException.java deleted file mode 100644 index 0bb6119..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.TemplateHashModelEx; -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonExtendedNodeException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonExtendedNodeException.java b/src/main/java/freemarker/core/NonExtendedNodeException.java deleted file mode 100644 index 3377257..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.TemplateModel; -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonHashException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonHashException.java b/src/main/java/freemarker/core/NonHashException.java deleted file mode 100644 index 9ef2bab..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.TemplateHashModel; -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonListableRightUnboundedRangeModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonListableRightUnboundedRangeModel.java b/src/main/java/freemarker/core/NonListableRightUnboundedRangeModel.java deleted file mode 100644 index 2633c42..0000000 --- a/src/main/java/freemarker/core/NonListableRightUnboundedRangeModel.java +++ /dev/null @@ -1,39 +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.TemplateModelException; - -/** - * This exists for backward compatibly, and is used before Incompatible Improvements 2.3.21 only. - * - * @since 2.3.21 - */ -final class NonListableRightUnboundedRangeModel extends RightUnboundedRangeModel { - - NonListableRightUnboundedRangeModel(int begin) { - super(begin); - } - - public int size() throws TemplateModelException { - return 0; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/NonMarkupOutputException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonMarkupOutputException.java b/src/main/java/freemarker/core/NonMarkupOutputException.java deleted file mode 100644 index d9cb6ee..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonMethodException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonMethodException.java b/src/main/java/freemarker/core/NonMethodException.java deleted file mode 100644 index 79b6727..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.TemplateMethodModel; -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonNamespaceException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonNamespaceException.java b/src/main/java/freemarker/core/NonNamespaceException.java deleted file mode 100644 index 2d33dff..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonNodeException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonNodeException.java b/src/main/java/freemarker/core/NonNodeException.java deleted file mode 100644 index b551ed7..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.TemplateModel; -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonNumericalException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonNumericalException.java b/src/main/java/freemarker/core/NonNumericalException.java deleted file mode 100644 index 2e00bd3..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.TemplateModel; -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonSequenceException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonSequenceException.java b/src/main/java/freemarker/core/NonSequenceException.java deleted file mode 100644 index 7414ac3..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.TemplateModel; -import freemarker.template.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/ecb4e230/src/main/java/freemarker/core/NonSequenceOrCollectionException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonSequenceOrCollectionException.java b/src/main/java/freemarker/core/NonSequenceOrCollectionException.java deleted file mode 100644 index d83ff9d..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.ext.util.WrapperTemplateModel; -import freemarker.template.TemplateCollectionModel; -import freemarker.template.TemplateModel; -import freemarker.template.TemplateSequenceModel; -import freemarker.template.utility.CollectionUtils; - -/** - * 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, CollectionUtils.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/ecb4e230/src/main/java/freemarker/core/NonStringException.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/NonStringException.java b/src/main/java/freemarker/core/NonStringException.java deleted file mode 100644 index 2c8ec22..0000000 --- a/src/main/java/freemarker/core/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 freemarker.core; - -import freemarker.template.TemplateBooleanModel; -import freemarker.template.TemplateDateModel; -import freemarker.template.TemplateModel; -import freemarker.template.TemplateNumberModel; -import freemarker.template.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); - } - -}
