From: Marco Zanon Date: Thu, 22 Oct 2015 13:03:13 +0000 (+0000) Subject: Renamed MInvalidValueJsonException to MInvalidJsonValueException. X-Git-Tag: 4.0~16 X-Git-Url: https://gitweb.marcozanon.com/?a=commitdiff_plain;h=df0c94e066f4d156da8599c33b08ce51c9553b55;p=Macaco Renamed MInvalidValueJsonException to MInvalidJsonValueException. --- diff --git a/src/java/com/marcozanon/macaco/json/MInvalidJsonValueException.java b/src/java/com/marcozanon/macaco/json/MInvalidJsonValueException.java new file mode 100644 index 0000000..eee825e --- /dev/null +++ b/src/java/com/marcozanon/macaco/json/MInvalidJsonValueException.java @@ -0,0 +1,30 @@ +/** + * Macaco + * Copyright (c) 2009-2015 Marco Zanon . + * Released under MIT license (see LICENSE for details). + */ + +package com.marcozanon.macaco.json; + +@SuppressWarnings("serial") +public class MInvalidJsonValueException extends MJsonException { + + /* */ + + public MInvalidJsonValueException() { + super(); + } + + public MInvalidJsonValueException(String message) { + super(message); + } + + public MInvalidJsonValueException(Throwable error) { + super(error); + } + + public MInvalidJsonValueException(String message, Throwable error) { + super(message, error); + } + +} diff --git a/src/java/com/marcozanon/macaco/json/MInvalidValueJsonException.java b/src/java/com/marcozanon/macaco/json/MInvalidValueJsonException.java deleted file mode 100644 index 5e021b2..0000000 --- a/src/java/com/marcozanon/macaco/json/MInvalidValueJsonException.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.json; - -@SuppressWarnings("serial") -public class MInvalidValueJsonException extends MJsonException { - - /* */ - - public MInvalidValueJsonException() { - super(); - } - - public MInvalidValueJsonException(String message) { - super(message); - } - - public MInvalidValueJsonException(Throwable error) { - super(error); - } - - public MInvalidValueJsonException(String message, Throwable error) { - super(message, error); - } - -} diff --git a/src/java/com/marcozanon/macaco/json/MJsonArray.java b/src/java/com/marcozanon/macaco/json/MJsonArray.java index 87ccea6..10f680b 100644 --- a/src/java/com/marcozanon/macaco/json/MJsonArray.java +++ b/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/src/java/com/marcozanon/macaco/json/MJsonBoolean.java b/src/java/com/marcozanon/macaco/json/MJsonBoolean.java index 734d2cc..a3c4162 100644 --- a/src/java/com/marcozanon/macaco/json/MJsonBoolean.java +++ b/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/src/java/com/marcozanon/macaco/json/MJsonNull.java b/src/java/com/marcozanon/macaco/json/MJsonNull.java index 222072a..4426340 100644 --- a/src/java/com/marcozanon/macaco/json/MJsonNull.java +++ b/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/src/java/com/marcozanon/macaco/json/MJsonNumber.java b/src/java/com/marcozanon/macaco/json/MJsonNumber.java index 5a31459..0443603 100644 --- a/src/java/com/marcozanon/macaco/json/MJsonNumber.java +++ b/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/src/java/com/marcozanon/macaco/json/MJsonObject.java b/src/java/com/marcozanon/macaco/json/MJsonObject.java index a6c73e0..bb42c7f 100644 --- a/src/java/com/marcozanon/macaco/json/MJsonObject.java +++ b/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/src/java/com/marcozanon/macaco/json/MJsonString.java b/src/java/com/marcozanon/macaco/json/MJsonString.java index b0db6ec..ba42617 100644 --- a/src/java/com/marcozanon/macaco/json/MJsonString.java +++ b/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)); }