Class RJInternal


  • public class RJInternal
    extends java.lang.Object
    Class which provides a series of helper functions for both ReadJSON and ReadJSON.XL.

    The helpers for class ReadArrJSON are kept inside that class, and do not appear in this one.


Stateless Class: This class neither contains any program-state, nor can it be instantiated. The @StaticFunctional Annotation may also be called 'The Spaghetti Report'. Static-Functional classes are, essentially, C-Styled Files, without any constructors or non-static member field. It is very similar to the Java-Bean @Stateless Annotation.
  • 1 Constructor(s), 1 declared private, zero-argument constructor
  • 25 Method(s), 25 declared static
  • 0 Field(s)


    • Method Summary

       
      GET Methods: Standard Number Extraction
      Modifier and Type Method
      protected static <T> T GET​(JsonArray ja, int index, Class<T> primitiveClass, Function<JsonNumber,​T> jsonTypeToJavaType)
      protected static <T extends Number>
      T
      GET​(JsonArray ja, int index, Function<JsonNumber,​T> jsonTypeToJavaType, Class<T> returnClass)
      protected static <T extends Number>
      T
      GET​(JsonObject jo, String propertyName, boolean isOptional, Function<JsonNumber,​T> jsonTypeToJavaType, Class<T> returnClass)
      protected static <T> T GET​(JsonObject jo, String propertyName, Class<T> primitiveClass, Function<JsonNumber,​T> jsonTypeToJavaType)
       
      GET Methods: Accepting a 'FLAGS' Parameter
      Modifier and Type Method
      protected static <T extends Number>
      T
      GET​(JsonArray ja, int index, int FLAGS, T defaultValue, Class<T> returnClass, Function<JsonNumber,​T> jsonTypeToJavaType, Function<JsonNumber,​T> typeToType2)
      protected static <T extends Number>
      T
      GET​(JsonObject jo, String propertyName, int FLAGS, T defaultValue, Class<T> returnClass, Function<JsonNumber,​T> jsonTypeToJavaType, Function<JsonNumber,​T> typeToType2)
       
      PARSE Methods: String Parsing, also accepting a 'FLAGS' Parameter
      Modifier and Type Method
      protected static <T extends Number>
      T
      PARSE​(JsonArray ja, int index, int FLAGS, T defaultValue, Class<T> returnClass, Function<String,​T> parser, Function<BigDecimal,​T> defaultParser1, Function<BigDecimal,​T> defaultParser2)
      protected static <T extends Number>
      T
      PARSE​(JsonObject jo, String propertyName, int FLAGS, T defaultValue, Class<T> returnClass, Function<String,​T> parser, Function<BigDecimal,​T> defaultParser1, Function<BigDecimal,​T> defaultParser2)
       
      Flag Checking Helper Methods
      Modifier and Type Method
      protected static <T> T IOOBEX​(JsonArray ja, int index, T defaultValue, int FLAGS)
      protected static <T> T JNAEX​(JsonArray ja, int index, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, Class<T> returnClass)
      protected static <T> T JNOEX​(JsonObject jo, String propertyName, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, Class<T> returnClass)
      protected static <T> T JPMEX​(JsonObject jo, String propertyName, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, Class<T> returnClass)
      protected static <T> T JSPAEX​(Exception e, JsonArray ja, int index, T defaultValue, int FLAGS, JsonValue retrievedValue, Class<T> returnClass)
      protected static <T> T JSPOEX​(Exception e, JsonObject jo, String propertyName, T defaultValue, int FLAGS, JsonValue retrievedValue, Class<T> returnClass)
      protected static <T> T JTAEX​(JsonArray ja, int index, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, JsonValue retrievedValue, Class<T> returnClass)
      protected static <T> T JTOEX​(JsonObject jo, String propertyName, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, JsonValue retrievedValue, Class<T> returnClass)
       
      Assorted Extras
      Modifier and Type Method
      protected static Number convertToNumber​(String s)
      protected static Number convertToNumber​(BigDecimal bd)
      protected static Number convertToNumber​(JsonNumber jn)
      protected static double DOUBLE_WITH_CHECK​(BigDecimal bd)
      protected static double DOUBLE_WITH_CHECK​(JsonNumber jn)
      protected static float FLOAT_WITH_CHECK​(BigDecimal bd)
      protected static float FLOAT_WITH_CHECK​(JsonNumber jn)
      protected static void throwAE_INFINITY​(BigDecimal bd, String primTypeName, boolean positiveOrNegative)
      protected static void throwAE_INFINITY​(JsonNumber jn, String primTypeName, boolean positiveOrNegative)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • throwAE_INFINITY

        🡇    
        protected static void throwAE_INFINITY​(JsonNumber jn,
                                               java.lang.String primTypeName,
                                               boolean positiveOrNegative)
        Helper Method that generates an ArithmeticException with a uniformly-consistent exception message
        Parameters:
        jn - A Java javax.json.JsonNumber whose magnitude is too large.
        Throws:
        java.lang.ArithmeticException
        Code:
        Exact Method Body:
         throw new ArithmeticException(
             "When attempting to conver the JsonNumber [" + jn.toString() + "] to a " +
             primTypeName + " primitive, the number had a magnitude that was too large: " +
             (positiveOrNegative ? "Positive" : "Negative") + " Infinity was returned."
         );
        
      • throwAE_INFINITY

        🡅  🡇    
        protected static void throwAE_INFINITY​(java.math.BigDecimal bd,
                                               java.lang.String primTypeName,
                                               boolean positiveOrNegative)
        Helper Method that generates an ArithmeticException with a uniformly-consistent exception message
        Parameters:
        bd - A Java java.math.BigDecimal whose magnitude is too large.
        Throws:
        java.lang.ArithmeticException
        Code:
        Exact Method Body:
         throw new ArithmeticException(
             "When attempting to conver the JsonNumber [" + bd.toString() + "] to a " +
             primTypeName + " primitive, the number had a magnitude that was too large: " +
             (positiveOrNegative ? "Positive" : "Negative") + " Infinity was returned."
         );
        
      • DOUBLE_WITH_CHECK

        🡅  🡇    
        protected static double DOUBLE_WITH_CHECK​(java.math.BigDecimal bd)
        Converts a BigDecimal into a Java double
        Parameters:
        bd - Any BigDecimal
        Returns:
        Java double primitive
        Throws:
        JsonArithmeticException - If infinity is returned from the call to code BigDecimal.doubleValue()
        Code:
        Exact Method Body:
         double ret = bd.doubleValue();
        
         if (ret == Double.NEGATIVE_INFINITY) throwAE_INFINITY(bd, "double", false);
         if (ret == Double.POSITIVE_INFINITY) throwAE_INFINITY(bd, "double", true);
        
         return ret;
        
      • FLOAT_WITH_CHECK

        🡅  🡇    
        protected static float FLOAT_WITH_CHECK​(java.math.BigDecimal bd)
        Converts a BigDecimal into a Java float
        Parameters:
        bd - Any BigDecimal
        Returns:
        Java float primitive
        Throws:
        JsonArithmeticException - If infinity is returned from the call to code BigDecimal.floatValue()
        Code:
        Exact Method Body:
         float ret = bd.floatValue();
        
         if (ret == Float.NEGATIVE_INFINITY) throwAE_INFINITY(bd, "float", false);
         if (ret == Float.POSITIVE_INFINITY) throwAE_INFINITY(bd, "float", true);
        
         return ret;
        
      • convertToNumber

        🡅  🡇    
        protected static java.lang.Number convertToNumber​(JsonNumber jn)
        Converts any JsonNumber into one of the inheriting subclasses of Java class Number
        Parameters:
        jn - Any JsonNumber
        Returns:
        The most appropriate intance of java.lang.Number
        See Also:
        ReadJSON.getNUMBER(JsonObject, String, int, Number), ReadJSON.getNUMBER(JsonArray, int, int, Number), JsonNumber.isIntegral(), JsonNumber.bigIntegerValue(), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         if (jn.isIntegral())
         {
             BigInteger bi = jn.bigIntegerValue();
             int        l  = bi.bitLength();
        
             if (l <= 32) return Integer.valueOf(bi.intValue());
             if (l <= 64) return Long.valueOf(bi.longValue());
             return bi;
         }
         else
         {
             BigDecimal bd = jn.bigDecimalValue();
        
             // This probably isn't the most efficient thing I've ever written, but I do not
             // have the energy to stare at java.math.BigDecimal at the moment.  The JavaDoc for
             // this JSON => Java-Type Conversion is quite intricate.  I will figure this out at
             // at later date.
        
             float f = bd.floatValue();
             if ((f != Float.NEGATIVE_INFINITY) && (f != Float.POSITIVE_INFINITY)) return f;
        
             double d = bd.doubleValue();
             if ((f != Double.NEGATIVE_INFINITY) && (f != Double.POSITIVE_INFINITY)) return d;
        
             return bd;
         }
        
      • convertToNumber

        🡅  🡇    
        protected static java.lang.Number convertToNumber​(java.math.BigDecimal bd)
        Converts any java.math.BigDecimal into one of the inheriting subclasses of Number.
        Parameters:
        bd - Any BigDecimal
        Returns:
        The most appropriate instance of java.lang.Number
        Code:
        Exact Method Body:
         if (bd.scale() == 0)
         {
             BigInteger bi = bd.toBigInteger();
             int        l  = bi.bitLength();
        
             if (l <= 32) return Integer.valueOf(bi.intValue());
             if (l <= 64) return Long.valueOf(bi.longValue());
             return bi;
         }
         else
         {
             // This probably isn't the most efficient thing I've ever written, but I do not
             // have the energy to stare at java.math.BigDecimal at the moment.  The JavaDoc for
             // this JSON => Java-Type Conversion is quite intricate.  I will figure this out at
             // at later date.
        
             float f = bd.floatValue();
             if ((f != Float.NEGATIVE_INFINITY) && (f != Float.POSITIVE_INFINITY)) return f;
        
             double d = bd.doubleValue();
             if ((f != Double.NEGATIVE_INFINITY) && (f != Double.POSITIVE_INFINITY)) return d;
        
             return bd;
         }
        
      • GET

        🡅  🡇    
        protected static <T> T GET​
                    (JsonArray ja,
                     int index,
                     java.lang.Class<T> primitiveClass,
                     java.util.function.Function<JsonNumber,​T> jsonTypeToJavaType)
        
        This is an internal helper method for retrieving an element from a JsonArray, and converting it to one of the standard Java Types.
        Type Parameters:
        T - This is the return Java-Type of this method. Java Type-Inference is used to determine this parameter.

        NOTE: Here, all this means is that the Java Compiler will look at the left hand side of the assignment to infer what type is returned.

        ALSO: It is somewhat interesting that the Java Compiler will automatically convert a Java int to a java.lang.Integer - it is called auto-boxing . The wrapper classes (java.lang.Integer, java.lang.Float, etc...) are sometimes called Boxed Types by Sun / Oracle (for lack of a better-term).

        Essentially, during the compile-time analysis, the primitive number classes and the full-object (boxed) classes are seemingly treated as interchangeable. Remember, though, a primitive cannot be assigned null; and furthermore there is some cost/overhead in changing from the boxed ava.lang.Integer to the primitive int type (albeit, an extremely low-cost overhead).
        Parameters:
        ja - Any instance of JsonArray
        index - Any index into the array which holds a JsonNumber
        primitiveClass - Used for exception-reporting only. This is the final expect Java Primitive Type that will ultimately be returned to the user. It is passed as a convenience field when the null-primitive exception is thrown.
        jsonTypeToJavaType - This should convert an instance of JsonNumber, into one of the concrete, boxed, subclasses of java.lang.Number
        Returns:
        The converted number, as an instance Generic-Parameter 'T'
        Throws:
        JsonNullPrimitiveArrException - If the JsonArray element located at 'index' contains Json-Null, then this exception throws.
        JsonTypeArrException - If the JsonArray element located at 'index' does not contain a JsonNumber, then this exception throws.
        JsonArithmeticArrException - If there any arithmetic problems during the conversion
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of 'ja'
        See Also:
        ReadJSON.getInt(JsonArray, int), ReadJSON.getLong(JsonArray, int), ReadJSON.getShort(JsonArray, int), ReadJSON.getByte(JsonArray, int), ReadJSON.getDouble(JsonArray, int), ReadJSON.getFloat(JsonArray, int)
        Code:
        Exact Method Body:
         // This will throw an IndexOutOfBoundsException if the index is out of bounds.
         JsonValue jv = ja.get(index);
        
         switch (jv.getValueType())
         {
             // This method allows for null-returns.  If Json-Null, return Java-Null.
             case NULL: throw new JsonNullPrimitiveArrException
                 (ja, index, NUMBER, primitiveClass);
        
             // This will throw ArithmeticException if it cannot be converted
             case NUMBER:
        
                 // REMEMBER: The primary reason for this class is that MEANINGFUL ERROR MESSAGES
                 //           make Json-Binding a lot easer...  "JsonArithmeticException" has just
                 //           about everything that you need to know when debugging this stuff
        
                 try
                     { return jsonTypeToJavaType.apply((JsonNumber) jv); }
        
                 catch (ArithmeticException ae)
                 {
                     throw new JsonArithmeticArrException
                         (ae, ja, index, NUMBER, jv, primitiveClass);
                 }
        
             // The JsonValue at the specified array-index does not contain an JsonNumber.
             default: throw new JsonTypeArrException
                 (ja, index, NUMBER, jv, primitiveClass);
         }
        
      • GET

        🡅  🡇    
        protected static <T extends java.lang.Number> T GET​
                    (JsonArray ja,
                     int index,
                     java.util.function.Function<JsonNumber,​T> jsonTypeToJavaType,
                     java.lang.Class<T> returnClass)
        
        This is an internal helper method for retrieving an element from a JsonArray, and converting it to one of the standard Java Types.
        Type Parameters:
        T - This is the return Java-Type of this method. Java Type-Inference is used to determine this parameter.

        NOTE: Here, all this means is that the Java Compiler will look at the left hand side of the assignment to infer what type is returned.

        ALSO: It is somewhat interesting that the Java Compiler will automatically convert a Java int to a java.lang.Integer - it is called auto-boxing . The wrapper classes (java.lang.Integer, java.lang.Float, etc...) are sometimes called Boxed Types by Sun / Oracle (for lack of a better-term).

        Essentially, during the compile-time analysis, the primitive number classes and the full-object (boxed) classes are seemingly treated as interchangeable. Remember, though, a primitive cannot be assigned null; and furthermore there is some cost/overhead in changing from the boxed ava.lang.Integer to the primitive int type (albeit, an extremely low-cost overhead).
        Parameters:
        ja - Any instance of JsonArray
        index - Any index into the array which holds a JsonNumber
        jsonTypeToJavaType - This should convert an instance of JsonNumber, into one of the concrete, boxed, subclasses of java.lang.Number
        Returns:
        The converted number, as an instance Generic-Parameter 'T'
        Throws:
        JsonTypeArrException - If the JsonArray element located at 'index' does not contain a JsonNumber, then this exception throws.
        JsonArithmeticArrException - If there any arithmetic problems during the conversion
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of 'ja'
        See Also:
        ReadJSON.getINTEGER(JsonArray, int), ReadJSON.getLONG(JsonArray, int), ReadJSON.getSHORT(JsonArray, int), ReadJSON.getBYTE(JsonArray, int), ReadJSON.getDOUBLE(JsonArray, int), ReadJSON.getFLOAT(JsonArray, int)
        Code:
        Exact Method Body:
         // This will throw an IndexOutOfBoundsException if the index is out of bounds.
         // Since this *IS NOT* a method with FLAGS, the user has no way to avoid this exception
         // throw if, indeed, the index really is out of bounds!
         //
         // Using one of the 'FLAGS' variants of the 'GET' array-index, a user may request that
         // either null or a default-value be returned.  Not with this version-of 'GET', though.
        
         JsonValue jv = ja.get(index);
        
         switch (jv.getValueType())
         {
             // This method allows for null-returns.  If Json-Null, return Java-Null.
             case NULL: return null;
        
             // This will throw ArithmeticException if it cannot be converted
             case NUMBER:
        
                 // REMEMBER: The primary reason for this class is that MEANINGFUL ERROR MESSAGES
                 //           make Json-Binding a lot easer...  "JsonArithmeticException" has just
                 //           about everything that you need to know when debugging this stuff
        
                 try
                     { return jsonTypeToJavaType.apply((JsonNumber) jv); }
        
                 catch (ArithmeticException ae)
                 {
                     throw new JsonArithmeticArrException
                         (ae, ja, index, NUMBER, jv, returnClass);
                 }
        
             // The JsonValue at the specified array-index does not contain an JsonNumber.
             default: throw new JsonTypeArrException
                 (ja, index, NUMBER, jv, returnClass);
         }
        
      • GET

        🡅  🡇    
        protected static <T> T GET​
                    (JsonObject jo,
                     java.lang.String propertyName,
                     java.lang.Class<T> primitiveClass,
                     java.util.function.Function<JsonNumber,​T> jsonTypeToJavaType)
        
        This is an internal helper method for retrieving a property from a JsonObject, and converting it to one of the standard Java Types.
        Type Parameters:
        T - This is the return Java-Type of this method. Java Type-Inference is used to determine this parameter.

        NOTE: Here, all this means is that the Java Compiler will look at the left hand side of the assignment to infer what type is returned.

        ALSO: It is somewhat interesting that the Java Compiler will automatically convert a Java int to a java.lang.Integer - it is called auto-boxing . The wrapper classes (java.lang.Integer, java.lang.Float, etc...) are sometimes called Boxed Types by Sun / Oracle (for lack of a better-term).

        Essentially, during the compile-time analysis, the primitive number classes and the full-object (boxed) classes are seemingly treated as interchangeable. Remember, though, a primitive cannot be assigned null; and furthermore there is some cost/overhead in changing from the boxed ava.lang.Integer to the primitive int type (albeit, an extremely low-cost overhead).
        Parameters:
        jo - Any instance of JsonObject
        propertyName - Any property name contained by 'jo'
        jsonTypeToJavaType - This should convert an instance of JsonNumber, into one of the concrete, boxed, subclasses of java.lang.Number
        Returns:
        The converted number, as an instance Generic-Parameter 'T'
        Throws:
        JsonNullPrimitiveObjException - If the JsonObject property specified by 'propertyName' contains Json-Null, then this exception throws.
        JsonPropMissingException - If the property is missing, and 'isOptional' is FALSE.
        JsonTypeObjException - If the JsonArray element located at 'index' does not contain a JsonNumber, then this exception throws.
        JsonArithmeticObjException - If there any arithmetic problems during the conversion
        See Also:
        ReadJSON.getInt(JsonObject, String), ReadJSON.getLong(JsonObject, String), ReadJSON.getShort(JsonObject, String), ReadJSON.getByte(JsonObject, String), ReadJSON.getDouble(JsonObject, String), ReadJSON.getFloat(JsonObject, String)
        Code:
        Exact Method Body:
         // Here, a 'get' request was made for a property that isn't actually listed among the
         // properties in the provided JsonObject.  Since this internal 'GET' is used by methods
         // that are trying to return a Java Primitive (like 'int' or 'float'), then an exception
         // has to be thrown.  The option of returning 'null' isn't possible here!
            
         if (! jo.containsKey(propertyName)) throw new JsonPropMissingException
             (jo, propertyName, NUMBER, primitiveClass);
        
         JsonValue jv = jo.get(propertyName);
        
         switch (jv.getValueType())
         {
             // This method allows for null-returns.  If Json-Null, return Java-Null.
             case NULL: throw new JsonNullPrimitiveObjException
                 (jo, propertyName, NUMBER, primitiveClass);
        
             // This will throw ArithmeticException if this isn't a proper Java int
             case NUMBER:
        
                 // REMEMBER: The primary reason for this class is that MEANINGFUL ERROR MESSAGES
                 //           make Json-Binding a lot easer...  "JsonArithmeticException" has just
                 //           about everything that you need to know when debugging this stuff
        
                 try
                     { return jsonTypeToJavaType.apply((JsonNumber) jv); }
        
                 catch (ArithmeticException ae)
                 {
                     throw new JsonArithmeticObjException
                         (ae, jo, propertyName, NUMBER, jv, primitiveClass);
                 }
        
             // The JsonObject property does not contain a JsonNumber.
             default: throw new JsonTypeObjException
                 (jo, propertyName, NUMBER, jv, primitiveClass);
         }
        
      • GET

        🡅  🡇    
        protected static <T extends java.lang.Number> T GET​
                    (JsonObject jo,
                     java.lang.String propertyName,
                     boolean isOptional,
                     java.util.function.Function<JsonNumber,​T> jsonTypeToJavaType,
                     java.lang.Class<T> returnClass)
        
        This is an internal helper method for retrieving a property from a JsonObject, and converting it to one of the standard Java Types.
        Type Parameters:
        T - This is the return Java-Type of this method. Java Type-Inference is used to determine this parameter.

        NOTE: Here, all this means is that the Java Compiler will look at the left hand side of the assignment to infer what type is returned.

        ALSO: It is somewhat interesting that the Java Compiler will automatically convert a Java int to a java.lang.Integer - it is called auto-boxing . The wrapper classes (java.lang.Integer, java.lang.Float, etc...) are sometimes called Boxed Types by Sun / Oracle (for lack of a better-term).

        Essentially, during the compile-time analysis, the primitive number classes and the full-object (boxed) classes are seemingly treated as interchangeable. Remember, though, a primitive cannot be assigned null; and furthermore there is some cost/overhead in changing from the boxed ava.lang.Integer to the primitive int type (albeit, an extremely low-cost overhead).
        Parameters:
        jo - Any instance of JsonObject
        propertyName - Any property name contained by 'jo'
        isOptional - Indicates whether 'propertyName' may be missing from 'jo'
        jsonTypeToJavaType - This should convert an instance of JsonNumber, into one of the concrete, boxed, subclasses of java.lang.Number
        Returns:
        The converted number, as an instance Generic-Parameter 'T'
        Throws:
        JsonPropMissingException - If the property is missing, and 'isOptional' is FALSE.
        JsonTypeObjException - If the JsonArray element located at 'index' does not contain a JsonNumber, then this exception throws.
        JsonArithmeticObjException - If there any arithmetic problems during the conversion
        See Also:
        ReadJSON.getINTEGER(JsonObject, String, boolean), ReadJSON.getLONG(JsonObject, String, boolean), ReadJSON.getSHORT(JsonObject, String, boolean), ReadJSON.getBYTE(JsonObject, String, boolean), ReadJSON.getDOUBLE(JsonObject, String, boolean), ReadJSON.getFLOAT(JsonObject, String, boolean)
        Code:
        Exact Method Body:
         // Here, a 'get' request was made for a property that isn't actually listed among the
         // properties in the provided JsonObject.  If 'isOptional' return null, otherwise throw
        
         if (! jo.containsKey(propertyName))
         {
             if (isOptional) return null;
        
             throw new JsonPropMissingException
                 (jo, propertyName, NUMBER, returnClass);
         }
        
         JsonValue jv = jo.get(propertyName);
        
         switch (jv.getValueType())
         {
             // This method allows for null-returns.  If Json-Null, return Java-Null.
             case NULL: return null;
        
             // This will throw ArithmeticException if this isn't a proper Java int
             case NUMBER:
        
                 // REMEMBER: The primary reason for this class is that MEANINGFUL ERROR MESSAGES
                 //           make Json-Binding a lot easer...  "JsonArithmeticException" has just
                 //           about everything that you need to know when debugging this stuff
        
                 try
                     { return jsonTypeToJavaType.apply((JsonNumber) jv); }
        
                 catch (ArithmeticException ae)
                 {
                     throw new JsonArithmeticObjException
                         (ae, jo, propertyName, NUMBER, jv, returnClass);
                 }
        
             // The JsonObject property does not contain a JsonNumber.
             default: throw new JsonTypeObjException
                 (jo, propertyName, NUMBER, jv, returnClass);
         }
        
      • IOOBEX

        🡅  🡇    
        protected static <T> T IOOBEX​(JsonArray ja,
                                      int index,
                                      T defaultValue,
                                      int FLAGS)
        Flag Checker for IndexOutOfBoundsException.

        Checks whether the relevant flags were set in the users FLAGS parameter, and either returns the appropriate value accordingly, or throws IndexOutOfBoundsException.
        Type Parameters:
        T - If requested, the default-value is returned, and this is its type.
        Returns:
        Can return either the user-provided default-value, or null depending on whether a match was found in the user's request settings ('FLAGS').
        Throws:
        java.lang.IndexOutOfBoundsException - If no flag was set specifying one of the two return-value options.
        See Also:
        JFlag.RETURN_NULL_ON_IOB, JFlag.RETURN_DEFVAL_ON_IOB, JFlag.RETURN_NULL_ON_ANY_ALL, JFlag.RETURN_DEFVAL_ON_ANY_ALL
        Code:
        Exact Method Body:
         if ((FLAGS & RETURN_NULL_ON_IOB) != 0)          return null;
         if ((FLAGS & RETURN_DEFVAL_ON_IOB) != 0)        return defaultValue;
         if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
         if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
        
         ja.get(index); // Throws an IndexOutOfBoundsException
        
         // If you have reached this statment, this method was not applied properly
         throw new Torello.Java.UnreachableError();
        
      • JPMEX

        🡅  🡇    
        protected static <T> T JPMEX​(JsonObject jo,
                                     java.lang.String propertyName,
                                     T defaultValue,
                                     int FLAGS,
                                     JsonValue.ValueType expectedType,
                                     java.lang.Class<T> returnClass)
        Flag Checker for JsonPropMissingException

        Checks whether the relevant flags were set in the users FLAGS parameter, and either returns the appropriate value accordingly, or throws JsonPropMissingException.
        Type Parameters:
        T - If requested, the default-value is returned, and this is its type.
        Returns:
        Can return either the user-provided default-value, or null depending on whether a match was found in the user's request settings ('FLAGS').
        Throws:
        JsonPropMissingException - If no flag was set specifying one of the two return-value options.
        See Also:
        JFlag.RETURN_NULL_ON_MISSING, JFlag.RETURN_DEFVAL_ON_MISSING, JFlag.RETURN_NULL_ON_ANY_ALL, JFlag.RETURN_DEFVAL_ON_ANY_ALL
        Code:
        Exact Method Body:
         if ((FLAGS & RETURN_NULL_ON_MISSING) != 0)      return null;
         if ((FLAGS & RETURN_DEFVAL_ON_MISSING) != 0)    return defaultValue;
         if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
         if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
        
         throw new JsonPropMissingException(jo, propertyName, expectedType, returnClass);
        
      • JNAEX

        🡅  🡇    
        protected static <T> T JNAEX​(JsonArray ja,
                                     int index,
                                     T defaultValue,
                                     int FLAGS,
                                     JsonValue.ValueType expectedType,
                                     java.lang.Class<T> returnClass)
        Flag Checker for JsonNullArrException

        Checks whether the relevant flags were set in the users FLAGS parameter, and either returns the appropriate value accordingly, or throws JsonNullArrException.
        Type Parameters:
        T - If requested, the default-value is returned, and this is its type.
        Returns:
        Can return either the user-provided default-value, or null depending on whether a match was found in the user's request settings ('FLAGS').
        Throws:
        JsonNullArrException - If no flag was set specifying one of the two return-value options.
        See Also:
        JFlag.RETURN_NULL_ON_NULL, JFlag.RETURN_DEFVAL_ON_NULL, JFlag.RETURN_NULL_ON_ANY_ALL, JFlag.RETURN_DEFVAL_ON_ANY_ALL
        Code:
        Exact Method Body:
         if ((FLAGS & RETURN_NULL_ON_NULL) != 0)         return null;
         if ((FLAGS & RETURN_DEFVAL_ON_NULL) != 0)       return defaultValue;
         if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
         if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
        
         throw new JsonNullArrException(ja, index, expectedType, returnClass);
        
      • JNOEX

        🡅  🡇    
        protected static <T> T JNOEX​(JsonObject jo,
                                     java.lang.String propertyName,
                                     T defaultValue,
                                     int FLAGS,
                                     JsonValue.ValueType expectedType,
                                     java.lang.Class<T> returnClass)
        Flag Checker for JsonNullObjException

        Checks whether the relevant flags were set in the users FLAGS parameter, and either returns the appropriate value accordingly, or throws JsonNullObjException.
        Type Parameters:
        T - If requested, the default-value is returned, and this is its type.
        Returns:
        Can return either the user-provided default-value, or null depending on whether a match was found in the user's request settings ('FLAGS').
        Throws:
        JsonNullObjException - If no flag was set specifying one of the two return-value options.
        See Also:
        JFlag.RETURN_NULL_ON_NULL, JFlag.RETURN_DEFVAL_ON_NULL, JFlag.RETURN_NULL_ON_ANY_ALL, JFlag.RETURN_DEFVAL_ON_ANY_ALL
        Code:
        Exact Method Body:
         if ((FLAGS & RETURN_NULL_ON_NULL) != 0)         return null;
         if ((FLAGS & RETURN_DEFVAL_ON_NULL) != 0)       return defaultValue;
         if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
         if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
        
         throw new JsonNullObjException(jo, propertyName, expectedType, returnClass);
        
      • JTAEX

        🡅  🡇    
        protected static <T> T JTAEX​(JsonArray ja,
                                     int index,
                                     T defaultValue,
                                     int FLAGS,
                                     JsonValue.ValueType expectedType,
                                     JsonValue retrievedValue,
                                     java.lang.Class<T> returnClass)
        Flag Checker for JsonTypeArrException

        Checks whether the relevant flags were set in the users FLAGS parameter, and either returns the appropriate value accordingly, or throws JsonTypeArrException.
        Type Parameters:
        T - If requested, the default-value is returned, and this is its type.
        Returns:
        Can return either the user-provided default-value, or null depending on whether a match was found in the user's request settings ('FLAGS').
        Throws:
        JsonTypeArrException - If no flag was set specifying one of the two return-value options.
        See Also:
        JFlag.RETURN_NULL_ON_WRONG_JSONTYPE, JFlag.RETURN_DEFVAL_ON_WRONG_JSONTYPE, JFlag.RETURN_NULL_ON_ANY_ALL, JFlag.RETURN_DEFVAL_ON_ANY_ALL
        Code:
        Exact Method Body:
         if ((FLAGS & RETURN_NULL_ON_WRONG_JSONTYPE) != 0)   return null;
         if ((FLAGS & RETURN_DEFVAL_ON_WRONG_JSONTYPE) != 0) return defaultValue;
         if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)          return null;
         if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)        return defaultValue;
        
         throw new JsonTypeArrException(ja, index, expectedType, retrievedValue, returnClass);
        
      • JTOEX

        🡅  🡇    
        protected static <T> T JTOEX​(JsonObject jo,
                                     java.lang.String propertyName,
                                     T defaultValue,
                                     int FLAGS,
                                     JsonValue.ValueType expectedType,
                                     JsonValue retrievedValue,
                                     java.lang.Class<T> returnClass)
        Flag Checker for JsonTypeObjException

        Checks whether the relevant flags were set in the users FLAGS parameter, and either returns the appropriate value accordingly, or throws JsonNullObjException.
        Type Parameters:
        T - If requested, the default-value is returned, and this is its type.
        Returns:
        Can return either the user-provided default-value, or null depending on whether a match was found in the user's request settings ('FLAGS').
        Throws:
        JsonNullObjException - If no flag was set specifying one of the two return-value options.
        See Also:
        JFlag.RETURN_NULL_ON_WRONG_JSONTYPE, JFlag.RETURN_DEFVAL_ON_WRONG_JSONTYPE, JFlag.RETURN_NULL_ON_ANY_ALL, JFlag.RETURN_DEFVAL_ON_ANY_ALL
        Code:
        Exact Method Body:
         if ((FLAGS & RETURN_NULL_ON_WRONG_JSONTYPE) != 0)   return null;
         if ((FLAGS & RETURN_DEFVAL_ON_WRONG_JSONTYPE) != 0) return defaultValue;
         if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)          return null;
         if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)        return defaultValue;
        
         throw new JsonTypeObjException
             (jo, propertyName, expectedType, retrievedValue, returnClass);
        
      • JSPAEX

        🡅  🡇    
        protected static <T> T JSPAEX​(java.lang.Exception e,
                                      JsonArray ja,
                                      int index,
                                      T defaultValue,
                                      int FLAGS,
                                      JsonValue retrievedValue,
                                      java.lang.Class<T> returnClass)
        Flag Checker for JsonStrParseArrException

        Checks whether the relevant flags were set in the users FLAGS parameter, and either returns the appropriate value accordingly, or throws JsonStrParseArrException.
        Type Parameters:
        T - If requested, the default-value is returned, and this is its type.
        Returns:
        Can return either the user-provided default-value, or null depending on whether a match was found in the user's request settings ('FLAGS').
        Throws:
        JsonStrParseArrException - If no flag was set specifying one of the two return-value options.
        See Also:
        JFlag.RETURN_NULL_ON_SPEX, JFlag.RETURN_DEFVAL_ON_SPEX, JFlag.RETURN_NULL_ON_ANY_ALL, JFlag.RETURN_DEFVAL_ON_ANY_ALL
        Code:
        Exact Method Body:
         if ((FLAGS & RETURN_NULL_ON_SPEX) != 0)         return null;
         if ((FLAGS & RETURN_DEFVAL_ON_SPEX) != 0)       return defaultValue;
         if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
         if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
        
         throw new JsonStrParseArrException(e, ja, index, retrievedValue, returnClass);
        
      • JSPOEX

        🡅  🡇    
        protected static <T> T JSPOEX​(java.lang.Exception e,
                                      JsonObject jo,
                                      java.lang.String propertyName,
                                      T defaultValue,
                                      int FLAGS,
                                      JsonValue retrievedValue,
                                      java.lang.Class<T> returnClass)
        Flag Checker for JsonStrParseObjException

        Checks whether the relevant flags were set in the users FLAGS parameter, and either returns the appropriate value accordingly, or throws JsonStrParseObjException.
        Type Parameters:
        T - If requested, the default-value is returned, and this is its type.
        Returns:
        Can return either the user-provided default-value, or null depending on whether a match was found in the user's request settings ('FLAGS').
        Throws:
        JsonStrParseObjException - If no flag was set specifying one of the two return-value options.
        See Also:
        JFlag.RETURN_NULL_ON_SPEX, JFlag.RETURN_DEFVAL_ON_SPEX, JFlag.RETURN_NULL_ON_ANY_ALL, JFlag.RETURN_DEFVAL_ON_ANY_ALL
        Code:
        Exact Method Body:
         if ((FLAGS & RETURN_NULL_ON_SPEX) != 0)         return null;
         if ((FLAGS & RETURN_DEFVAL_ON_SPEX) != 0)       return defaultValue;
         if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
         if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
        
         throw new JsonStrParseObjException(e, jo, propertyName, retrievedValue, returnClass);
        
      • GET

        🡅  🡇    
        protected static <T extends java.lang.Number> T GET​
                    (JsonArray ja,
                     int index,
                     int FLAGS,
                     T defaultValue,
                     java.lang.Class<T> returnClass,
                     java.util.function.Function<JsonNumber,​T> jsonTypeToJavaType,
                     java.util.function.Function<JsonNumber,​T> typeToType2)
        
        This is an internal helper method for retrieving an element from a JsonArray, and converting it to a Java Type.
        Parameters:
        ja - Any instance of JsonArray
        index - The array index containing the element to retrieve.
        FLAGS - The return-value / exception-throw flag constants defined in JFlag
        defaultValue - This is the 'Default Value' returned by this method, if there are any problems converting or extracting the specified number, and the appropriate flags are set.
        Returns:
        On success, this method returns the converted number.
        Throws:
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of input array 'ja' and none of these Exception-Flags are set:
        JsonArithmeticArrException - If the number converstion function throws an ArithmeticException while attempting to convert the JsonNumber into a number, and none of these Exception-Flags are set:
        JsonNullArrException - If the JsonArray element located at 'index' contains Json-Null, rather than a JsonNumber, and none of these Exception-Flags are set:
        JsonTypeArrException - If the JsonArray element located at 'index' contains a some other Json-Type rather than JsonNumber, and none of these Exception-Flags are set:
        See Also:
        ReadJSON.getINTEGER(JsonArray, int, int, int), ReadJSON.getLONG(JsonArray, int, int, long), ReadJSON.getSHORT(JsonArray, int, int, short), ReadJSON.getBYTE(JsonArray, int, int, byte), ReadJSON.getDOUBLE(JsonArray, int, int, double), ReadJSON.getFLOAT(JsonArray, int, int, float), ReadJSON.getNUMBER(JsonArray, int, int, Number)
        Code:
        Exact Method Body:
         // When TRUE, the index provided turned out to be outside of the bounds of the array.  The
         // IndexOutOfBounds "handler" (the method called here) will check the FLAGS, and:
         //
         //  1) return the defaultValue (if Requested by 'FLAGS' for IOOBEX)
         //  2) return null (if Requested by 'FLAGS' for IOOBEX)
         //  3) throw IndexOutOfBoundsException
         //
         // NOTE: It is probably a "little less efficient" to turn this into a method call,
         //       since there are all these parameters that have to be passed, but this is
         //       trading "readability" (less head-aches) in exchange for efficiency.
         //
         // This point applies to all of the "Exception Flag Handlers" used here
        
         if (index >= ja.size()) return IOOBEX(ja, index, defaultValue, FLAGS);
        
         JsonValue jv = ja.get(index);
        
         switch (jv.getValueType())
         {
             // When a 'NULL' (Json-Null) JsonValue is present, the JsonNullArrException 'handler'
             // will do one of the following:
             //
             //  1) return the defaultValue (if Requested by 'FLAGS' for JNAEX)
             //  2) return null (if Requested by 'FLAGS' for JNAEX)
             //  3) throw JsonNullArrException
        
             case NULL: return JNAEX(ja, index, defaultValue, FLAGS, NUMBER, returnClass);
        
             case NUMBER:
        
                 // Temp Variable, Used Twice (Just a Cast)
                 JsonNumber n = (JsonNumber) jv;
        
                 try
                     { return jsonTypeToJavaType.apply(n); }
        
                 // Because
                 //
                 // 1) A method for this code would only be invoked here, and...
                 // 2) And because there would be 9 parameters to pass, 
                 // 3) the 'inline' version of "Flag Handler" is left here!
                 //
                 // NOTE: All four "JsonArithmetic Arr/Obj Exception" exception throws
                 //       are different for each of the 4 methods where they are used.
        
                 catch (ArithmeticException ae)
                 {
                     if ((FLAGS & RETURN_NULL_ON_AEX) != 0)          return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_AEX) != 0)        return defaultValue;
                     if ((FLAGS & RETURN_JAPPROX_ON_AEX) != 0)       return typeToType2.apply(n);
                     if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
                    
                     throw new JsonArithmeticArrException
                         (ae, ja, index, NUMBER, jv, returnClass);
                 }
        
             // The JsonValue at the specified array-index does not contain an JsonNumber.
             // The "JsonTypeArrException Handler" will do one of these:
             //
             //  1) return the defaultValue (if Requested by 'FLAGS' for JTAEX)
             //  2) return null (if Requested by 'FLAGS' for JTAEX)
             //  3) throw JsonTypeArrException
        
             default: return JTAEX(ja, index, defaultValue, FLAGS, NUMBER, jv, returnClass);
         }
        
      • GET

        🡅  🡇    
        protected static <T extends java.lang.Number> T GET​
                    (JsonObject jo,
                     java.lang.String propertyName,
                     int FLAGS,
                     T defaultValue,
                     java.lang.Class<T> returnClass,
                     java.util.function.Function<JsonNumber,​T> jsonTypeToJavaType,
                     java.util.function.Function<JsonNumber,​T> typeToType2)
        
        This is an internal helper method for retrieving a property from a JsonObject, and converting it to a Java Type.
        Parameters:
        jo - Any instance of JsonObject
        propertyName - The name of the property in 'jo' to retrieve.
        FLAGS - The return-value / exception-throw flag constants defined in JFlag
        defaultValue - This is the 'Default Value' returned by this method, if there are any problems converting or extracting the specified number, and the appropriate flags are set
        Returns:
        On success, this method returns the converted number
        Throws:
        JsonPropMissingException - If 'jo' does not have a property with the name 'propertyName' and none of these Exception-Flags are set:
        JsonArithmeticObjException - If the number converstion function throws an ArithmeticException while attempting to convert the JsonNumber into a number, and none of these Exception-Flags are set:
        JsonNullObjException - If the JsonObject property specified by 'propertyName' contains Json-Null, rather than a JsonNumber, and none of these Exception-Flags are set:
        JsonTypeObjException - If the JsonObject property specified by 'propertyName' contains a some other Json-Type rather than JsonNumber, and none of these Exception-Flags are set:
        See Also:
        ReadJSON.getINTEGER(JsonObject, String, int, int), ReadJSON.getLONG(JsonObject, String, int, long), ReadJSON.getSHORT(JsonObject, String, int, short), ReadJSON.getBYTE(JsonObject, String, int, byte), ReadJSON.getDOUBLE(JsonObject, String, int, double), ReadJSON.getFLOAT(JsonObject, String, int, float), ReadJSON.getNUMBER(JsonObject, String, int, Number)
        Code:
        Exact Method Body:
         JsonValue jv = jo.get(propertyName);
        
         // When TRUE, the user-specified 'property' (named by 'propertyName') isn't actually one
         // of the listed properties inside the JsonObject.  The JsonPropMissingException "handler"
         // (the method called here) will check the FLAGS, and:
         //
         //  1) return the defaultValue (if Requested by 'FLAGS' for JPMEX)
         //  2) return null (if Requested by 'FLAGS' for JPMEX)
         //  3) throw JsonPropMissingException
         //
         // NOTE: It is probably a "little less efficient" to turn this into a method call,
         //       since there are all these parameters that have to be passed, but this is
         //       trading "readability" (less head-aches) in exchange for efficiency.
         //
         // This point applies to all of the "Exception Flag Handlers" used here
        
         if (jv == null) return JPMEX(jo, propertyName, defaultValue, FLAGS, NUMBER, returnClass);
        
         switch (jv.getValueType())
         {
             // When a 'NULL' (Json-Null) JsonValue is present, the JsonNullObjException 'handler'
             // will do one of the following:
             //
             //  1) return the defaultValue (if Requested by 'FLAGS' for JNOEX)
             //  2) return null (if Requested by 'FLAGS' for JNOEX)
             //  3) throw JsonNullArrException
        
             case NULL: return JNOEX(jo, propertyName, defaultValue, FLAGS, NUMBER, returnClass);
        
             case NUMBER:
        
                 // Temp Variable, Used Twice (Just a Cast)
                 JsonNumber n = (JsonNumber) jv;
        
                 try
                     { return jsonTypeToJavaType.apply(n); }
        
                 // Because
                 //
                 // 1) A method for this code would only be invoked here, and...
                 // 2) And because there would be 9 parameters to pass, 
                 // 3) the 'inline' version of "Flag Handler" is left here!
                 //
                 // NOTE: All four "JsonArithmetic Arr/Obj Exception" exception throws
                 //       are different for each of the 4 methods where they are used.
        
                 catch (ArithmeticException ae)
                 {
                     if ((FLAGS & RETURN_NULL_ON_AEX) != 0)          return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_AEX) != 0)        return defaultValue;
                     if ((FLAGS & RETURN_JAPPROX_ON_AEX) != 0)       return typeToType2.apply(n);
                     if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
        
                     throw new JsonArithmeticObjException
                         (ae, jo, propertyName, NUMBER, jv, returnClass);
                 }
        
             // The JsonValue of 'propertyName' does not contain an JsonNumber.
             // The "JsonTypeObjException Handler" will do one of these:
             //
             //  1) return the defaultValue (if Requested by 'FLAGS' for JTOEX)
             //  2) return null (if Requested by 'FLAGS' for JTOEX)
             //  3) throw JsonTypeObjException
        
             default: return JTOEX(jo, propertyName, defaultValue, FLAGS, NUMBER, jv, returnClass);
         }
        
      • PARSE

        🡅  🡇    
        protected static <T extends java.lang.Number> T PARSE​
                    (JsonArray ja,
                     int index,
                     int FLAGS,
                     T defaultValue,
                     java.lang.Class<T> returnClass,
                     java.util.function.Function<java.lang.String,​T> parser,
                     java.util.function.Function<java.math.BigDecimal,​T> defaultParser1,
                     java.util.function.Function<java.math.BigDecimal,​T> defaultParser2)
        
        Retrieve a JsonArray element containing a JsonString, and transform it to a Java Type, with either a user-provided parser, or the standard java parser for that class (passed as a parameter).
        Type Parameters:
        T - The type of the returned value
        Parameters:
        ja - Any instance of JsonArray
        index - array-index containing the JsonString to retrieve.
        FLAGS - The return-value / exception-throw flag constants defined in JFlag
        defaultValue - User-provided default-value, only returned if flags are set.
        parser - A valid String -> 'T' parser. This parameter may be null.
        defaultParser1 - Default String -> 'T' parser.
        defaultParser2 - String -> 'T' parser, that will round on Arithmetic Exceptions
        Returns:
        On success, this method returns the converted type.
        Throws:
        JsonPropMissingException - 'jo' doesn't have 'propertyName', unless flags are set.
        JsonArithmeticArrException - after parse, conversion fails, and flags aren't set
        JsonStrParseArrException - parser-failure unless flags are set
        JsonNullArrException - property contains null, unless flags are set
        JsonTypeArrException - property doesn't contain JsonString, unless flags are set.
        See Also:
        ReadJSON.parseINTEGER(JsonArray, int, int, int, Function), ReadJSON.parseLONG(JsonArray, int, int, long, Function), ReadJSON.parseSHORT(JsonArray, int, int, short, Function), ReadJSON.parseBYTE(JsonArray, int, int, byte, Function), ReadJSON.parseDOUBLE(JsonArray, int, int, double, Function), ReadJSON.parseFLOAT(JsonArray, int, int, float, Function), ReadJSON.parseNUMBER(JsonArray, int, int, Number, Function)
        Code:
        Exact Method Body:
         // When TRUE, the index provided turned out to be outside of the bounds of the array.  The
         // IndexOutOfBounds "handler" (the method called here) will check the FLAGS, and:
         //
         //  1) return the defaultValue (if Requested by 'FLAGS' for IOOBEX)
         //  2) return null (if Requested by 'FLAGS' for IOOBEX)
         //  3) throw IndexOutOfBoundsException
         //
         // NOTE: It is probably a "little less efficient" to turn this into a method call,
         //       since there are all these parameters that have to be passed, but this is
         //       trading "readability" (less head-aches) in exchange for efficiency.
         //
         // This point applies to all of the "Exception Flag Handlers" used here
        
         if (index >= ja.size()) return IOOBEX(ja, index, defaultValue, FLAGS);
        
         JsonValue jv = ja.get(index);
        
         switch (jv.getValueType())
         {
             // When a 'NULL' (Json-Null) JsonValue is present, the JsonNullArrException 'handler'
             // will do one of the following:
             //
             //  1) return the defaultValue (if Requested by 'FLAGS' for JNAEX)
             //  2) return null (if Requested by 'FLAGS' for JNAEX)
             //  3) throw JsonNullArrException
        
             case NULL: return JNAEX(ja, index, defaultValue, FLAGS, STRING, returnClass);
        
             case STRING:
        
                 String s = ((JsonString) jv).getString();
        
                 // NOTE: This isn't actually an "Exception Case", and if the user hasn't made
                 //       a request, the empty-string is passed to whatever parser is configured
        
                 if (s.length() == 0)
                 {
                     if ((FLAGS & RETURN_NULL_ON_0LEN_STR) != 0)     return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_0LEN_STR) != 0)   return defaultValue;
                     if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
                 }
        
                 // Temp Variable, used in order not to invoke the BigDecimal contructor twice
                 BigDecimal bd = null;
        
                 try
                 {
                     return (parser != null)
                         ? parser.apply(s)
                         : defaultParser1.apply(bd = new BigDecimal(s.trim()));
        
                         // NOTE: 'bd' will not be null if "ArithmeticException" is thrown...
                         // new BigDecimal throws "NumberFormatException" is thrown
                         // parser.applly can throw ArithmeticException
                 }
        
                 // Because
                 //
                 // 1) A method for this code would only be invoked here, and...
                 // 2) And because there would be 9 parameters to pass, 
                 // 3) the 'inline' version of "Flag Handler" is left here!
                 //
                 // NOTE: All four "JsonArithmetic Arr/Obj Exception" exception throws
                 //       are different for each of the 4 methods where they are used.
        
                 catch (ArithmeticException ae)
                 {
                     if ((FLAGS & RETURN_NULL_ON_AEX) != 0)          return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_AEX) != 0)        return defaultValue;
                     if ((FLAGS & RETURN_JAPPROX_ON_AEX) != 0)       return defaultParser2.apply(bd);
                     if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
        
                     throw new JsonArithmeticArrException(ae, ja, index, STRING, jv, returnClass);
                 }
        
                 // HANDLER STRIKES AGAIN! - but this time for "JsonStrParseArrException"
                 // RETURNS: null, or defaultValue, (otherwise throws JsonStrParseArrException)
        
                 catch (Exception e)
                     { return JSPAEX(e, ja, index, defaultValue, FLAGS, jv, returnClass); }
        
             // The JsonValue at the specified array-index does not contain an JsonString.
             // The "JsonTypeArrException Handler" will do one of these:
             //
             //  1) return the defaultValue (if Requested by 'FLAGS' for JTAEX)
             //  2) return null (if Requested by 'FLAGS' for JTAEX)
             //  3) throw JsonTypeArrException
        
             default: return JTAEX(ja, index, defaultValue, FLAGS, STRING, jv, returnClass);
         }
        
      • PARSE

        🡅    
        protected static <T extends java.lang.Number> T PARSE​
                    (JsonObject jo,
                     java.lang.String propertyName,
                     int FLAGS,
                     T defaultValue,
                     java.lang.Class<T> returnClass,
                     java.util.function.Function<java.lang.String,​T> parser,
                     java.util.function.Function<java.math.BigDecimal,​T> defaultParser1,
                     java.util.function.Function<java.math.BigDecimal,​T> defaultParser2)
        
        Retrieve a JsonObject property containing a JsonString, and transform it to a Java Type, with either a user-provided parser, or the standard java parser for that class (passed as a parameter).
        Type Parameters:
        T - The type of the returned value.
        Parameters:
        jo - Any instance of JsonObject
        propertyName - propertyName containing the JsonString to retrieve.
        FLAGS - The return-value / exception-throw flag constants defined in JFlag
        defaultValue - User-provided default-value, only returned if flags are set.
        parser - A valid String -> 'T' parser. This parameter may be null.
        defaultParser1 - Default String -> 'T' parser.
        defaultParser2 - String -> 'T' parser, that will round on Arithmetic Exceptions
        Returns:
        On success, this method returns the converted type instance.
        Throws:
        JsonPropMissingException - 'jo' doesn't have 'propertyName', unless flags are set.
        JsonArithmeticObjException - after parse, conversion fails, and flags aren't set
        JsonStrParseObjException - parser-failure unless flags are set
        JsonNullObjException - property contains null, unless flags are set
        JsonTypeObjException - property doesn't contain JsonString, unless flags are set.
        See Also:
        ReadJSON.parseINTEGER(JsonObject, String, int, int, Function), ReadJSON.parseLONG(JsonObject, String, int, long, Function), ReadJSON.parseSHORT(JsonObject, String, int, short, Function), ReadJSON.parseBYTE(JsonObject, String, int, byte, Function), ReadJSON.parseDOUBLE(JsonObject, String, int, double, Function), ReadJSON.parseFLOAT(JsonObject, String, int, float, Function), ReadJSON.parseNUMBER(JsonObject, String, int, Number, Function)
        Code:
        Exact Method Body:
         JsonValue jv = jo.get(propertyName);
        
         // When TRUE, the user-specified 'property' (named by 'propertyName') isn't actually one
         // of the listed properties inside the JsonObject.  The JsonPropMissingException "handler"
         // (the method called here) will check the FLAGS, and:
         //
         //  1) return the defaultValue (if Requested by 'FLAGS' for JPMEX)
         //  2) return null (if Requested by 'FLAGS' for JPMEX)
         //  3) throw JsonPropMissingException
         //
         // NOTE: It is probably a "little less efficient" to turn this into a method call,
         //       since there are all these parameters that have to be passed, but this is
         //       trading "readability" (less head-aches) in exchange for efficiency.
         //
         // This point applies to all of the "Exception Flag Handlers" used here
        
         if (jv == null) return JPMEX(jo, propertyName, defaultValue, FLAGS, STRING, returnClass);
        
         switch (jv.getValueType())
         {
             // When a 'NULL' (Json-Null) JsonValue is present, the JsonNullObjException 'handler'
             // will do one of the following:
             //
             //  1) return the defaultValue (if Requested by 'FLAGS' for JNOEX)
             //  2) return null (if Requested by 'FLAGS' for JNOEX)
             //  3) throw JsonNullArrException
        
             case NULL: return JNOEX(jo, propertyName, defaultValue, FLAGS, STRING, returnClass);
        
             case STRING:
        
                 String s = ((JsonString) jv).getString();
        
                 // NOTE: This isn't actually an "Exception Case", and if the user hasn't made
                 //       a request, the empty-string is passed to whatever parser is configured
        
                 if (s.length() == 0)
                 {
                     if ((FLAGS & RETURN_NULL_ON_0LEN_STR) != 0)     return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_0LEN_STR) != 0)   return defaultValue;
                     if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
                 }
        
                 // Temp Variable, used in order not to invoke the BigDecimal contructor twice
                 BigDecimal bd = null;
        
                 try
                 {
                     return (parser != null)
                         ? parser.apply(s)
                         : defaultParser1.apply(bd = new BigDecimal(s.trim()));
        
                         // NOTE: 'bd' will not be null if "ArithmeticException" is thrown...
                         // new BigDecimal throws "NumberFormatException" is thrown
                         // parser.applly can throw ArithmeticException
                 }
        
                 // Because
                 //
                 // 1) A method for this code would only be invoked here, and...
                 // 2) And because there would be 9 parameters to pass, 
                 // 3) the 'inline' version of "Flag Handler" is left here!
                 //
                 // NOTE: All four "JsonArithmetic Arr/Obj Exception" exception throws
                 //       are different for each of the 4 methods where they are used.
        
                 catch (ArithmeticException ae)
                 {
                     if ((FLAGS & RETURN_NULL_ON_AEX) != 0)          return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_AEX) != 0)        return defaultValue;
                     if ((FLAGS & RETURN_JAPPROX_ON_AEX) != 0)      return defaultParser2.apply(bd);
                     if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0)      return null;
                     if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0)    return defaultValue;
        
                     throw new JsonArithmeticObjException
                         (ae, jo, propertyName, STRING, jv, returnClass);
                 }
        
                 // HANDLER STRIKES AGAIN! - but this time for "JsonStrParseObjException"
                 // RETURNS: null, or defaultValue, (otherwise throws JsonStrParseObjException)
        
                 catch (Exception e)
                     { return JSPOEX(e, jo, propertyName, defaultValue, FLAGS, jv, returnClass); }
        
             // The JsonValue of 'propertyName' does not contain an JsonString.
             // The "JsonTypeObjException Handler" will do one of these:
             //
             //  1) return the defaultValue (if Requested by 'FLAGS' for JTOEX)
             //  2) return null (if Requested by 'FLAGS' for JTOEX)
             //  3) throw JsonTypeObjException
        
             default: return JTOEX(jo, propertyName, defaultValue, FLAGS, STRING, jv, returnClass);
         }