You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2015/09/17 12:15:26 UTC

incubator-freemarker git commit: Unifying UnformattableDateException and UnformattableNumberException as UnformattableValueException. Added UnparsableValueException, using it for TemplateDateFormat.parse.

Repository: incubator-freemarker
Updated Branches:
  refs/heads/2.3-gae 89ec237f4 -> 03e8fc070


Unifying UnformattableDateException and UnformattableNumberException as UnformattableValueException. Added UnparsableValueException, using it for TemplateDateFormat.parse.


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/03e8fc07
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/03e8fc07
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/03e8fc07

Branch: refs/heads/2.3-gae
Commit: 03e8fc070cec335ecfe3c11aaf5c1979b858ca3e
Parents: 89ec237
Author: ddekany <dd...@apache.org>
Authored: Thu Sep 17 12:15:07 2015 +0200
Committer: ddekany <dd...@apache.org>
Committed: Thu Sep 17 12:15:07 2015 +0200

----------------------------------------------------------------------
 .../BackwardCompatibleTemplateNumberFormat.java |  2 +-
 .../core/BuiltInsForMultipleTypes.java          |  2 +-
 src/main/java/freemarker/core/Environment.java  |  2 +-
 .../core/ISOLikeTemplateDateFormat.java         | 27 ++++++++-----
 .../freemarker/core/JavaTemplateDateFormat.java | 10 +++--
 .../core/JavaTemplateNumberFormat.java          |  8 ++--
 .../freemarker/core/TemplateDateFormat.java     |  2 +-
 .../freemarker/core/TemplateFormatUtil.java     |  6 +--
 .../freemarker/core/TemplateNumberFormat.java   |  2 +-
 .../core/UnformattableDateException.java        | 41 --------------------
 .../core/UnformattableNumberException.java      | 41 --------------------
 .../core/UnformattableValueException.java       | 41 ++++++++++++++++++++
 ...nDateTypeFormattingUnsupportedException.java |  2 +-
 .../core/UnparsableValueException.java          | 38 ++++++++++++++++++
 .../core/BaseNTemplateNumberFormatFactory.java  |  4 +-
 ...EpochMillisDivTemplateDateFormatFactory.java |  9 ++---
 .../EpochMillisTemplateDateFormatFactory.java   |  9 ++---
 .../core/HexTemplateNumberFormatFactory.java    |  6 +--
 ...AndTZSensitiveTemplateDateFormatFactory.java | 11 +++---
 ...aleSensitiveTemplateNumberFormatFactory.java |  6 +--
 20 files changed, 137 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/BackwardCompatibleTemplateNumberFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BackwardCompatibleTemplateNumberFormat.java b/src/main/java/freemarker/core/BackwardCompatibleTemplateNumberFormat.java
index 04aca2e..9f7dcc8 100644
--- a/src/main/java/freemarker/core/BackwardCompatibleTemplateNumberFormat.java
+++ b/src/main/java/freemarker/core/BackwardCompatibleTemplateNumberFormat.java
@@ -25,6 +25,6 @@ package freemarker.core;
  */
 abstract class BackwardCompatibleTemplateNumberFormat extends TemplateNumberFormat {
 
-    abstract String format(Number number) throws UnformattableNumberException;
+    abstract String format(Number number) throws UnformattableValueException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java b/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
index 58bcddc..6520720 100644
--- a/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
+++ b/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
@@ -186,7 +186,7 @@ class BuiltInsForMultipleTypes {
             throws TemplateModelException {
                 try {
                     return df.parse(text);
-                } catch (java.text.ParseException e) {
+                } catch (TemplateValueFormatException e) {
                     throw new _TemplateModelException(e,
                             "The string doesn't match the expected date/time/date-time format. "
                             + "The string to parse was: ", new _DelayedJQuote(text), ". ",

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/Environment.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Environment.java b/src/main/java/freemarker/core/Environment.java
index 29812a9..da980c7 100644
--- a/src/main/java/freemarker/core/Environment.java
+++ b/src/main/java/freemarker/core/Environment.java
@@ -1081,7 +1081,7 @@ public final class Environment extends Configurable {
             throws TemplateModelException, _MiscTemplateException {
         try {
             return format.format(number);
-        } catch (UnformattableNumberException e) {
+        } catch (UnformattableValueException e) {
             throw new _MiscTemplateException(exp, e, this,
                     "Failed to format number with ", new _DelayedJQuote(format.getDescription()), ": ",
                     e.getMessage());

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/ISOLikeTemplateDateFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/ISOLikeTemplateDateFormat.java b/src/main/java/freemarker/core/ISOLikeTemplateDateFormat.java
index 5dda644..b26352a 100644
--- a/src/main/java/freemarker/core/ISOLikeTemplateDateFormat.java
+++ b/src/main/java/freemarker/core/ISOLikeTemplateDateFormat.java
@@ -22,6 +22,7 @@ package freemarker.core;
 import java.util.Date;
 import java.util.TimeZone;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import freemarker.template.TemplateDateModel;
 import freemarker.template.TemplateModelException;
 import freemarker.template.utility.DateUtil;
@@ -197,17 +198,23 @@ abstract class ISOLikeTemplateDateFormat  extends TemplateDateFormat {
             DateToISO8601CalendarFactory calendarFactory);
 
     @Override
-    public final Date parse(String s) throws java.text.ParseException {
+    @SuppressFBWarnings(value = "RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN",
+            justification = "Known to use the singleton Boolean-s only")
+    public final Date parse(String s) throws UnparsableValueException {
         CalendarFieldsToDateConverter calToDateConverter = factory.getCalendarFieldsToDateCalculator(env);
         TimeZone tz = forceUTC != Boolean.FALSE ? DateUtil.UTC : timeZone;
-        if (dateType == TemplateDateModel.DATE) {
-            return parseDate(s, tz, calToDateConverter);
-        } else if (dateType == TemplateDateModel.TIME) {
-            return parseTime(s, tz, calToDateConverter);
-        } else if (dateType == TemplateDateModel.DATETIME) {
-            return parseDateTime(s, tz, calToDateConverter);
-        } else {
-            throw new BugException("Unexpected date type: " + dateType);
+        try {
+            if (dateType == TemplateDateModel.DATE) {
+                return parseDate(s, tz, calToDateConverter);
+            } else if (dateType == TemplateDateModel.TIME) {
+                return parseTime(s, tz, calToDateConverter);
+            } else if (dateType == TemplateDateModel.DATETIME) {
+                return parseDateTime(s, tz, calToDateConverter);
+            } else {
+                throw new BugException("Unexpected date type: " + dateType);
+            }
+        } catch (DateParseException e) {
+            throw new UnparsableValueException(e.getMessage(), e);
         }
     }
     
@@ -255,7 +262,7 @@ abstract class ISOLikeTemplateDateFormat  extends TemplateDateFormat {
      */
     @Override
     public <MO extends TemplateMarkupOutputModel> MO format(TemplateDateModel dateModel,
-            MarkupOutputFormat<MO> outputFormat) throws UnformattableNumberException, TemplateModelException {
+            MarkupOutputFormat<MO> outputFormat) throws TemplateValueFormatException, TemplateModelException {
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/JavaTemplateDateFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/JavaTemplateDateFormat.java b/src/main/java/freemarker/core/JavaTemplateDateFormat.java
index 747c7b4..8183a88 100644
--- a/src/main/java/freemarker/core/JavaTemplateDateFormat.java
+++ b/src/main/java/freemarker/core/JavaTemplateDateFormat.java
@@ -44,8 +44,12 @@ class JavaTemplateDateFormat extends TemplateDateFormat {
     }
 
     @Override
-    public Date parse(String s) throws ParseException {
-        return javaDateFormat.parse(s);
+    public Date parse(String s) throws UnparsableValueException {
+        try {
+            return javaDateFormat.parse(s);
+        } catch (ParseException e) {
+            throw new UnparsableValueException(e.getMessage(), e);
+        }
     }
 
     @Override
@@ -70,7 +74,7 @@ class JavaTemplateDateFormat extends TemplateDateFormat {
      */
     @Override
     public <MO extends TemplateMarkupOutputModel> MO format(TemplateDateModel dateModel,
-            MarkupOutputFormat<MO> outputFormat) throws UnformattableNumberException, TemplateModelException {
+            MarkupOutputFormat<MO> outputFormat) throws UnformattableValueException, TemplateModelException {
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/JavaTemplateNumberFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/JavaTemplateNumberFormat.java b/src/main/java/freemarker/core/JavaTemplateNumberFormat.java
index b34414b..4144af8 100644
--- a/src/main/java/freemarker/core/JavaTemplateNumberFormat.java
+++ b/src/main/java/freemarker/core/JavaTemplateNumberFormat.java
@@ -34,14 +34,14 @@ final class JavaTemplateNumberFormat extends BackwardCompatibleTemplateNumberFor
     }
 
     @Override
-    public String format(TemplateNumberModel numberModel) throws UnformattableNumberException, TemplateModelException {
+    public String format(TemplateNumberModel numberModel) throws UnformattableValueException, TemplateModelException {
         Number number = TemplateFormatUtil.getNonNullNumber(numberModel);
         return format(number);
     }
 
     @Override
     public <MO extends TemplateMarkupOutputModel> MO format(TemplateNumberModel dateModel,
-            MarkupOutputFormat<MO> outputFormat) throws UnformattableNumberException, TemplateModelException {
+            MarkupOutputFormat<MO> outputFormat) throws UnformattableValueException, TemplateModelException {
         return null;
     }
 
@@ -51,11 +51,11 @@ final class JavaTemplateNumberFormat extends BackwardCompatibleTemplateNumberFor
     }
 
     @Override
-    String format(Number number) throws UnformattableNumberException {
+    String format(Number number) throws UnformattableValueException {
         try {
             return javaNumberFormat.format(number);
         } catch (ArithmeticException e) {
-            throw new UnformattableNumberException(
+            throw new UnformattableValueException(
                     "This format can't format the " + number + " number. Reason: " + e.getMessage(), e);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/TemplateDateFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TemplateDateFormat.java b/src/main/java/freemarker/core/TemplateDateFormat.java
index 497ea25..92d63fa 100644
--- a/src/main/java/freemarker/core/TemplateDateFormat.java
+++ b/src/main/java/freemarker/core/TemplateDateFormat.java
@@ -98,7 +98,7 @@ public abstract class TemplateDateFormat extends TemplateValueFormat {
      * 
      * @return The interpretation of the text as {@link Date}. Can't be {@code null}.
      */
-    public abstract Date parse(String s) throws java.text.ParseException;
+    public abstract Date parse(String s) throws TemplateValueFormatException;
     
     /**
      * Tells if this formatter should be re-created if the locale changes.

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/TemplateFormatUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TemplateFormatUtil.java b/src/main/java/freemarker/core/TemplateFormatUtil.java
index 2856df5..66e10da 100644
--- a/src/main/java/freemarker/core/TemplateFormatUtil.java
+++ b/src/main/java/freemarker/core/TemplateFormatUtil.java
@@ -43,10 +43,10 @@ public final class TemplateFormatUtil {
 
     /**
      * Utility method to extract the {@link Number} from an {@link TemplateNumberModel}, and throw
-     * {@link UnformattableNumberException} with a standard error message if that's {@code null}.
+     * {@link UnformattableValueException} with a standard error message if that's {@code null}.
      */
     public static Number getNonNullNumber(TemplateNumberModel numberModel)
-            throws TemplateModelException, UnformattableNumberException {
+            throws TemplateModelException, UnformattableValueException {
         Number number = numberModel.getAsNumber();
         if (number == null) {
             throw EvalUtil.newModelHasStoredNullException(Number.class, numberModel, null);
@@ -56,7 +56,7 @@ public final class TemplateFormatUtil {
 
     /**
      * Utility method to extract the {@link Date} from an {@link TemplateDateModel}, and throw
-     * {@link UnformattableDateException} with a standard error message if that's {@code null}.
+     * {@link UnformattableValueException} with a standard error message if that's {@code null}.
      */
     public static Date getNonNullDate(TemplateDateModel dateModel) throws TemplateModelException {
         Date date = dateModel.getAsDate();

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/TemplateNumberFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TemplateNumberFormat.java b/src/main/java/freemarker/core/TemplateNumberFormat.java
index 87d4bbc..ee2ec83 100644
--- a/src/main/java/freemarker/core/TemplateNumberFormat.java
+++ b/src/main/java/freemarker/core/TemplateNumberFormat.java
@@ -50,7 +50,7 @@ public abstract class TemplateNumberFormat extends TemplateValueFormat {
      * 
      * @throws TemplateValueFormatException
      *             If any problem occurs while parsing/getting the format. Notable subclass:
-     *             {@link UnformattableNumberException}.
+     *             {@link UnformattableValueException}.
      * @throws TemplateModelException
      *             Exception thrown by the {@code dateModel} object when calling its methods.
      */

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/UnformattableDateException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnformattableDateException.java b/src/main/java/freemarker/core/UnformattableDateException.java
deleted file mode 100644
index 8173b30..0000000
--- a/src/main/java/freemarker/core/UnformattableDateException.java
+++ /dev/null
@@ -1,41 +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;
-
-/**
- * Thrown when a {@link TemplateDateModel} can't be formatted because of the value/properties of the
- * {@link TemplateDateModel}. For example, a formatter may not support dates before year 1. The most often used subclass
- * is {@link UnknownDateTypeFormattingUnsupportedException}.
- * 
- * @since 2.3.24
- */
-public abstract class UnformattableDateException extends TemplateValueFormatException {
-
-    public UnformattableDateException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public UnformattableDateException(String message) {
-        super(message);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/UnformattableNumberException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnformattableNumberException.java b/src/main/java/freemarker/core/UnformattableNumberException.java
deleted file mode 100644
index 2342338..0000000
--- a/src/main/java/freemarker/core/UnformattableNumberException.java
+++ /dev/null
@@ -1,41 +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.TemplateNumberModel;
-
-/**
- * Thrown when a {@link TemplateNumberModel} can't be formatted because of the value/properties of the
- * {@link TemplateNumberModel}. For example, some formatters might can't format NaN, or can't display numbers above
- * certain magnitude.
- * 
- * @since 2.3.24
- */
-public class UnformattableNumberException extends TemplateValueFormatException {
-
-    public UnformattableNumberException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public UnformattableNumberException(String message) {
-        super(message);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/UnformattableValueException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnformattableValueException.java b/src/main/java/freemarker/core/UnformattableValueException.java
new file mode 100644
index 0000000..d769680
--- /dev/null
+++ b/src/main/java/freemarker/core/UnformattableValueException.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+/**
+ * Thrown when a {@link TemplateModel} can't be formatted because of the value/properties of it are outside of that the
+ * {@link TemplateValueFormat} supports. For example, a formatter may not support dates before year 1, or can't format
+ * NaN. The most often used subclass is {@link UnknownDateTypeFormattingUnsupportedException}.
+ * 
+ * @since 2.3.24
+ */
+public class UnformattableValueException extends TemplateValueFormatException {
+
+    public UnformattableValueException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public UnformattableValueException(String message) {
+        super(message);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/UnknownDateTypeFormattingUnsupportedException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnknownDateTypeFormattingUnsupportedException.java b/src/main/java/freemarker/core/UnknownDateTypeFormattingUnsupportedException.java
index 45be76a..84275bd 100644
--- a/src/main/java/freemarker/core/UnknownDateTypeFormattingUnsupportedException.java
+++ b/src/main/java/freemarker/core/UnknownDateTypeFormattingUnsupportedException.java
@@ -26,7 +26,7 @@ import freemarker.template.TemplateDateModel;
  * 
  * @since 2.3.24
  */
-public final class UnknownDateTypeFormattingUnsupportedException extends UnformattableDateException {
+public final class UnknownDateTypeFormattingUnsupportedException extends UnformattableValueException {
 
     public UnknownDateTypeFormattingUnsupportedException() {
         super(MessageUtil.UNKNOWN_DATE_TO_STRING_ERROR_MESSAGE);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/main/java/freemarker/core/UnparsableValueException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnparsableValueException.java b/src/main/java/freemarker/core/UnparsableValueException.java
new file mode 100644
index 0000000..dab0397
--- /dev/null
+++ b/src/main/java/freemarker/core/UnparsableValueException.java
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ * Thrown when the content of the string that should be parsed by the {@link TemplateValueFormat} doesn't match what the
+ * format expects.
+ * 
+ * @since 2.3.24
+ */
+public class UnparsableValueException extends TemplateValueFormatException {
+
+    public UnparsableValueException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public UnparsableValueException(String message) {
+        this(message, null);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/test/java/freemarker/core/BaseNTemplateNumberFormatFactory.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/BaseNTemplateNumberFormatFactory.java b/src/test/java/freemarker/core/BaseNTemplateNumberFormatFactory.java
index f2f0dae..d527aa0 100644
--- a/src/test/java/freemarker/core/BaseNTemplateNumberFormatFactory.java
+++ b/src/test/java/freemarker/core/BaseNTemplateNumberFormatFactory.java
@@ -87,7 +87,7 @@ public class BaseNTemplateNumberFormatFactory extends TemplateNumberFormatFactor
                 return Integer.toString(NumberUtil.toIntExact(n), base);
             } catch (ArithmeticException e) {
                 if (fallbackFormat == null) {
-                    throw new UnformattableNumberException(
+                    throw new UnformattableValueException(
                             n + " doesn't fit into an int, and there was no fallback format specified.");
                 } else {
                     return fallbackFormat.format(numberModel);
@@ -97,7 +97,7 @@ public class BaseNTemplateNumberFormatFactory extends TemplateNumberFormatFactor
 
         @Override
         public <MO extends TemplateMarkupOutputModel> MO format(TemplateNumberModel dateModel,
-                MarkupOutputFormat<MO> outputFormat) throws UnformattableNumberException, TemplateModelException {
+                MarkupOutputFormat<MO> outputFormat) throws UnformattableValueException, TemplateModelException {
             return null;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/test/java/freemarker/core/EpochMillisDivTemplateDateFormatFactory.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/EpochMillisDivTemplateDateFormatFactory.java b/src/test/java/freemarker/core/EpochMillisDivTemplateDateFormatFactory.java
index 0181452..b056e7b 100644
--- a/src/test/java/freemarker/core/EpochMillisDivTemplateDateFormatFactory.java
+++ b/src/test/java/freemarker/core/EpochMillisDivTemplateDateFormatFactory.java
@@ -18,7 +18,6 @@
  */
 package freemarker.core;
 
-import java.text.ParseException;
 import java.util.Date;
 import java.util.Locale;
 import java.util.TimeZone;
@@ -64,7 +63,7 @@ public class EpochMillisDivTemplateDateFormatFactory extends TemplateDateFormatF
         
         @Override
         public String format(TemplateDateModel dateModel)
-                throws UnformattableDateException, TemplateModelException {
+                throws UnformattableValueException, TemplateModelException {
             return String.valueOf(TemplateFormatUtil.getNonNullDate(dateModel).getTime() / divisor);
         }
 
@@ -80,16 +79,16 @@ public class EpochMillisDivTemplateDateFormatFactory extends TemplateDateFormatF
 
         @Override
         public <MO extends TemplateMarkupOutputModel> MO format(TemplateDateModel dateModel,
-                MarkupOutputFormat<MO> outputFormat) throws UnformattableNumberException, TemplateModelException {
+                MarkupOutputFormat<MO> outputFormat) throws UnformattableValueException, TemplateModelException {
             throw new NotImplementedException();
         }
 
         @Override
-        public Date parse(String s) throws ParseException {
+        public Date parse(String s) throws UnparsableValueException {
             try {
                 return new Date(Long.parseLong(s));
             } catch (NumberFormatException e) {
-                throw new ParseException("Malformed long", 0);
+                throw new UnparsableValueException("Malformed long");
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/test/java/freemarker/core/EpochMillisTemplateDateFormatFactory.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/EpochMillisTemplateDateFormatFactory.java b/src/test/java/freemarker/core/EpochMillisTemplateDateFormatFactory.java
index d2e8a0a..176aec7 100644
--- a/src/test/java/freemarker/core/EpochMillisTemplateDateFormatFactory.java
+++ b/src/test/java/freemarker/core/EpochMillisTemplateDateFormatFactory.java
@@ -18,7 +18,6 @@
  */
 package freemarker.core;
 
-import java.text.ParseException;
 import java.util.Date;
 import java.util.Locale;
 import java.util.TimeZone;
@@ -51,7 +50,7 @@ public class EpochMillisTemplateDateFormatFactory extends TemplateDateFormatFact
         
         @Override
         public String format(TemplateDateModel dateModel)
-                throws UnformattableDateException, TemplateModelException {
+                throws UnformattableValueException, TemplateModelException {
             return String.valueOf(TemplateFormatUtil.getNonNullDate(dateModel).getTime());
         }
 
@@ -67,16 +66,16 @@ public class EpochMillisTemplateDateFormatFactory extends TemplateDateFormatFact
 
         @Override
         public <MO extends TemplateMarkupOutputModel> MO format(TemplateDateModel dateModel,
-                MarkupOutputFormat<MO> outputFormat) throws UnformattableNumberException, TemplateModelException {
+                MarkupOutputFormat<MO> outputFormat) throws UnformattableValueException, TemplateModelException {
             throw new NotImplementedException();
         }
 
         @Override
-        public Date parse(String s) throws ParseException {
+        public Date parse(String s) throws UnparsableValueException {
             try {
                 return new Date(Long.parseLong(s));
             } catch (NumberFormatException e) {
-                throw new ParseException("Malformed long", 0);
+                throw new UnparsableValueException("Malformed long");
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/test/java/freemarker/core/HexTemplateNumberFormatFactory.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/HexTemplateNumberFormatFactory.java b/src/test/java/freemarker/core/HexTemplateNumberFormatFactory.java
index 8a9ded2..f18d97b 100644
--- a/src/test/java/freemarker/core/HexTemplateNumberFormatFactory.java
+++ b/src/test/java/freemarker/core/HexTemplateNumberFormatFactory.java
@@ -47,18 +47,18 @@ public class HexTemplateNumberFormatFactory extends TemplateNumberFormatFactory
         
         @Override
         public String format(TemplateNumberModel numberModel)
-                throws UnformattableNumberException, TemplateModelException {
+                throws UnformattableValueException, TemplateModelException {
             Number n = TemplateFormatUtil.getNonNullNumber(numberModel);
             try {
                 return Integer.toHexString(NumberUtil.toIntExact(n));
             } catch (ArithmeticException e) {
-                throw new UnformattableNumberException(n + " doesn't fit into an int");
+                throw new UnformattableValueException(n + " doesn't fit into an int");
             }
         }
 
         @Override
         public <MO extends TemplateMarkupOutputModel> MO format(TemplateNumberModel dateModel,
-                MarkupOutputFormat<MO> outputFormat) throws UnformattableNumberException, TemplateModelException {
+                MarkupOutputFormat<MO> outputFormat) throws UnformattableValueException, TemplateModelException {
             return null;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/test/java/freemarker/core/LocAndTZSensitiveTemplateDateFormatFactory.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/LocAndTZSensitiveTemplateDateFormatFactory.java b/src/test/java/freemarker/core/LocAndTZSensitiveTemplateDateFormatFactory.java
index a5e4d89..7fd46fe 100644
--- a/src/test/java/freemarker/core/LocAndTZSensitiveTemplateDateFormatFactory.java
+++ b/src/test/java/freemarker/core/LocAndTZSensitiveTemplateDateFormatFactory.java
@@ -18,7 +18,6 @@
  */
 package freemarker.core;
 
-import java.text.ParseException;
 import java.util.Date;
 import java.util.Locale;
 import java.util.TimeZone;
@@ -55,7 +54,7 @@ public class LocAndTZSensitiveTemplateDateFormatFactory extends TemplateDateForm
 
         @Override
         public String format(TemplateDateModel dateModel)
-                throws UnformattableDateException, TemplateModelException {
+                throws UnformattableValueException, TemplateModelException {
             return String.valueOf(TemplateFormatUtil.getNonNullDate(dateModel).getTime() + "@" + locale + ":" + timeZone.getID());
         }
 
@@ -71,20 +70,20 @@ public class LocAndTZSensitiveTemplateDateFormatFactory extends TemplateDateForm
 
         @Override
         public <MO extends TemplateMarkupOutputModel> MO format(TemplateDateModel dateModel,
-                MarkupOutputFormat<MO> outputFormat) throws UnformattableNumberException, TemplateModelException {
+                MarkupOutputFormat<MO> outputFormat) throws UnformattableValueException, TemplateModelException {
             throw new NotImplementedException();
         }
 
         @Override
-        public Date parse(String s) throws ParseException {
+        public Date parse(String s) throws UnparsableValueException {
             try {
                 int atIdx = s.indexOf("@");
                 if (atIdx == -1) {
-                    throw new ParseException("Missing @", 0);
+                    throw new UnparsableValueException("Missing @");
                 }
                 return new Date(Long.parseLong(s.substring(0, atIdx)));
             } catch (NumberFormatException e) {
-                throw new ParseException("Malformed long", 0);
+                throw new UnparsableValueException("Malformed long");
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/03e8fc07/src/test/java/freemarker/core/LocaleSensitiveTemplateNumberFormatFactory.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/LocaleSensitiveTemplateNumberFormatFactory.java b/src/test/java/freemarker/core/LocaleSensitiveTemplateNumberFormatFactory.java
index 01dbc83..3fb2fae 100644
--- a/src/test/java/freemarker/core/LocaleSensitiveTemplateNumberFormatFactory.java
+++ b/src/test/java/freemarker/core/LocaleSensitiveTemplateNumberFormatFactory.java
@@ -48,18 +48,18 @@ public class LocaleSensitiveTemplateNumberFormatFactory extends TemplateNumberFo
         
         @Override
         public String format(TemplateNumberModel numberModel)
-                throws UnformattableNumberException, TemplateModelException {
+                throws UnformattableValueException, TemplateModelException {
             Number n = numberModel.getAsNumber();
             try {
                 return n + "_" + locale;
             } catch (ArithmeticException e) {
-                throw new UnformattableNumberException(n + " doesn't fit into an int");
+                throw new UnformattableValueException(n + " doesn't fit into an int");
             }
         }
     
         @Override
         public <MO extends TemplateMarkupOutputModel> MO format(TemplateNumberModel dateModel,
-                MarkupOutputFormat<MO> outputFormat) throws UnformattableNumberException, TemplateModelException {
+                MarkupOutputFormat<MO> outputFormat) throws UnformattableValueException, TemplateModelException {
             return null;
         }