Renamed MInvalidValueJsonException to MInvalidJsonValueException.
authorMarco Zanon <info@marcozanon.com>
Thu, 22 Oct 2015 13:03:13 +0000 (13:03 +0000)
committerMarco Zanon <info@marcozanon.com>
Thu, 22 Oct 2015 13:03:13 +0000 (13:03 +0000)
4.x/src/java/com/marcozanon/macaco/json/MInvalidJsonValueException.java [new file with mode: 0644]
4.x/src/java/com/marcozanon/macaco/json/MInvalidValueJsonException.java [deleted file]
4.x/src/java/com/marcozanon/macaco/json/MJsonArray.java
4.x/src/java/com/marcozanon/macaco/json/MJsonBoolean.java
4.x/src/java/com/marcozanon/macaco/json/MJsonNull.java
4.x/src/java/com/marcozanon/macaco/json/MJsonNumber.java
4.x/src/java/com/marcozanon/macaco/json/MJsonObject.java
4.x/src/java/com/marcozanon/macaco/json/MJsonString.java

diff --git a/4.x/src/java/com/marcozanon/macaco/json/MInvalidJsonValueException.java b/4.x/src/java/com/marcozanon/macaco/json/MInvalidJsonValueException.java
new file mode 100644 (file)
index 0000000..eee825e
--- /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.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/4.x/src/java/com/marcozanon/macaco/json/MInvalidValueJsonException.java b/4.x/src/java/com/marcozanon/macaco/json/MInvalidValueJsonException.java
deleted file mode 100644 (file)
index 5e021b2..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.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);
-    }
-
-}
index 87ccea6de3cccc5547dd7afe3e3ab3442aecbc47..10f680b606065a1c931bb18517742a126e010f22 100644 (file)
@@ -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));
         }
     }
 
index 734d2cc4d5a3a1f3a7b9243b80699c62a56d3128..a3c4162003498a6ba41bd362a2009d83008a71e4 100644 (file)
@@ -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));
     }
index 222072a7f025d28b82dd431efc63c52d2688c5c7..44263401f3c298442aa0ec336516c7611984e88f 100644 (file)
@@ -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));
         }
     }
 
index 5a314591d72445a97adc3f2b4dc8dce1e7434eeb..044360360fbda1ea0d2957299427bd439eaaa7a6 100644 (file)
@@ -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);
     }
index a6c73e0fa08d03d9487b981f9764d97567a0baad..bb42c7f248aae673e7e6a8f940235b02b9174446 100644 (file)
@@ -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));
         }
     }
 
index b0db6ec8affdc8189561ef04c214d85f0ad27f5d..ba42617abef55b6ea55d0cfccc0ec8efb53b6f93 100644 (file)
@@ -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));
     }