From 03b72843fb58fdedadb88d392b004550cadafe08 Mon Sep 17 00:00:00 2001 From: Marco Zanon Date: Thu, 22 Oct 2015 13:03:13 +0000 Subject: [PATCH] Renamed MInvalidValueJsonException to MInvalidJsonValueException. --- ...n.java => MInvalidJsonValueException.java} | 10 +++---- .../marcozanon/macaco/json/MJsonArray.java | 14 +++++----- .../marcozanon/macaco/json/MJsonBoolean.java | 10 +++---- .../com/marcozanon/macaco/json/MJsonNull.java | 10 +++---- .../marcozanon/macaco/json/MJsonNumber.java | 10 +++---- .../marcozanon/macaco/json/MJsonObject.java | 14 +++++----- .../marcozanon/macaco/json/MJsonString.java | 28 +++++++++---------- 7 files changed, 48 insertions(+), 48 deletions(-) rename 4.x/src/java/com/marcozanon/macaco/json/{MInvalidValueJsonException.java => MInvalidJsonValueException.java} (55%) diff --git a/4.x/src/java/com/marcozanon/macaco/json/MInvalidValueJsonException.java b/4.x/src/java/com/marcozanon/macaco/json/MInvalidJsonValueException.java similarity index 55% rename from 4.x/src/java/com/marcozanon/macaco/json/MInvalidValueJsonException.java rename to 4.x/src/java/com/marcozanon/macaco/json/MInvalidJsonValueException.java index 5e021b2..eee825e 100644 --- a/4.x/src/java/com/marcozanon/macaco/json/MInvalidValueJsonException.java +++ b/4.x/src/java/com/marcozanon/macaco/json/MInvalidJsonValueException.java @@ -7,23 +7,23 @@ package com.marcozanon.macaco.json; @SuppressWarnings("serial") -public class MInvalidValueJsonException extends MJsonException { +public class MInvalidJsonValueException extends MJsonException { /* */ - public MInvalidValueJsonException() { + public MInvalidJsonValueException() { super(); } - public MInvalidValueJsonException(String message) { + public MInvalidJsonValueException(String message) { super(message); } - public MInvalidValueJsonException(Throwable error) { + public MInvalidJsonValueException(Throwable error) { super(error); } - public MInvalidValueJsonException(String message, Throwable error) { + public MInvalidJsonValueException(String message, Throwable error) { super(message, error); } diff --git a/4.x/src/java/com/marcozanon/macaco/json/MJsonArray.java b/4.x/src/java/com/marcozanon/macaco/json/MJsonArray.java index 87ccea6..10f680b 100644 --- a/4.x/src/java/com/marcozanon/macaco/json/MJsonArray.java +++ b/4.x/src/java/com/marcozanon/macaco/json/MJsonArray.java @@ -22,11 +22,11 @@ public class MJsonArray extends MJsonValue { /* */ - public MJsonArray() throws MInvalidValueJsonException { + public MJsonArray() throws MInvalidJsonValueException { this("[]"); } - public MJsonArray(String x) throws MInvalidValueJsonException { + public MJsonArray(String x) throws MInvalidJsonValueException { super(); // this.parseString(x); @@ -37,7 +37,7 @@ public class MJsonArray extends MJsonValue { try { tmpMJsonArray = new MJsonArray(this.getJsonValue()); } - catch (MInvalidValueJsonException exception) { // cannot happen + catch (MInvalidJsonValueException exception) { // cannot happen } return tmpMJsonArray; } @@ -108,20 +108,20 @@ public class MJsonArray extends MJsonValue { testValue.parseString(x.substring(0, position + 1)); return position + 1; } - catch (MInvalidValueJsonException exception) { + catch (MInvalidJsonValueException exception) { position = x.indexOf("]", position + 1); } } return 0; } - public void parseString(String x) throws MInvalidValueJsonException { + public void parseString(String x) throws MInvalidJsonValueException { if (MText.isBlank(x)) { throw new IllegalArgumentException("Invalid 'x': null or empty."); } // if ((2 > x.length()) || ('[' != x.charAt(0)) || (']' != x.charAt(x.length() - 1))) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: must begin and end with square brackets.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: must begin and end with square brackets.", x)); } String y = x.substring(1, x.length() - 1); int parsingPosition = 0; @@ -186,7 +186,7 @@ public class MJsonArray extends MJsonValue { parsingMode = MJsonArray.ParsingMode.ERROR; } if (MJsonArray.ParsingMode.ERROR == parsingMode) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json array.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json array.", x)); } } diff --git a/4.x/src/java/com/marcozanon/macaco/json/MJsonBoolean.java b/4.x/src/java/com/marcozanon/macaco/json/MJsonBoolean.java index 734d2cc..a3c4162 100644 --- a/4.x/src/java/com/marcozanon/macaco/json/MJsonBoolean.java +++ b/4.x/src/java/com/marcozanon/macaco/json/MJsonBoolean.java @@ -14,11 +14,11 @@ public class MJsonBoolean extends MJsonValue { /* */ - public MJsonBoolean() throws MInvalidValueJsonException { + public MJsonBoolean() throws MInvalidJsonValueException { this("false"); } - public MJsonBoolean(String x) throws MInvalidValueJsonException { + public MJsonBoolean(String x) throws MInvalidJsonValueException { super(); // this.parseString(x); @@ -29,7 +29,7 @@ public class MJsonBoolean extends MJsonValue { try { tmpMJsonBoolean = new MJsonBoolean(this.getJsonValue()); } - catch (MInvalidValueJsonException exception) { // cannot happen + catch (MInvalidJsonValueException exception) { // cannot happen } return tmpMJsonBoolean; } @@ -64,13 +64,13 @@ public class MJsonBoolean extends MJsonValue { return 0; } - public void parseString(String x) throws MInvalidValueJsonException { + public void parseString(String x) throws MInvalidJsonValueException { if (MText.isBlank(x)) { throw new IllegalArgumentException("Invalid 'x': null or empty."); } // if ((!"true".equals(x)) && (!"false".equals(x))) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json boolean.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json boolean.", x)); } this.setValue(Boolean.valueOf(x)); } diff --git a/4.x/src/java/com/marcozanon/macaco/json/MJsonNull.java b/4.x/src/java/com/marcozanon/macaco/json/MJsonNull.java index 222072a..4426340 100644 --- a/4.x/src/java/com/marcozanon/macaco/json/MJsonNull.java +++ b/4.x/src/java/com/marcozanon/macaco/json/MJsonNull.java @@ -12,11 +12,11 @@ public class MJsonNull extends MJsonValue { /* */ - public MJsonNull() throws MInvalidValueJsonException { + public MJsonNull() throws MInvalidJsonValueException { this("null"); } - public MJsonNull(String x) throws MInvalidValueJsonException { + public MJsonNull(String x) throws MInvalidJsonValueException { super(); // this.parseString(x); @@ -27,7 +27,7 @@ public class MJsonNull extends MJsonValue { try { tmpMJsonNull = new MJsonNull(this.getJsonValue()); } - catch (MInvalidValueJsonException exception) { // cannot happen + catch (MInvalidJsonValueException exception) { // cannot happen } return tmpMJsonNull; } @@ -45,13 +45,13 @@ public class MJsonNull extends MJsonValue { return 0; } - public void parseString(String x) throws MInvalidValueJsonException { + public void parseString(String x) throws MInvalidJsonValueException { if (MText.isBlank(x)) { throw new IllegalArgumentException("Invalid 'x': null or empty."); } // if (!"null".equals(x)) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json null.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json null.", x)); } } diff --git a/4.x/src/java/com/marcozanon/macaco/json/MJsonNumber.java b/4.x/src/java/com/marcozanon/macaco/json/MJsonNumber.java index 5a31459..0443603 100644 --- a/4.x/src/java/com/marcozanon/macaco/json/MJsonNumber.java +++ b/4.x/src/java/com/marcozanon/macaco/json/MJsonNumber.java @@ -15,11 +15,11 @@ public class MJsonNumber extends MJsonValue { /* */ - public MJsonNumber() throws MInvalidValueJsonException { + public MJsonNumber() throws MInvalidJsonValueException { this("0"); } - public MJsonNumber(String x) throws MInvalidValueJsonException { + public MJsonNumber(String x) throws MInvalidJsonValueException { super(); // this.parseString(x); @@ -30,7 +30,7 @@ public class MJsonNumber extends MJsonValue { try { tmpMJsonNumber = new MJsonNumber(this.getJsonValue()); } - catch (MInvalidValueJsonException exception) { // cannot happen + catch (MInvalidJsonValueException exception) { // cannot happen } return tmpMJsonNumber; } @@ -80,7 +80,7 @@ public class MJsonNumber extends MJsonValue { return validPosition; } - public void parseString(String x) throws MInvalidValueJsonException { + public void parseString(String x) throws MInvalidJsonValueException { if (MText.isBlank(x)) { throw new IllegalArgumentException("Invalid 'x': null or empty."); } @@ -90,7 +90,7 @@ public class MJsonNumber extends MJsonValue { y = new BigDecimal(x); } catch (NumberFormatException exception) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json number.", x)); // no need to propagate exception + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json number.", x)); // no need to propagate exception } this.setValue(y); } diff --git a/4.x/src/java/com/marcozanon/macaco/json/MJsonObject.java b/4.x/src/java/com/marcozanon/macaco/json/MJsonObject.java index a6c73e0..bb42c7f 100644 --- a/4.x/src/java/com/marcozanon/macaco/json/MJsonObject.java +++ b/4.x/src/java/com/marcozanon/macaco/json/MJsonObject.java @@ -25,11 +25,11 @@ public class MJsonObject extends MJsonValue { /* */ - public MJsonObject() throws MInvalidValueJsonException { + public MJsonObject() throws MInvalidJsonValueException { this("{}"); } - public MJsonObject(String x) throws MInvalidValueJsonException { + public MJsonObject(String x) throws MInvalidJsonValueException { super(); // this.parseString(x); @@ -40,7 +40,7 @@ public class MJsonObject extends MJsonValue { try { tmpMJsonObject = new MJsonObject(this.getJsonValue()); } - catch (MInvalidValueJsonException exception) { // cannot happen + catch (MInvalidJsonValueException exception) { // cannot happen } return tmpMJsonObject; } @@ -125,20 +125,20 @@ public class MJsonObject extends MJsonValue { testValue.parseString(x.substring(0, position + 1)); return position + 1; } - catch (MInvalidValueJsonException exception) { + catch (MInvalidJsonValueException exception) { position = x.indexOf("}", position + 1); } } return 0; } - public void parseString(String x) throws MInvalidValueJsonException { + public void parseString(String x) throws MInvalidJsonValueException { if (MText.isBlank(x)) { throw new IllegalArgumentException("Invalid 'x': null or empty."); } // if ((2 > x.length()) || ('{' != x.charAt(0)) || ('}' != x.charAt(x.length() - 1))) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: must begin and end with curly brackets.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: must begin and end with curly brackets.", x)); } String y = x.substring(1, x.length() - 1); int parsingPosition = 0; @@ -236,7 +236,7 @@ public class MJsonObject extends MJsonValue { parsingMode = MJsonObject.ParsingMode.ERROR; } if (MJsonObject.ParsingMode.ERROR == parsingMode) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json object.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json object.", x)); } } diff --git a/4.x/src/java/com/marcozanon/macaco/json/MJsonString.java b/4.x/src/java/com/marcozanon/macaco/json/MJsonString.java index b0db6ec..ba42617 100644 --- a/4.x/src/java/com/marcozanon/macaco/json/MJsonString.java +++ b/4.x/src/java/com/marcozanon/macaco/json/MJsonString.java @@ -16,15 +16,15 @@ public class MJsonString extends MJsonValue { /* */ - public MJsonString() throws MInvalidValueJsonException { + public MJsonString() throws MInvalidJsonValueException { this("\"\""); } - public MJsonString(String x) throws MInvalidValueJsonException { + public MJsonString(String x) throws MInvalidJsonValueException { this(x, false); } - public MJsonString(String x, boolean extendedEscapeMode) throws MInvalidValueJsonException { + public MJsonString(String x, boolean extendedEscapeMode) throws MInvalidJsonValueException { super(); // this.setExtendedEscapeMode(extendedEscapeMode); @@ -36,7 +36,7 @@ public class MJsonString extends MJsonValue { try { tmpMJsonString = new MJsonString(this.getJsonValue()); } - catch (MInvalidValueJsonException exception) { // cannot happen + catch (MInvalidJsonValueException exception) { // cannot happen } return tmpMJsonString; } @@ -143,7 +143,7 @@ public class MJsonString extends MJsonValue { return y.toString(); } - protected static String getUnescapedString(String x) throws MInvalidValueJsonException { + protected static String getUnescapedString(String x) throws MInvalidJsonValueException { if (null == x) { throw new IllegalArgumentException("Invalid 'x': null."); } @@ -184,7 +184,7 @@ public class MJsonString extends MJsonValue { } else if (x.indexOf("\\u", i) == i) { if ((i + 2 + 4) > x.length()) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x)); } else { int ch = -1; @@ -194,10 +194,10 @@ public class MJsonString extends MJsonValue { if ((0xD800 <= ch) && (0xDBFF >= ch)) { i++; if (x.indexOf("\\u", i) != i) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x)); } else if ((i + 2 + 4) > x.length()) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x)); } else { int cl = -1; @@ -205,13 +205,13 @@ public class MJsonString extends MJsonValue { cl = Integer.parseInt(x.substring(i + 2, i + 2 + 4), 16); i += 5; if ((0xDC00 >= cl) || (0xDFFF <= cl)) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x)); } int c = ((ch - 0xD800) << 10) + (cl - 0xDC00) + 0x010000; y.appendCodePoint(c); } catch (NumberFormatException exception) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x)); // no need to propagate exception + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x)); // no need to propagate exception } } } @@ -220,7 +220,7 @@ public class MJsonString extends MJsonValue { } } catch (NumberFormatException exception) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x)); // no need to propagate exception + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x)); // no need to propagate exception } } } @@ -268,17 +268,17 @@ public class MJsonString extends MJsonValue { return (quotationMarkPosition + 1) + 1; } - public void parseString(String x) throws MInvalidValueJsonException { + public void parseString(String x) throws MInvalidJsonValueException { if (MText.isBlank(x)) { throw new IllegalArgumentException("Invalid 'x': null or empty."); } // if ((2 > x.length()) || ('"' != x.charAt(0)) || ('"' != x.charAt(x.length() - 1))) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x)); } String y = x.substring(1, x.length() - 1); if (-1 < y.replaceAll("\\\\\"", "__").indexOf("\"")) { - throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x)); + throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x)); } this.setValue(MJsonString.getUnescapedString(y)); } -- 2.30.2