Renamed MFormatConversionException to MInvalidConversionFormatException.
authorMarco Zanon <info@marcozanon.com>
Thu, 22 Oct 2015 13:00:10 +0000 (13:00 +0000)
committerMarco Zanon <info@marcozanon.com>
Thu, 22 Oct 2015 13:00:10 +0000 (13:00 +0000)
4.x/src/java/com/marcozanon/macaco/conversion/MDateConverter.java
4.x/src/java/com/marcozanon/macaco/conversion/MFormatConversionException.java [deleted file]
4.x/src/java/com/marcozanon/macaco/conversion/MInvalidConversionFormatException.java [new file with mode: 0644]
4.x/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java

index d482d5fd6cc7e9664249895da629ee97851addfe..37c6afd486937471996f64717d36a551875c449c 100644 (file)
@@ -140,7 +140,7 @@ public class MDateConverter extends MObject {
         }
     }
 
-    protected static Date getDateFromStringByParameters(String x, String inputDateFormat, Locale inputLocale, TimeZone inputTimeZone) throws MFormatConversionException {
+    protected static Date getDateFromStringByParameters(String x, String inputDateFormat, Locale inputLocale, TimeZone inputTimeZone) throws MInvalidConversionFormatException {
         if (MText.isBlank(x)) {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
@@ -162,7 +162,7 @@ public class MDateConverter extends MObject {
             d1 = sdf.parse(x);
         }
         catch (ParseException exception) {
-            throw new MFormatConversionException(String.format("Invalid 'x' or parsing: %s (input format: %s).", x, inputDateFormat)); // no need to propagate exception
+            throw new MInvalidConversionFormatException(String.format("Invalid 'x' or parsing: %s (input format: %s).", x, inputDateFormat)); // no need to propagate exception
         }
         Calendar c2 = Calendar.getInstance(inputTimeZone, inputLocale);
         c2.clear();
@@ -174,7 +174,7 @@ public class MDateConverter extends MObject {
         c2.set(Calendar.SECOND, c1.get(Calendar.SECOND));
         Date d2 = c2.getTime();
         if (!x.equals(sdf.format(d2))) {
-            throw new MFormatConversionException(String.format("Invalid 'x' or parsing: %s (input format: %s).", x, inputDateFormat));
+            throw new MInvalidConversionFormatException(String.format("Invalid 'x' or parsing: %s (input format: %s).", x, inputDateFormat));
         }
         return d2;
     }
@@ -196,18 +196,18 @@ public class MDateConverter extends MObject {
         return sdf.format(date);
     }
 
-    public Date getDateFromString(String x) throws MFormatConversionException {
+    public Date getDateFromString(String x) throws MInvalidConversionFormatException {
         Date y = null;
         for (String dateFormat: this.getDateFormatsReference()) {
             try {
                 y = this.getDateFromStringByParameters(x, dateFormat, this.getLocale(), this.getTimeZoneReference());
                 return y;
             }
-            catch (MFormatConversionException exception) {
+            catch (MInvalidConversionFormatException exception) {
             }
         }
         if (null == y) {
-            throw new MFormatConversionException(String.format("Invalid 'x': %s.", x));
+            throw new MInvalidConversionFormatException(String.format("Invalid 'x': %s.", x));
         }
         return y; // necessary to avoid Java compilation errors
     }
diff --git a/4.x/src/java/com/marcozanon/macaco/conversion/MFormatConversionException.java b/4.x/src/java/com/marcozanon/macaco/conversion/MFormatConversionException.java
deleted file mode 100644 (file)
index a94ff8c..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Macaco
- * Copyright (c) 2009-2015 Marco Zanon <info@marcozanon.com>.
- * Released under MIT license (see LICENSE for details).
- */
-
-package com.marcozanon.macaco.conversion;
-
-@SuppressWarnings("serial")
-public class MFormatConversionException extends MConversionException {
-
-    /* */
-
-    public MFormatConversionException() {
-        super();
-    }
-
-    public MFormatConversionException(String message) {
-        super(message);
-    }
-
-    public MFormatConversionException(Throwable error) {
-        super(error);
-    }
-
-    public MFormatConversionException(String message, Throwable error) {
-        super(message, error);
-    }
-
-}
diff --git a/4.x/src/java/com/marcozanon/macaco/conversion/MInvalidConversionFormatException.java b/4.x/src/java/com/marcozanon/macaco/conversion/MInvalidConversionFormatException.java
new file mode 100644 (file)
index 0000000..4fe2a35
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * Macaco
+ * Copyright (c) 2009-2015 Marco Zanon <info@marcozanon.com>.
+ * Released under MIT license (see LICENSE for details).
+ */
+
+package com.marcozanon.macaco.conversion;
+
+@SuppressWarnings("serial")
+public class MInvalidConversionFormatException extends MConversionException {
+
+    /* */
+
+    public MInvalidConversionFormatException() {
+        super();
+    }
+
+    public MInvalidConversionFormatException(String message) {
+        super(message);
+    }
+
+    public MInvalidConversionFormatException(Throwable error) {
+        super(error);
+    }
+
+    public MInvalidConversionFormatException(String message, Throwable error) {
+        super(message, error);
+    }
+
+}
index 4d3ba8aa52be81b4bcbe63f3f51fefbc250a518c..6bcc00808d6404c7699e581e28640b2184107e63 100644 (file)
@@ -113,7 +113,7 @@ public class MNumberConverter extends MObject {
         }
     }
 
-    protected static BigDecimal getNumberFromStringByParameters(String x, String inputNumberFormat, Locale inputLocale) throws MFormatConversionException {
+    protected static BigDecimal getNumberFromStringByParameters(String x, String inputNumberFormat, Locale inputLocale) throws MInvalidConversionFormatException {
         if (MText.isBlank(x)) {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
@@ -128,7 +128,7 @@ public class MNumberConverter extends MObject {
         ParsePosition validPosition = new ParsePosition(0);
         BigDecimal bd = (BigDecimal)df.parse(x, validPosition);
         if (validPosition.getIndex() < x.length()) {
-            throw new MFormatConversionException(String.format("Invalid 'x' or parsing: %s (input format: %s).", x, inputNumberFormat));
+            throw new MInvalidConversionFormatException(String.format("Invalid 'x' or parsing: %s (input format: %s).", x, inputNumberFormat));
         }
         return bd;
     }
@@ -147,18 +147,18 @@ public class MNumberConverter extends MObject {
         return df.format(number);
     }
 
-    public BigDecimal getNumberFromString(String x) throws MFormatConversionException {
+    public BigDecimal getNumberFromString(String x) throws MInvalidConversionFormatException {
         BigDecimal y = null;
         for (String numberFormat: this.getNumberFormatsReference()) {
             try {
                 y = this.getNumberFromStringByParameters(x, numberFormat, this.getLocale());
                 return y;
             }
-            catch (MFormatConversionException exception) {
+            catch (MInvalidConversionFormatException exception) {
             }
         }
         if (null == y) {
-            throw new MFormatConversionException(String.format("Invalid 'x': %s.", x));
+            throw new MInvalidConversionFormatException(String.format("Invalid 'x': %s.", x));
         }
         return y; // necessary to avoid Java compilation errors
     }