From: Marco Zanon Date: Thu, 22 Oct 2015 13:00:10 +0000 (+0000) Subject: Renamed MFormatConversionException to MInvalidConversionFormatException. X-Git-Tag: 4.0~17 X-Git-Url: https://gitweb.marcozanon.com/?a=commitdiff_plain;h=40d941f05889a3a3ede38be87be8ffd35f221458;p=Macaco Renamed MFormatConversionException to MInvalidConversionFormatException. --- diff --git a/src/java/com/marcozanon/macaco/conversion/MDateConverter.java b/src/java/com/marcozanon/macaco/conversion/MDateConverter.java index d482d5f..37c6afd 100644 --- a/src/java/com/marcozanon/macaco/conversion/MDateConverter.java +++ b/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/src/java/com/marcozanon/macaco/conversion/MFormatConversionException.java b/src/java/com/marcozanon/macaco/conversion/MFormatConversionException.java deleted file mode 100644 index a94ff8c..0000000 --- a/src/java/com/marcozanon/macaco/conversion/MFormatConversionException.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Macaco - * Copyright (c) 2009-2015 Marco Zanon . - * 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/src/java/com/marcozanon/macaco/conversion/MInvalidConversionFormatException.java b/src/java/com/marcozanon/macaco/conversion/MInvalidConversionFormatException.java new file mode 100644 index 0000000..4fe2a35 --- /dev/null +++ b/src/java/com/marcozanon/macaco/conversion/MInvalidConversionFormatException.java @@ -0,0 +1,30 @@ +/** + * Macaco + * Copyright (c) 2009-2015 Marco Zanon . + * 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); + } + +} diff --git a/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java b/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java index 4d3ba8a..6bcc008 100644 --- a/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java +++ b/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 }