Repository: incubator-freemarker Updated Branches: refs/heads/3 22de04e9b -> d4de527bc
Got rid of _TemplateModelException-s on places where TemplateException or simple TemplateModelException can be used. Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/d4de527b Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/d4de527b Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/d4de527b Branch: refs/heads/3 Commit: d4de527bc7672f4febc63a77cc75a38d42fc363e Parents: 22de04e Author: ddekany <ddek...@apache.org> Authored: Tue Aug 8 23:15:40 2017 +0200 Committer: ddekany <ddek...@apache.org> Committed: Tue Aug 8 23:15:40 2017 +0200 ---------------------------------------------------------------------- .../core/APINotSupportedTemplateException.java | 2 +- .../org/apache/freemarker/core/ASTDirList.java | 6 +-- .../freemarker/core/ASTDollarInterpolation.java | 3 +- .../apache/freemarker/core/ASTExpBuiltIn.java | 33 +++++++------- .../freemarker/core/BuiltInForSequence.java | 2 +- .../freemarker/core/BuiltInsForDates.java | 3 +- .../freemarker/core/BuiltInsForSequences.java | 46 ++++++++++---------- .../core/BuiltInsForStringsBasic.java | 8 ++-- .../core/BuiltInsForStringsEncoding.java | 6 +-- .../core/BuiltInsForStringsRegexp.java | 10 ++--- .../org/apache/freemarker/core/Environment.java | 2 +- .../apache/freemarker/core/MessageUtils.java | 26 +++++------ .../core/UnexpectedTypeException.java | 2 +- .../core/_DelayedFTLTypeDescription.java | 37 ---------------- ..._DelayedTemplateLanguageTypeDescription.java | 37 ++++++++++++++++ .../org/apache/freemarker/core/_EvalUtils.java | 4 +- .../freemarker/core/model/impl/BeanModel.java | 4 +- .../core/model/impl/DefaultObjectWrapper.java | 6 +-- .../core/model/impl/SimpleMethod.java | 4 +- .../apache/freemarker/servlet/IncludePage.java | 5 +-- 20 files changed, 123 insertions(+), 123 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/APINotSupportedTemplateException.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/APINotSupportedTemplateException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/APINotSupportedTemplateException.java index 732f5e2..a3761ad 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/APINotSupportedTemplateException.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/APINotSupportedTemplateException.java @@ -34,7 +34,7 @@ class APINotSupportedTemplateException extends TemplateException { TemplateModel tm) { final _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder( "The value doesn't support ?api. See requirements in the FreeMarker Manual. (" - + "FTL type: ", new _DelayedFTLTypeDescription(tm), + + "FTL type: ", new _DelayedTemplateLanguageTypeDescription(tm), ", TemplateModel class: ", new _DelayedShortClassName(tm.getClass()), ", ObjectWapper: ", new _DelayedToString(env.getObjectWrapper()), ")" ).blame(blamedExpr); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java index 57120c2..7878e97 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java @@ -308,7 +308,7 @@ final class ASTDirList extends ASTDirective { && !NonSequenceOrCollectionException.isWrappedIterable(listedValue)) { throw new NonSequenceOrCollectionException(env, new _ErrorDescriptionBuilder("The value you try to list is ", - new _DelayedAOrAn(new _DelayedFTLTypeDescription(listedValue)), + new _DelayedAOrAn(new _DelayedTemplateLanguageTypeDescription(listedValue)), ", thus you must declare two nested content parameters after the \"as\"; one for the " + "key, and another for the value, like ", "<#... as k, v>", ")." )); @@ -365,7 +365,7 @@ final class ASTDirList extends ASTDirective { + "implementations, all keys must be strings, but one of them " + "was ", new _DelayedAOrAn( - new _DelayedFTLTypeDescription(nestedContentParam)), + new _DelayedTemplateLanguageTypeDescription(nestedContentParam)), "." ).tip("The listed value's TemplateModel class was ", new _DelayedShortClassName(listedValue.getClass()), @@ -391,7 +391,7 @@ final class ASTDirList extends ASTDirective { || listedValue instanceof TemplateSequenceModel) { throw new NonSequenceOrCollectionException(env, new _ErrorDescriptionBuilder("The value you try to list is ", - new _DelayedAOrAn(new _DelayedFTLTypeDescription(listedValue)), + new _DelayedAOrAn(new _DelayedTemplateLanguageTypeDescription(listedValue)), ", thus you must declare only one nested content parameter after the \"as\" (there's " + "no separate key and value)." )); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java index c422d93..46a46d2 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.Writer; import org.apache.freemarker.core.model.TemplateMarkupOutputModel; +import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.outputformat.MarkupOutputFormat; import org.apache.freemarker.core.outputformat.OutputFormat; import org.apache.freemarker.core.util.TemplateLanguageUtils; @@ -76,7 +77,7 @@ final class ASTDollarInterpolation extends ASTInterpolation { // ATTENTION: Keep this logic in sync. ?esc/?noEsc's logic! srcPlainText = moOF.getSourcePlainText(mo); if (srcPlainText == null) { - throw new _TemplateModelException(escapedExpression, + throw new TemplateException(escapedExpression, "The value to print is in ", new _DelayedToString(moOF), " format, which differs from the current output format, ", new _DelayedToString(outputFormat), ". Format conversion wasn't possible."); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltIn.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltIn.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltIn.java index 7e93646..eb78ef5 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltIn.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltIn.java @@ -63,7 +63,6 @@ import org.apache.freemarker.core.BuiltInsForSequences.sort_byBI; import org.apache.freemarker.core.BuiltInsForStringsMisc.evalBI; import org.apache.freemarker.core.model.TemplateDateModel; import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateNumberModel; import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.util._DateUtils; @@ -387,36 +386,36 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { return false; // be on the safe side. } - protected final void checkMethodArgCount(List args, int expectedCnt) throws TemplateModelException { + protected final void checkMethodArgCount(List args, int expectedCnt) throws TemplateException { checkMethodArgCount(args.size(), expectedCnt); } - protected final void checkMethodArgCount(TemplateModel[] args, int expectedCnt) throws TemplateModelException { + protected final void checkMethodArgCount(TemplateModel[] args, int expectedCnt) throws TemplateException { checkMethodArgCount(args.length, expectedCnt); } - protected final void checkMethodArgCount(int argCnt, int expectedCnt) throws TemplateModelException { + protected final void checkMethodArgCount(int argCnt, int expectedCnt) throws TemplateException { if (argCnt != expectedCnt) { throw MessageUtils.newArgCntError("?" + key, argCnt, expectedCnt); } } - protected final void checkMethodArgCount(List args, int minCnt, int maxCnt) throws TemplateModelException { + protected final void checkMethodArgCount(List args, int minCnt, int maxCnt) throws TemplateException { checkMethodArgCount(args.size(), minCnt, maxCnt); } protected final void checkMethodArgCount(TemplateModel[] args, int minCnt, int maxCnt) throws - TemplateModelException { + TemplateException { checkMethodArgCount(args.length, minCnt, maxCnt); } - protected final void checkMethodArgCount(int argCnt, int minCnt, int maxCnt) throws TemplateModelException { + protected final void checkMethodArgCount(int argCnt, int minCnt, int maxCnt) throws TemplateException { if (argCnt < minCnt || argCnt > maxCnt) { throw MessageUtils.newArgCntError("?" + key, argCnt, minCnt, maxCnt); } } - protected final String getStringMethodArg(TemplateModel[] args, int argIdx) throws TemplateModelException { + protected final String getStringMethodArg(TemplateModel[] args, int argIdx) throws TemplateException { return getStringMethodArg(args, argIdx, false); } @@ -424,18 +423,18 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { * Gets a method argument and checks if it's a string; it does NOT check if {@code args} is big enough. */ protected final String getStringMethodArg(TemplateModel[] args, int argIdx, boolean optional) - throws TemplateModelException { + throws TemplateException { TemplateModel arg = args[argIdx]; return getStringMethodArg(arg, argIdx, optional); } protected String getStringMethodArg(TemplateModel arg, int argIdx) - throws TemplateModelException { + throws TemplateException { return getStringMethodArg(arg, argIdx, false); } protected String getStringMethodArg(TemplateModel arg, int argIdx, boolean optional) - throws TemplateModelException { + throws TemplateException { if (!(arg instanceof TemplateScalarModel)) { if (optional && arg == null) { return null; @@ -447,7 +446,7 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { } protected final Number getNumberMethodArg(TemplateModel[] args, int argIdx) - throws TemplateModelException { + throws TemplateException { return getNumberMethodArg(args, argIdx, false); } @@ -455,18 +454,18 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { * Gets a method argument and checks if it's a number; it does NOT check if {@code args} is big enough. */ protected final Number getNumberMethodArg(TemplateModel[] args, int argIdx, boolean optional) - throws TemplateModelException { + throws TemplateException { TemplateModel arg = args[argIdx]; return getNumberMethodArg(arg, argIdx, optional); } protected Number getNumberMethodArg(TemplateModel arg, int argIdx) - throws TemplateModelException { + throws TemplateException { return getNumberMethodArg(arg, argIdx, false); } protected Number getNumberMethodArg(TemplateModel arg, int argIdx, boolean optional) - throws TemplateModelException { + throws TemplateException { if (!(arg instanceof TemplateNumberModel)) { if (optional && arg == null) { return null; @@ -477,11 +476,11 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { } } - protected final TemplateModelException newMethodArgInvalidValueException(int argIdx, Object[] details) { + protected final TemplateException newMethodArgInvalidValueException(int argIdx, Object[] details) { return MessageUtils.newMethodArgInvalidValueException("?" + key, argIdx, details); } - protected final TemplateModelException newMethodArgsInvalidValueException(Object[] details) { + protected final TemplateException newMethodArgsInvalidValueException(Object[] details) { return MessageUtils.newMethodArgsInvalidValueException("?" + key, details); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForSequence.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForSequence.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForSequence.java index 8c36823..4aca088 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForSequence.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForSequence.java @@ -34,5 +34,5 @@ abstract class BuiltInForSequence extends ASTExpBuiltIn { return calculateResult((TemplateSequenceModel) model); } abstract TemplateModel calculateResult(TemplateSequenceModel tsm) - throws TemplateModelException; + throws TemplateException; } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java index 7d7a57c..49bfbdb 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java @@ -27,6 +27,7 @@ import org.apache.freemarker.core.model.ArgumentArrayLayout; import org.apache.freemarker.core.model.TemplateDateModel; import org.apache.freemarker.core.model.TemplateFunctionModel; import org.apache.freemarker.core.model.TemplateModel; +import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.model.impl.SimpleDate; import org.apache.freemarker.core.model.impl.SimpleScalar; @@ -98,7 +99,7 @@ class BuiltInsForDates { try { tzArg = _DateUtils.getTimeZone(tzName); } catch (UnrecognizedTimeZoneException e) { - throw new _TemplateModelException( + throw new TemplateException( "The time zone string specified for ?", key, "(...) is not recognized as a valid time zone name: ", new _DelayedJQuote(tzName)); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java index f5e3253..045432a 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java @@ -87,9 +87,9 @@ class BuiltInsForSequences { private ChunkedSequence( TemplateSequenceModel wrappedTsm, int chunkSize, TemplateModel fillerItem) - throws TemplateModelException { + throws TemplateException { if (chunkSize < 1) { - throw new _TemplateModelException("The 1st argument to ?', key, ' (...) must be at least 1."); + throw new TemplateException("The 1st argument to ?', key, ' (...) must be at least 1."); } this.wrappedTsm = wrappedTsm; this.chunkSize = chunkSize; @@ -217,7 +217,7 @@ class BuiltInsForSequences { try { sb.append(_EvalUtils.coerceModelToStringOrUnsupportedMarkup(item, null, null, env)); } catch (TemplateException e) { - throw new _TemplateModelException(e, + throw new TemplateException(e, "\"?", key, "\" failed at index ", idx, " with this error:\n\n", MessageUtils.EMBEDDED_MESSAGE_BEGIN, new _DelayedGetMessageWithoutStackTop(e), @@ -246,7 +246,7 @@ class BuiltInsForSequences { TemplateModel model = target.eval(env); if (model instanceof TemplateCollectionModel) { if (model instanceof RightUnboundedRangeModel) { - throw new _TemplateModelException( + throw new TemplateException( "The sequence to join was right-unbounded numerical range, thus it's infinitely long."); } return new BIMethodForCollection(env, (TemplateCollectionModel) model); @@ -436,12 +436,12 @@ class BuiltInsForSequences { return ArgumentArrayLayout.TWO_POSITIONAL_PARAMETERS; } - int findInCol(TemplateModel target) throws TemplateModelException { + int findInCol(TemplateModel target) throws TemplateException { return findInCol(target, 0, Integer.MAX_VALUE); } int findInCol(TemplateModel target, int startIndex) - throws TemplateModelException { + throws TemplateException { if (m_dir == 1) { return findInCol(target, startIndex, Integer.MAX_VALUE); } else { @@ -451,7 +451,7 @@ class BuiltInsForSequences { int findInCol(TemplateModel target, final int allowedRangeStart, final int allowedRangeEnd) - throws TemplateModelException { + throws TemplateException { if (allowedRangeEnd < 0) return -1; TemplateModelIterator it = m_col.iterator(); @@ -475,7 +475,7 @@ class BuiltInsForSequences { } int findInSeq(TemplateModel target) - throws TemplateModelException { + throws TemplateException { final int seqSize = m_seq.size(); final int actualStartIndex; @@ -489,7 +489,7 @@ class BuiltInsForSequences { } private int findInSeq(TemplateModel target, int startIndex) - throws TemplateModelException { + throws TemplateException { int seqSize = m_seq.size(); if (m_dir == 1) { @@ -513,7 +513,7 @@ class BuiltInsForSequences { private int findInSeq( TemplateModel target, int scanStartIndex, int seqSize) - throws TemplateModelException { + throws TemplateException { if (m_dir == 1) { for (int i = scanStartIndex; i < seqSize; i++) { if (modelsEqual(i, m_seq.get(i), target, m_env)) return i; @@ -563,7 +563,7 @@ class BuiltInsForSequences { for (int i = 0; i < ln; i++) { TemplateModel item = seq.get(i); if (!(item instanceof TemplateScalarModel)) { - throw new _TemplateModelException( + throw new TemplateException( "The argument to ?", key, "(key), when it's a sequence, must be a " + "sequence of strings, but the item at index ", i, " is not a string."); @@ -571,7 +571,7 @@ class BuiltInsForSequences { subvars[i] = ((TemplateScalarModel) item).getAsString(); } } else { - throw new _TemplateModelException( + throw new TemplateException( "The argument to ?", key, "(key) must be a string (the name of the subvariable), or a " + "sequence of strings (the \"path\" to the subvariable)."); } @@ -659,7 +659,7 @@ class BuiltInsForSequences { } } - static TemplateModelException newInconsistentSortKeyTypeException( + static TemplateException newInconsistentSortKeyTypeException( int keyNamesLn, String firstType, String firstTypePlural, int index, TemplateModel key) { String valueInMsg; String valuesInMsg; @@ -670,13 +670,13 @@ class BuiltInsForSequences { valueInMsg = "key value"; valuesInMsg = "key values"; } - return new _TemplateModelException( + return new TemplateException( startErrorMessage(keyNamesLn, index), "All ", valuesInMsg, " in the sequence must be ", firstTypePlural, ", because the first ", valueInMsg, " was that. However, the ", valueInMsg, " of the current item isn't a ", firstType, " but a ", - new _DelayedFTLTypeDescription(key), "."); + new _DelayedTemplateLanguageTypeDescription(key), "."); } /** @@ -693,7 +693,7 @@ class BuiltInsForSequences { * sequence length was 0. */ static TemplateSequenceModel sort(TemplateSequenceModel seq, String[] keyNames) - throws TemplateModelException { + throws TemplateException { int ln = seq.size(); if (ln == 0) return seq; @@ -712,7 +712,7 @@ class BuiltInsForSequences { key = ((TemplateHashModel) key).get(keyNames[keyNameI]); } catch (ClassCastException e) { if (!(key instanceof TemplateHashModel)) { - throw new _TemplateModelException( + throw new TemplateException( startErrorMessage(keyNamesLn, i), (keyNameI == 0 ? "Sequence items must be hashes when using ?sortBy. " @@ -726,7 +726,7 @@ class BuiltInsForSequences { } } if (key == null) { - throw new _TemplateModelException( + throw new TemplateException( startErrorMessage(keyNamesLn, i), "The " + _StringUtils.jQuote(keyNames[keyNameI]), " subvariable was null or missing."); } @@ -749,7 +749,7 @@ class BuiltInsForSequences { keyType = KEY_TYPE_BOOLEAN; keyComparator = new BooleanKVPComparator(); } else { - throw new _TemplateModelException( + throw new TemplateException( startErrorMessage(keyNamesLn, i), "Values used for sorting must be numbers, strings, date/times or booleans."); } @@ -818,7 +818,7 @@ class BuiltInsForSequences { try { Collections.sort(res, keyComparator); } catch (Exception exc) { - throw new _TemplateModelException(exc, + throw new TemplateException(exc, startErrorMessage(keyNamesLn), "Unexpected error while sorting:" + exc); } @@ -853,7 +853,7 @@ class BuiltInsForSequences { @Override TemplateModel calculateResult(TemplateSequenceModel seq) - throws TemplateModelException { + throws TemplateException { return sort(seq, null); } @@ -862,7 +862,7 @@ class BuiltInsForSequences { private static boolean modelsEqual( int seqItemIndex, TemplateModel seqItem, TemplateModel searchedItem, Environment env) - throws TemplateModelException { + throws TemplateException { try { return _EvalUtils.compare( seqItem, null, @@ -872,7 +872,7 @@ class BuiltInsForSequences { true, true, true, // The last one is true to emulate an old bug for BC env); } catch (TemplateException ex) { - throw new _TemplateModelException(ex, + throw new TemplateException(ex, "This error has occurred when comparing sequence item at 0-based index ", Integer.valueOf(seqItemIndex), " to the searched item:\n", new _DelayedGetMessage(ex)); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java index e9dc852..e6c9011 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java @@ -508,10 +508,10 @@ class BuiltInsForStringsBasic { : _StringUtils.rightPad(s, width, filling)); } catch (IllegalArgumentException e) { if (filling.length() == 0) { - throw new _TemplateModelException( + throw new TemplateException( "?", key, "(...) argument #2 can't be a 0-length string."); } else { - throw new _TemplateModelException(e, + throw new TemplateException(e, "?", key, "(...) failed: ", e); } } @@ -708,7 +708,7 @@ class BuiltInsForStringsBasic { return ArgumentArrayLayout.TWO_POSITIONAL_PARAMETERS; } - private TemplateModelException newIndexGreaterThanLengthException( + private TemplateException newIndexGreaterThanLengthException( int argIdx, int idx, final int len) throws TemplateModelException { return MessageUtils.newMethodArgInvalidValueException( "?" + key, argIdx, @@ -716,7 +716,7 @@ class BuiltInsForStringsBasic { len, ", but it was ", idx, "."); } - private TemplateModelException newIndexLessThan0Exception( + private TemplateException newIndexLessThan0Exception( int argIdx, int idx) throws TemplateModelException { return MessageUtils.newMethodArgInvalidValueException( "?" + key, argIdx, http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java index 6d67d4f..5c6ad97 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java @@ -156,12 +156,12 @@ class BuiltInsForStringsEncoding { try { charset = Charset.forName(charsetName); } catch (UnsupportedCharsetException e) { - throw new _TemplateModelException(e, "Wrong charset name, or charset is unsupported by the runtime " + throw new TemplateException(e, "Wrong charset name, or charset is unsupported by the runtime " + "environment: " + _StringUtils.jQuote(charsetName)); } return new SimpleScalar(encodeWithCharset(charset)); } catch (Exception e) { - throw new _TemplateModelException(e, "Failed to execute URL encoding."); + throw new TemplateException(e, "Failed to execute URL encoding."); } } @@ -175,7 +175,7 @@ class BuiltInsForStringsEncoding { if (cachedResult == null) { Charset charset = env.getEffectiveURLEscapingCharset(); if (charset == null) { - throw new _TemplateModelException( + throw new TemplateModelException( "To do URL encoding, the framework that encloses " + "FreeMarker must specify the output encoding " + "or the URL encoding charset, so ask the " http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsRegexp.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsRegexp.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsRegexp.java index 8c75de1..a0fa172 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsRegexp.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsRegexp.java @@ -221,7 +221,7 @@ class BuiltInsForStringsRegexp { return new SimpleScalar(firedEntireInputMatcher.group(i)); } catch (Exception e) { - throw new _TemplateModelException(e, "Failed to read match group"); + throw new TemplateModelException("Failed to read match group", e); } } @@ -230,7 +230,7 @@ class BuiltInsForStringsRegexp { try { return firedEntireInputMatcher.groupCount() + 1; } catch (Exception e) { - throw new _TemplateModelException(e, "Failed to get match group count"); + throw new TemplateModelException("Failed to get match group count", e); } } @@ -284,7 +284,7 @@ class BuiltInsForStringsRegexp { public TemplateModel next() throws TemplateModelException { final ArrayList matchingInputParts = RegexMatchModel.this.matchingInputParts; if (matchingInputParts == null) { - if (!hasFindInfo) throw new _TemplateModelException("There were no more matches"); + if (!hasFindInfo) throw new TemplateModelException("There were no more matches"); MatchWithGroups result = new MatchWithGroups(input, matcher); nextIdx++; hasFindInfo = matcher.find(); @@ -293,7 +293,7 @@ class BuiltInsForStringsRegexp { try { return (TemplateModel) matchingInputParts.get(nextIdx++); } catch (IndexOutOfBoundsException e) { - throw new _TemplateModelException(e, "There were no more matches"); + throw new TemplateModelException("There were no more matches", e); } } } @@ -314,7 +314,7 @@ class BuiltInsForStringsRegexp { try { return (TemplateModel) matchingInputParts.get(nextIdx++); } catch (IndexOutOfBoundsException e) { - throw new _TemplateModelException(e, "There were no more matches"); + throw new TemplateModelException("There were no more matches", e); } } }; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java index 4ce70a2..59b390f 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java @@ -662,7 +662,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen if (node == null) { node = getCurrentVisitorNode(); if (node == null) { - throw new _TemplateModelException( + throw new TemplateModelException( "The target node of recursion is missing or null."); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java b/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java index 971f660..b7fdf4c 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java @@ -177,11 +177,11 @@ class MessageUtils { return sb; } - static TemplateModelException newArgCntError(String methodName, int argCnt, int expectedCnt) { + static TemplateException newArgCntError(String methodName, int argCnt, int expectedCnt) { return newArgCntError(methodName, argCnt, expectedCnt, expectedCnt); } - static TemplateModelException newArgCntError(String methodName, int argCnt, int minCnt, int maxCnt) { + static TemplateException newArgCntError(String methodName, int argCnt, int minCnt, int maxCnt) { ArrayList/*<Object>*/ desc = new ArrayList(20); desc.add(methodName); @@ -220,47 +220,47 @@ class MessageUtils { } desc.add("."); - return new _TemplateModelException(desc.toArray()); + return new TemplateException(desc.toArray()); } - static TemplateModelException newMethodArgMustBeStringException(String methodName, int argIdx, TemplateModel arg) { + static TemplateException newMethodArgMustBeStringException(String methodName, int argIdx, TemplateModel arg) { return newMethodArgUnexpectedTypeException(methodName, argIdx, "string", arg); } - static TemplateModelException newMethodArgMustBeNumberException(String methodName, int argIdx, TemplateModel arg) { + static TemplateException newMethodArgMustBeNumberException(String methodName, int argIdx, TemplateModel arg) { return newMethodArgUnexpectedTypeException(methodName, argIdx, "number", arg); } - static TemplateModelException newMethodArgMustBeBooleanException(String methodName, int argIdx, TemplateModel arg) { + static TemplateException newMethodArgMustBeBooleanException(String methodName, int argIdx, TemplateModel arg) { return newMethodArgUnexpectedTypeException(methodName, argIdx, "boolean", arg); } - static TemplateModelException newMethodArgMustBeExtendedHashException( + static TemplateException newMethodArgMustBeExtendedHashException( String methodName, int argIdx, TemplateModel arg) { return newMethodArgUnexpectedTypeException(methodName, argIdx, "extended hash", arg); } - static TemplateModelException newMethodArgMustBeSequenceException( + static TemplateException newMethodArgMustBeSequenceException( String methodName, int argIdx, TemplateModel arg) { return newMethodArgUnexpectedTypeException(methodName, argIdx, "sequence", arg); } - static TemplateModelException newMethodArgMustBeSequenceOrCollectionException( + static TemplateException newMethodArgMustBeSequenceOrCollectionException( String methodName, int argIdx, TemplateModel arg) { return newMethodArgUnexpectedTypeException(methodName, argIdx, "sequence or collection", arg); } - static TemplateModelException newMethodArgUnexpectedTypeException( + static TemplateException 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)), "."); + ", but received ", new _DelayedAOrAn(new _DelayedTemplateLanguageTypeDescription(arg)), "."); } /** * The type of the argument was good, but it's value wasn't. */ - static TemplateModelException newMethodArgInvalidValueException( + static TemplateException newMethodArgInvalidValueException( String methodName, int argIdx, Object... details) { return new _TemplateModelException( methodName, "(...) argument #", Integer.valueOf(argIdx + 1), @@ -270,7 +270,7 @@ class MessageUtils { /** * The type of the argument was good, but the values of two or more arguments are inconsistent with each other. */ - static TemplateModelException newMethodArgsInvalidValueException( + static TemplateException newMethodArgsInvalidValueException( String methodName, Object... details) { return new _TemplateModelException(methodName, "(...) arguments have invalid value: ", details); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/UnexpectedTypeException.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/UnexpectedTypeException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/UnexpectedTypeException.java index 741eed0..aef918d 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/UnexpectedTypeException.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/UnexpectedTypeException.java @@ -129,7 +129,7 @@ public class UnexpectedTypeException extends TemplateException { : "the expression" ), " has evaluated to ", - new _DelayedAOrAn(new _DelayedFTLTypeDescription(model)), + new _DelayedAOrAn(new _DelayedTemplateLanguageTypeDescription(model)), (blamedAssignmentTargetVarName == null ? ":" : ".")}; } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedFTLTypeDescription.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedFTLTypeDescription.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedFTLTypeDescription.java deleted file mode 100644 index 2bdaa6d..0000000 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedFTLTypeDescription.java +++ /dev/null @@ -1,37 +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; - -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.util.TemplateLanguageUtils; - -/** Don't use this; used internally by FreeMarker, might changes without notice. */ -public class _DelayedFTLTypeDescription extends _DelayedConversionToString { - - public _DelayedFTLTypeDescription(TemplateModel tm) { - super(tm); - } - - @Override - protected String doConversion(Object obj) { - return TemplateLanguageUtils.getTypeDescription((TemplateModel) obj); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedTemplateLanguageTypeDescription.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedTemplateLanguageTypeDescription.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedTemplateLanguageTypeDescription.java new file mode 100644 index 0000000..4c22bc2 --- /dev/null +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedTemplateLanguageTypeDescription.java @@ -0,0 +1,37 @@ +/* + * 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; + +import org.apache.freemarker.core.model.TemplateModel; +import org.apache.freemarker.core.util.TemplateLanguageUtils; + +/** Don't use this; used internally by FreeMarker, might changes without notice. */ +public class _DelayedTemplateLanguageTypeDescription extends _DelayedConversionToString { + + public _DelayedTemplateLanguageTypeDescription(TemplateModel tm) { + super(tm); + } + + @Override + protected String doConversion(Object obj) { + return TemplateLanguageUtils.getTypeDescription((TemplateModel) obj); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/_EvalUtils.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_EvalUtils.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_EvalUtils.java index 2c29856..e187f32 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/_EvalUtils.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_EvalUtils.java @@ -293,12 +293,12 @@ public class _EvalUtils { (quoteOperandsInErrors && leftExp != null ? new Object[] { "(", new _DelayedGetCanonicalForm(leftExp), ") value " } : ""), - "is ", new _DelayedAOrAn(new _DelayedFTLTypeDescription(leftValue)), ".\n", + "is ", new _DelayedAOrAn(new _DelayedTemplateLanguageTypeDescription(leftValue)), ".\n", "Right hand operand ", (quoteOperandsInErrors && rightExp != null ? new Object[] { "(", new _DelayedGetCanonicalForm(rightExp), ") value " } : ""), - "is ", new _DelayedAOrAn(new _DelayedFTLTypeDescription(rightValue)), + "is ", new _DelayedAOrAn(new _DelayedTemplateLanguageTypeDescription(rightValue)), "."); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/BeanModel.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/BeanModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/BeanModel.java index 65c3953..0baf851 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/BeanModel.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/BeanModel.java @@ -32,7 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.freemarker.core._DelayedFTLTypeDescription; +import org.apache.freemarker.core._DelayedTemplateLanguageTypeDescription; import org.apache.freemarker.core._DelayedJQuote; import org.apache.freemarker.core._TemplateModelException; import org.apache.freemarker.core.model.AdapterTemplateModel; @@ -154,7 +154,7 @@ public class BeanModel throw new _TemplateModelException(e, "An error has occurred when reading existing sub-variable ", new _DelayedJQuote(key), "; see cause exception! The type of the containing value was: ", - new _DelayedFTLTypeDescription(this) + new _DelayedTemplateLanguageTypeDescription(this) ); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapper.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapper.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapper.java index 709fe81..64b85a3 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapper.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapper.java @@ -47,7 +47,7 @@ import org.apache.freemarker.core.Configuration; import org.apache.freemarker.core.NonTemplateCallPlace; import org.apache.freemarker.core.Version; import org.apache.freemarker.core._CoreAPI; -import org.apache.freemarker.core._DelayedFTLTypeDescription; +import org.apache.freemarker.core._DelayedTemplateLanguageTypeDescription; import org.apache.freemarker.core._DelayedShortClassName; import org.apache.freemarker.core._TemplateModelException; import org.apache.freemarker.core.model.AdapterTemplateModel; @@ -817,10 +817,10 @@ public class DefaultObjectWrapper implements RichObjectWrapper { return ObjectWrapperAndUnwrapper.CANT_UNWRAP_TO_TARGET_CLASS; } else { throw new _TemplateModelException( - "Failed to convert ", new _DelayedFTLTypeDescription(seq), + "Failed to convert ", new _DelayedTemplateLanguageTypeDescription(seq), " object to ", new _DelayedShortClassName(array.getClass()), ": Problematic sequence item at index ", Integer.valueOf(i) ," with value type: ", - new _DelayedFTLTypeDescription(seqItem)); + new _DelayedTemplateLanguageTypeDescription(seqItem)); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/SimpleMethod.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/SimpleMethod.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/SimpleMethod.java index b1d756c..c1786af 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/SimpleMethod.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/SimpleMethod.java @@ -22,7 +22,7 @@ import java.lang.reflect.Array; import java.lang.reflect.Member; import org.apache.freemarker.core._CallableUtils; -import org.apache.freemarker.core._DelayedFTLTypeDescription; +import org.apache.freemarker.core._DelayedTemplateLanguageTypeDescription; import org.apache.freemarker.core._DelayedOrdinal; import org.apache.freemarker.core._ErrorDescriptionBuilder; import org.apache.freemarker.core._TemplateModelException; @@ -151,7 +151,7 @@ class SimpleMethod { _MethodUtils.invocationErrorMessageStart(member), " couldn't be called: Can't convert the ", new _DelayedOrdinal(argIdx + 1), " argument's value to the target Java type, ", _ClassUtils.getShortClassName(targetType), - ". The type of the actual value was: ", new _DelayedFTLTypeDescription(argVal)); + ". The type of the actual value was: ", new _DelayedTemplateLanguageTypeDescription(argVal)); if (argVal instanceof TemplateMarkupOutputModel && (targetType.isAssignableFrom(String.class))) { desc.tip(MARKUP_OUTPUT_TO_STRING_TIP); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d4de527b/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/IncludePage.java ---------------------------------------------------------------------- diff --git a/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/IncludePage.java b/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/IncludePage.java index a1504ff..304c71c 100644 --- a/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/IncludePage.java +++ b/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/IncludePage.java @@ -38,8 +38,7 @@ import javax.servlet.http.HttpServletResponseWrapper; import org.apache.freemarker.core.Environment; import org.apache.freemarker.core.TemplateException; -import org.apache.freemarker.core._DelayedFTLTypeDescription; -import org.apache.freemarker.core.TemplateException; +import org.apache.freemarker.core._DelayedTemplateLanguageTypeDescription; import org.apache.freemarker.core.model.ArgumentArrayLayout; import org.apache.freemarker.core.CallPlace; import org.apache.freemarker.core.model.TemplateBooleanModel; @@ -100,7 +99,7 @@ public class IncludePage implements TemplateDirectiveModel { if (!(path instanceof TemplateScalarModel)) { throw new TemplateException(env, "Expected a scalar model. \"", PATH_PARAM_NAME, "\" is instead ", - new _DelayedFTLTypeDescription(path)); + new _DelayedTemplateLanguageTypeDescription(path)); } final String strPath = ((TemplateScalarModel) path).getAsString(); if (strPath == null) {