From e84ffd40d1740433441915108685bb5dd17ecc22 Mon Sep 17 00:00:00 2001 From: Marco Zanon Date: Thu, 22 Oct 2015 13:00:10 +0000 Subject: [PATCH] Renamed MFormatConversionException to MInvalidConversionFormatException. --- .../marcozanon/macaco/conversion/MDateConverter.java | 12 ++++++------ ...n.java => MInvalidConversionFormatException.java} | 10 +++++----- .../macaco/conversion/MNumberConverter.java | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) rename 4.x/src/java/com/marcozanon/macaco/conversion/{MFormatConversionException.java => MInvalidConversionFormatException.java} (50%) diff --git a/4.x/src/java/com/marcozanon/macaco/conversion/MDateConverter.java b/4.x/src/java/com/marcozanon/macaco/conversion/MDateConverter.java index d482d5f..37c6afd 100644 --- a/4.x/src/java/com/marcozanon/macaco/conversion/MDateConverter.java +++ b/4.x/src/java/com/marcozanon/macaco/conversion/MDateConverter.java @@ -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/MInvalidConversionFormatException.java similarity index 50% rename from 4.x/src/java/com/marcozanon/macaco/conversion/MFormatConversionException.java rename to 4.x/src/java/com/marcozanon/macaco/conversion/MInvalidConversionFormatException.java index a94ff8c..4fe2a35 100644 --- a/4.x/src/java/com/marcozanon/macaco/conversion/MFormatConversionException.java +++ b/4.x/src/java/com/marcozanon/macaco/conversion/MInvalidConversionFormatException.java @@ -7,23 +7,23 @@ package com.marcozanon.macaco.conversion; @SuppressWarnings("serial") -public class MFormatConversionException extends MConversionException { +public class MInvalidConversionFormatException extends MConversionException { /* */ - public MFormatConversionException() { + public MInvalidConversionFormatException() { super(); } - public MFormatConversionException(String message) { + public MInvalidConversionFormatException(String message) { super(message); } - public MFormatConversionException(Throwable error) { + public MInvalidConversionFormatException(Throwable error) { super(error); } - public MFormatConversionException(String message, Throwable error) { + public MInvalidConversionFormatException(String message, Throwable error) { super(message, error); } diff --git a/4.x/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java b/4.x/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java index 4d3ba8a..6bcc008 100644 --- a/4.x/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java +++ b/4.x/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java @@ -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 } -- 2.30.2