Package Torello.JSON
Class ReadBoxedJSON
- java.lang.Object
-
- Torello.JSON.ReadBoxedJSON
-
public class ReadBoxedJSON extends java.lang.Object
Builds on the J2EE Standard Release JSON Parsing Tools by providing additional help with converting JSON Data into Java Boxed-Primitive Types
This class builds on the J2EE Standard 'Glass-Fish' JSON Processor
There are several JSON Parsers available, and even more implementations for serializing and de-serializing data to/from JSON. The Glass Fish Tool is included in the J2EE, and is available on GitHub. That is the one used by the Java HTML JAR Library (See:javax.json.*)
Primary Classes Used:JsonArrayandJsonObject
This comment-note is intentionally repeated, verbatim, at the top of all Json Reader Classes in this package.
JSON to Java Binding:
JSON-Binding is the art of converting data that has been stored, saved or transmitted usingJava-Script Object Notationinto a Java Primitive or Object-Type.JSONcan arrive into Java-Program Memory from almost any source. If you are wondering why such a massive amount of "work" is necessary just to convert a Json Integer into Java Integer, the value added is the extraordinary amount of attention paid to user configuration, error checking, & exception messaging. Methods here don't require more than 1 or 2 lines of code, and guarantee that a thorough type checking is performed.
Unlike Java-Types which are checked by the Java-Compiler each-and-every time a programmer compiles his project, any guarantee that JSON-Type Data is pristine, uncorrupted, and in any kind of pre-agreed format may or may not be assured. The methods here are able to handle changes that might be made to an API (possibly from great distances away, and without the Software-Manager's consent). If an error could occur, configuration flags can be used to determine default error-recovery behaviors. If an exception does throw, the exception messages printed will contain multiple lines of detailed information.- Utilizes the Java-Standard
javax.json.*Package-Library, & its Glass-Fish Implementation - Handles the Transfer & Conversion of All Json-Type's into Java-Type's with just One Line of Code
- Provides all manner of User-Configurable Exception-Handling &
Error-Decision Management via Class
JFlag - Provides a Fine-Grained Suite of Exception-Classes, all with Consistent & Meaningful Error-Messages. Json Files can occasionally grow extremely large, and error messaging details make debugging easier
- Primary Helper-Classes for the (Experimental) Google-Chrome
Browser AutomationPackage
The goal ofTorello.JSONis to provide small, static helper methods in the same spirit asjava.util.Objectsandjava.util.Arrays: simple calls that keep JSON handling out of your application logic. Instead of repeating loops, type checks, null checks, and exception wiring at every call site, these methods centralize that work behind a consistent set of straight-forward “read value” operations.
Reads a single Json value from a Json Array or Object and returns a boxed primitive
For seven out of the eight Java Primitive Types, this class provides four methods for extracting Json-Values, and converting them into Java's "Boxed" types. "Boxed Types" are extremely easy to understand, and are just basic Java Primitive values - such asint, booleanordoublethat have been converted into a reference, and can be treated the same way that all reference values are treated and used in Java.
Java's auto-boxing and un-boxing means that this process is extremely efficient, and owing to how the compiler has implemented boxed-primitives, there is next to no efficiency loss when using boxed primitives, rather than ordinary primitives.
-
Boxed primitives (such as
java.lang.Integerandjava.lang.Boolean) are reference types and may therefore hold the valuenull. -
Boxed primitives may be used with Java generics and collections
(for example,
List<Integer>), whereas primitive types (such asint) may not. - Java supports automatic boxing and unboxing, allowing the compiler to transparently convert between a boxed value and its corresponding primitive value when required.
UnlikeParseBoxedJSON, which operates on textualJsonStringvalues, this class is intended for scenarios where numeric or boolean JSON values are already represented using native JSON types such asJsonNumberorJsonValue.TRUE. This distinction allows callers to choose the most direct and semantically appropriate conversion path based on how the source JSON data is structured, without forcing all values through an intermediate string representation.
As with the other JSON reader classes in this package, each method operates on a single, explicitly addressed JSON value, either by array index or object property name. This design keeps data access predictable and makes it easier for calling code to distinguish between missing values, type mismatches, and valid conversions when integrating JSON input into strongly typed Java logic.
Method Parameters
Parameter Explanation jaA JsonArraywhose element (atindex) is being converted into a Java Boxed-Primitive value.
For the numeric methods, the array-element is expected to be aJsonNumber. For the boolean methods, the array-element is expected to beJsonValue.TRUEorJsonValue.FALSE.
If the element isJsonValue.NULL, these methods may return Javanull(depending on the specific overload and/or flags).indexThe zero-based array index of the element being read from ja.
When using a “no-flags” method, an out-of-boundsindexwill throw the normal Java exception.
When using aFLAGS-overload, the flags may allow returning Java-nullor adefaultValuerather than throwing.joA JsonObjectwhose property value (namedpropertyName) is being converted into a Java Boxed-Primitive value.
For the numeric methods, the property is expected to be aJsonNumber. For boolean methods, the property is expected to beJsonValue.TRUEorJsonValue.FALSE.
If the property exists but containsJsonValue.NULL, these methods may return Javanull(depending on the specific overload and/or flags).propertyNameThe name of the JsonObjectproperty to retrieve fromjo.
If the property is not present and you are using a “no-flags” overload, behavior is controlled byisOptional.
If the property is not present and you are using aFLAGSoverload, the flags may allow returning Java-nullor adefaultValue.isOptionalUsed by the “no-flags” JsonObjectmethod overloads.
Whentrueandjodoes not containpropertyName, the method returns Java-null.
Whenfalseand the property is missing, an exception is thrown.
Note: this parameter is about the property missing case. If the property exists but isJsonValue.NULL, the methods may still return Javanull(the classes intentionally allow null-returns).FLAGSA bit-mask of JFlagconstants that alters failure/edge-case behavior.
WhenFLAGSis0, the “normal” behavior applies (exceptions are thrown for missing property, wrong JSON type, arithmetic conversion failures, out-of-bounds index, etc.).
When one or more flags are supplied, certain problems may be handled by returning Java-nullor returningdefaultValueinstead of throwing.See the “Default-Value Flags” / “Flags Master List” documentation for the authoritative per-flag meaning in classJFlagdefaultValueA Java <PRIMITIVE>fallback value that may be returned by theFLAGS-method overloads.
If the selected flags request a “default-value return” for some failure/edge-case (missing property, null, wrong type, parse/arithmetic error, out-of-bounds, etc.), this is the value that will be returned.Note that the return type of the public methods is the corresponding Boxed Type (example:java.lang.Integer). The type ofdefaultValueis the matching primitive type. Java's "Auto-Boxing" and "Auto Un-Boxing" makes this easy.
Single Character:
Note that this class simply doesn't support any methods for reading ajava.lang.Character. This is because their are just entirely too many possibilities, combinations & options for the appropriate "Default Behavior" when attempting to read a single character of data from any random JSON Data-Type.
Remember that the JSON Specification does not posses any "Single-JSON-Character" Data-Type. Creating some kind of Flag-Controlled Reader for a'char'that can capably decide what to do would be so overtly verbose, for something so simple, that it isn't worth the effort...- See Also:
JsonObject,JsonArray
Hi-Lited Source-Code:- View Here: Torello/JSON/ReadBoxedJSON.java
- Open New Browser-Tab: Torello/JSON/ReadBoxedJSON.java
File Size: 41,681 Bytes Line Count: 1,049 '\n' Characters Found
Stateless Class:This class neither contains any program-state, nor can it be instantiated. The@StaticFunctionalAnnotation may also be called 'The Spaghetti Report'.Static-Functionalclasses are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's@StatelessAnnotation.
- 1 Constructor(s), 1 declared private, zero-argument constructor
- 32 Method(s), 32 declared static
- 0 Field(s)
- Utilizes the Java-Standard
-
-
Method Summary
No Control Flags: Retrieve a JsonNumberfrom aJsonArrayand Transform it to a Java Boxed Numeric TypeModifier and Type Method static BytegetByte(JsonArray ja, int index)static DoublegetDouble(JsonArray ja, int index)static FloatgetFloat(JsonArray ja, int index)static IntegergetInteger(JsonArray ja, int index)static LonggetLong(JsonArray ja, int index)static ShortgetShort(JsonArray ja, int index)No Control Flags: Retrieve a JsonNumberfrom aJsonObjectand Transform it to a Java Boxed Numeric TypeModifier and Type Method static BytegetByte(JsonObject jo, String propertyName, boolean isOptional)static DoublegetDouble(JsonObject jo, String propertyName, boolean isOptional)static FloatgetFloat(JsonObject jo, String propertyName, boolean isOptional)static IntegergetInteger(JsonObject jo, String propertyName, boolean isOptional)static LonggetLong(JsonObject jo, String propertyName, boolean isOptional)static ShortgetShort(JsonObject jo, String propertyName, boolean isOptional)Using Error Control Flags: Retrieve a JsonNumberfrom aJsonArrayand Transform it to a Java Boxed Numeric TypeModifier and Type Method static BytegetByte(JsonArray ja, int index, int FLAGS, byte defaultValue)static DoublegetDouble(JsonArray ja, int index, int FLAGS, double defaultValue)static FloatgetFloat(JsonArray ja, int index, int FLAGS, float defaultValue)static IntegergetInteger(JsonArray ja, int index, int FLAGS, int defaultValue)static LonggetLong(JsonArray ja, int index, int FLAGS, long defaultValue)static ShortgetShort(JsonArray ja, int index, int FLAGS, short defaultValue)Using Error Control Flags: Retrieve a JsonNumberfrom aJsonObjectand Transform it to a Java Boxed Numeric TypeModifier and Type Method static BytegetByte(JsonObject jo, String propertyName, int FLAGS, byte defaultValue)static DoublegetDouble(JsonObject jo, String propertyName, int FLAGS, double defaultValue)static FloatgetFloat(JsonObject jo, String propertyName, int FLAGS, float defaultValue)static IntegergetInteger(JsonObject jo, String propertyName, int FLAGS, int defaultValue)static LonggetLong(JsonObject jo, String propertyName, int FLAGS, long defaultValue)static ShortgetShort(JsonObject jo, String propertyName, int FLAGS, short defaultValue)Boxed-Boolean Methods: Retrieve JsonValue.TRUEorFALSEand Transform it to a Java Boxed-BooleanModifier and Type Method static BooleangetBoolean(JsonArray ja, int index)static BooleangetBoolean(JsonArray ja, int index, int FLAGS, boolean defaultValue)static BooleangetBoolean(JsonObject jo, String propertyName, boolean isOptional)static BooleangetBoolean(JsonObject jo, String propertyName, int FLAGS, boolean defaultValue)Internal Use Only, Protected: General Purpose Parse Methods Modifier and Type Method protected static <T extends Number>
TGET(JsonArray ja, int index, int FLAGS, T defaultValue, Class<T> returnClass, Function<JsonNumber,T> jsonTypeToJavaType, Function<JsonNumber,T> typeToType2)protected static <T extends Number>
TGET(JsonObject jo, String propertyName, int FLAGS, T defaultValue, Class<T> returnClass, Function<JsonNumber,T> jsonTypeToJavaType, Function<JsonNumber,T> typeToType2)protected static <T extends Number>
TGET_NO_FLAGS(JsonArray ja, int index, Function<JsonNumber,T> jsonTypeToJavaType, Class<T> returnClass)protected static <T extends Number>
TGET_NO_FLAGS(JsonObject jo, String propertyName, boolean isOptional, Function<JsonNumber,T> jsonTypeToJavaType, Class<T> returnClass)
-
-
-
Method Detail
-
getInteger
public static java.lang.Integer getInteger(JsonArray ja, int index)
Retrieve a JsonArray element, and transform it to a Java Boxed IntegerAccepts: a JsonArray, along with an array index.Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Integer ( java.lang.Integer)- See Also:
GET_NO_FLAGS(JsonArray, int, Function, Class),JsonNumber.intValueExact()- Code:
- Exact Method Body:
return GET_NO_FLAGS(ja, index, JsonNumber::intValueExact, Integer.class);
-
getLong
public static java.lang.Long getLong(JsonArray ja, int index)
Retrieve a JsonArray element, and transform it to a Boxed Long IntegerAccepts: a JsonArray, along with an array index.Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Long ( java.lang.Long)- See Also:
GET_NO_FLAGS(JsonArray, int, Function, Class),JsonNumber.longValueExact()- Code:
- Exact Method Body:
return GET_NO_FLAGS(ja, index, JsonNumber::longValueExact, Long.class);
-
getShort
public static java.lang.Short getShort(JsonArray ja, int index)
Retrieve a JsonArray element, and transform it to a Boxed Short IntegerAccepts: a JsonArray, along with an array index.Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Long ( java.lang.Long)- See Also:
GET_NO_FLAGS(JsonArray, int, Function, Class),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET_NO_FLAGS(ja, index, jn -> jn.bigDecimalValue().shortValueExact(), Short.class);
-
getByte
public static java.lang.Byte getByte(JsonArray ja, int index)
Retrieve a JsonArray element, and transform it to a Java Boxed ByteAccepts: a JsonArray, along with an array index.Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Byte ( java.lang.Byte)- See Also:
GET_NO_FLAGS(JsonArray, int, Function, Class),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET_NO_FLAGS(ja, index, jn -> jn.bigDecimalValue().byteValueExact(), Byte.class);
-
getDouble
public static java.lang.Double getDouble(JsonArray ja, int index)
Retrieve a JsonArray element, and transform it to a Java Boxed DoubleAccepts: a JsonArray, along with an array index.Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Double ( java.lang.Double)- See Also:
GET_NO_FLAGS(JsonArray, int, Function, Class),RJInternal.DOUBLE_WITH_CHECK(JsonNumber)- Code:
- Exact Method Body:
return GET_NO_FLAGS(ja, index, RJInternal::DOUBLE_WITH_CHECK, Double.class);
-
getFloat
public static java.lang.Float getFloat(JsonArray ja, int index)
Retrieve a JsonArray element, and transform it to a Java Boxed FloatAccepts: a JsonArray, along with an array index.Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Float ( java.lang.Float)- See Also:
GET_NO_FLAGS(JsonArray, int, Function, Class),RJInternal.FLOAT_WITH_CHECK(JsonNumber)- Code:
- Exact Method Body:
return GET_NO_FLAGS(ja, index, RJInternal::FLOAT_WITH_CHECK, Float.class);
-
getBoolean
public static java.lang.Boolean getBoolean(JsonArray ja, int index)
Retrieve a JsonArray element, and transform it to a Java Boxed BooleanAccepts: a JsonArray, along with an array index.Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Boolean ( java.lang.Boolean)- See Also:
JsonValue.getValueType(),JsonValue.ValueType.TRUE,JsonValue.ValueType.FALSE,JsonValue.TRUE,JsonValue.FALSE- Code:
- Exact Method Body:
final JsonValue jv = ja.get(index); switch (jv.getValueType()) { case NULL: return null; case TRUE: return true; case FALSE: return false; default: throw new JsonTypeArrException(ja, index, TRUE, jv, Boolean.class); }
-
getInteger
public static java.lang.Integer getInteger(JsonObject jo, java.lang.String propertyName, boolean isOptional)
Retrieve a JsonObject property, and transform it to a Java Boxed IntegerAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Integer ( java.lang.Integer)- See Also:
GET_NO_FLAGS(JsonObject, String, boolean, Function, Class),JsonNumber.intValueExact()- Code:
- Exact Method Body:
return GET_NO_FLAGS (jo, propertyName, isOptional, JsonNumber::intValueExact, Integer.class);
-
getLong
public static java.lang.Long getLong(JsonObject jo, java.lang.String propertyName, boolean isOptional)
Retrieve a JsonObject property, and transform it to a Boxed Long IntegerAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Long ( java.lang.Long)- See Also:
GET_NO_FLAGS(JsonObject, String, boolean, Function, Class),JsonNumber.longValueExact()- Code:
- Exact Method Body:
return GET_NO_FLAGS (jo, propertyName, isOptional, JsonNumber::longValueExact, Long.class);
-
getShort
public static java.lang.Short getShort(JsonObject jo, java.lang.String propertyName, boolean isOptional)
Retrieve a JsonObject property, and transform it to a Boxed Short IntegerAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Short ( java.lang.Short)- See Also:
GET_NO_FLAGS(JsonObject, String, boolean, Function, Class),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET_NO_FLAGS( jo, propertyName, isOptional, jn -> jn.bigDecimalValue().shortValueExact(), Short.class );
-
getByte
public static java.lang.Byte getByte(JsonObject jo, java.lang.String propertyName, boolean isOptional)
Retrieve a JsonObject property, and transform it to a Java Boxed ByteAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Byte ( java.lang.Byte)- See Also:
GET_NO_FLAGS(JsonObject, String, boolean, Function, Class),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET_NO_FLAGS( jo, propertyName, isOptional, jn -> jn.bigDecimalValue().byteValueExact(), Byte.class );
-
getDouble
public static java.lang.Double getDouble(JsonObject jo, java.lang.String propertyName, boolean isOptional)
Retrieve a JsonObject property, and transform it to a Java Boxed DoubleAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Double ( java.lang.Double)- See Also:
GET_NO_FLAGS(JsonObject, String, boolean, Function, Class),RJInternal.DOUBLE_WITH_CHECK(JsonNumber)- Code:
- Exact Method Body:
return GET_NO_FLAGS (jo, propertyName, isOptional, RJInternal::DOUBLE_WITH_CHECK, Double.class);
-
getFloat
public static java.lang.Float getFloat(JsonObject jo, java.lang.String propertyName, boolean isOptional)
Retrieve a JsonObject property, and transform it to a Java Boxed FloatAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Float ( java.lang.Float)- See Also:
GET_NO_FLAGS(JsonObject, String, boolean, Function, Class),RJInternal.FLOAT_WITH_CHECK(JsonNumber)- Code:
- Exact Method Body:
return GET_NO_FLAGS (jo, propertyName, isOptional, RJInternal::FLOAT_WITH_CHECK, Float.class);
-
getBoolean
public static java.lang.Boolean getBoolean(JsonObject jo, java.lang.String propertyName, boolean isOptional)
Retrieve a JsonObject property, and transform it to a Java Boxed BooleanAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Does not accept user configuration flags. Instead, throws all default exceptions on error. Throws: Please review documentation for GET_NO_FLAGSmethod, listed below.Returns: A Java Boxed Boolean ( java.lang.Boolean)- See Also:
JsonValue.getValueType(),JsonValue.ValueType.TRUE,JsonValue.ValueType.FALSE,JsonValue.TRUE,JsonValue.FALSE- Code:
- Exact Method Body:
if (! jo.containsKey(propertyName)) { if (isOptional) return null; throw new JsonPropMissingException(jo, propertyName, TRUE, Boolean.class); } final JsonValue jv = jo.get(propertyName); switch (jv.getValueType()) { case NULL: return null; case TRUE: return true; case FALSE: return false; default: throw new JsonTypeObjException(jo, propertyName, TRUE, jv, Boolean.class); }
-
getInteger
public static java.lang.Integer getInteger(JsonArray ja, int index, int FLAGS, int defaultValue)
Retrieve a JsonArray element, and transform it to a Java Boxed IntegerAccepts: a JsonArray, along with an array index.Flags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Integer ( java.lang.Integer)- See Also:
GET(JsonArray, int, int, Number, Class, Function, Function),JsonNumber.intValueExact(),JsonNumber.intValue()- Code:
- Exact Method Body:
return GET( ja, index, FLAGS, defaultValue, Integer.class, JsonNumber::intValueExact, JsonNumber::intValue );
-
getLong
public static java.lang.Long getLong(JsonArray ja, int index, int FLAGS, long defaultValue)
Retrieve a JsonArray element, and transform it to a Boxed Long IntegerAccepts: a JsonArray, along with an array index.Flags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Long ( java.lang.Long)- See Also:
GET(JsonArray, int, int, Number, Class, Function, Function),JsonNumber.longValueExact(),JsonNumber.longValue()- Code:
- Exact Method Body:
return GET( ja, index, FLAGS, defaultValue, Long.class, JsonNumber::longValueExact, JsonNumber::longValue );
-
getShort
public static java.lang.Short getShort(JsonArray ja, int index, int FLAGS, short defaultValue)
Retrieve a JsonArray element, and transform it to a Boxed Short IntegerAccepts: a JsonArray, along with an array index.Flags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Short ( java.lang.Short)- See Also:
GET(JsonArray, int, int, Number, Class, Function, Function),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET( ja, index, FLAGS, defaultValue, Short.class, jn -> jn.bigDecimalValue().shortValueExact(), jn -> jn.bigDecimalValue().shortValue() );
-
getByte
public static java.lang.Byte getByte(JsonArray ja, int index, int FLAGS, byte defaultValue)
Retrieve a JsonArray element, and transform it to a Java Boxed ByteAccepts: a JsonArray, along with an array index.Flags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Byte ( java.lang.Byte)- See Also:
GET(JsonArray, int, int, Number, Class, Function, Function),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET( ja, index, FLAGS, defaultValue, Byte.class, jn -> jn.bigDecimalValue().byteValueExact(), jn -> jn.bigDecimalValue().byteValue() );
-
getDouble
public static java.lang.Double getDouble(JsonArray ja, int index, int FLAGS, double defaultValue)
Retrieve a JsonArray element, and transform it to a Java Boxed DoubleAccepts: a JsonArray, along with an array index.Flags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Double ( java.lang.Double)- See Also:
GET(JsonArray, int, int, Number, Class, Function, Function),RJInternal.DOUBLE_WITH_CHECK(JsonNumber),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET( ja, index, FLAGS, defaultValue, Double.class, RJInternal::DOUBLE_WITH_CHECK, jn -> jn.bigDecimalValue().doubleValue() );
-
getFloat
public static java.lang.Float getFloat(JsonArray ja, int index, int FLAGS, float defaultValue)
Retrieve a JsonArray element, and transform it to a Java Boxed FloatAccepts: a JsonArray, along with an array index.Flags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Float ( java.lang.Float)- See Also:
GET(JsonArray, int, int, Number, Class, Function, Function),RJInternal.FLOAT_WITH_CHECK(JsonNumber),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET( ja, index, FLAGS, defaultValue, Float.class, RJInternal::FLOAT_WITH_CHECK, jn -> jn.bigDecimalValue().floatValue() );
-
getBoolean
public static java.lang.Boolean getBoolean(JsonArray ja, int index, int FLAGS, boolean defaultValue)
Retrieve a JsonArray element, and transform it to a Java Boxed BooleanAccepts: a JsonArray, along with an array index.Flags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Boolean ( java.lang.Boolean)- See Also:
JsonValue.getValueType(),JsonValue.ValueType.TRUE,JsonValue.ValueType.FALSE,JsonValue.TRUE,JsonValue.FALSE- Code:
- Exact Method Body:
if (index >= ja.size()) return IOOBEX(ja, index, defaultValue, FLAGS); final JsonValue jv = ja.get(index); // Throw an IndexOutOfBoundsException switch (jv.getValueType()) { case NULL: return JNAEX(ja, index, defaultValue, FLAGS, TRUE, Boolean.class); case TRUE: return true; case FALSE: return false; default: return JTAEX(ja, index, defaultValue, FLAGS, TRUE, jv, Boolean.class); }
-
getInteger
public static java.lang.Integer getInteger(JsonObject jo, java.lang.String propertyName, int FLAGS, int defaultValue)
Retrieve a JsonObject property, and transform it to a Java Boxed IntegerAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Integer ( java.lang.Integer)- See Also:
GET(JsonObject, String, int, Number, Class, Function, Function),JsonNumber.intValueExact(),JsonNumber.intValue()- Code:
- Exact Method Body:
return GET( jo, propertyName, FLAGS, defaultValue, Integer.class, JsonNumber::intValueExact, JsonNumber::intValue );
-
getLong
public static java.lang.Long getLong(JsonObject jo, java.lang.String propertyName, int FLAGS, long defaultValue)
Retrieve a JsonObject property, and transform it to a Boxed Long IntegerAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Long ( java.lang.Long)- See Also:
GET(JsonObject, String, int, Number, Class, Function, Function),JsonNumber.longValueExact(),JsonNumber.longValue()- Code:
- Exact Method Body:
return GET( jo, propertyName, FLAGS, defaultValue, Long.class, JsonNumber::longValueExact, JsonNumber::longValue );
-
getShort
public static java.lang.Short getShort(JsonObject jo, java.lang.String propertyName, int FLAGS, short defaultValue)
Retrieve a JsonObject property, and transform it to a Boxed Short IntegerAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Short ( java.lang.Short)- See Also:
GET(JsonObject, String, int, Number, Class, Function, Function),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET( jo, propertyName, FLAGS, defaultValue, Short.class, jn -> jn.bigDecimalValue().shortValueExact(), jn -> jn.bigDecimalValue().shortValue() );
-
getByte
public static java.lang.Byte getByte(JsonObject jo, java.lang.String propertyName, int FLAGS, byte defaultValue)
Retrieve a JsonObject property, and transform it to a Java Boxed ByteAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Byte ( java.lang.Byte)- See Also:
GET(JsonObject, String, int, Number, Class, Function, Function),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET( jo, propertyName, FLAGS, defaultValue, Byte.class, jn -> jn.bigDecimalValue().byteValueExact(), jn -> jn.bigDecimalValue().byteValue() );
-
getDouble
public static java.lang.Double getDouble(JsonObject jo, java.lang.String propertyName, int FLAGS, double defaultValue)
Retrieve a JsonObject property, and transform it to a Java Boxed DoubleAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Double ( java.lang.Double)- See Also:
GET(JsonObject, String, int, Number, Class, Function, Function),RJInternal.DOUBLE_WITH_CHECK(JsonNumber),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET( jo, propertyName, FLAGS, defaultValue, Double.class, RJInternal::DOUBLE_WITH_CHECK, jn -> jn.bigDecimalValue().doubleValue() );
-
getFloat
public static java.lang.Float getFloat(JsonObject jo, java.lang.String propertyName, int FLAGS, float defaultValue)
Retrieve a JsonObject property, and transform it to a Java Boxed FloatAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Float ( java.lang.Float)- See Also:
GET(JsonObject, String, int, Number, Class, Function, Function),RJInternal.FLOAT_WITH_CHECK(JsonNumber),JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return GET( jo, propertyName, FLAGS, defaultValue, Float.class, RJInternal::FLOAT_WITH_CHECK, jn -> jn.bigDecimalValue().floatValue() );
-
getBoolean
public static java.lang.Boolean getBoolean(JsonObject jo, java.lang.String propertyName, int FLAGS, boolean defaultValue)
Retrieve a JsonObject property, and transform it to a Java Boxed BooleanAccepts: a JsonObject, along with property name, as ajava.lang.StringFlags: Accepts Error-Control Flags; May be configured to suppress exceptions. Throws: Please review documentation for GETmethod, listed below.Returns: A Java Boxed Boolean ( java.lang.Boolean)- See Also:
JsonValue.getValueType(),JsonValue.ValueType.TRUE,JsonValue.ValueType.FALSE,JsonValue.TRUE,JsonValue.FALSE- Code:
- Exact Method Body:
final JsonValue jv = jo.get(propertyName); if (jv == null) return JPMEX(jo, propertyName, defaultValue, FLAGS, TRUE, Boolean.class); switch (jv.getValueType()) { case NULL: return JNOEX(jo, propertyName, defaultValue, FLAGS, TRUE, Boolean.class); case TRUE: return true; case FALSE: return false; default: return JTOEX(jo, propertyName, defaultValue, FLAGS, TRUE, jv, Boolean.class); }
-
GET_NO_FLAGS
protected static <T extends java.lang.Number> T GET_NO_FLAGS (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 aJsonArray, and converting it to one of the standard Java Types.- Type Parameters:
T- Numeric Boxed-Type, as an instance ofjava.lang.Class- Parameters:
ja- Any instance ofJsonArrayindex- A valid index into'ja'jsonTypeToJavaType- This should convert an instance ofJsonNumber, into one of the concrete, boxed, subclasses ofjava.lang.Number- Returns:
- The converted number, as an instance Generic-Parameter
'T' - Throws:
JsonTypeArrException- If array index specified does not contain aJsonNumberJsonArithmeticArrException- If there any arithmetic problems during the conversionjava.lang.IndexOutOfBoundsException- If'index'is out of the bounds of'ja'- See Also:
getInteger(JsonArray, int),getLong(JsonArray, int),getShort(JsonArray, int),getByte(JsonArray, int),getDouble(JsonArray, int),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. final 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_NO_FLAGS
protected static <T extends java.lang.Number> T GET_NO_FLAGS (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 aJsonObject, and converting it to one of the standard Java Types.- Type Parameters:
T- Numeric Boxed-Type, as an instance ofjava.lang.Class- Parameters:
jo- Any instance ofJsonObjectpropertyName- Any property name contained by'jo'isOptional- WhenTRUEis passed, if'propertyName'is not actually listed in'jo'this method shall return Java-Null gracefully. WhenFALSEis passed, if'jo'does not have the specified property, aJsonPropMissingExceptionwill throw.
If'jo'actually has a property named'propertyName', then the value passed to this parameter is fully irrelevant.jsonTypeToJavaType- This should convert an instance ofJsonNumber, into one of the concrete, boxed, subclasses ofjava.lang.Number- Returns:
- The converted number, as an instance of Generic-Parameter
'T' - Throws:
JsonPropMissingException- If the property is missing, and'isOptional'isFALSE.JsonTypeObjException- If the property specified does not contain aJsonNumberJsonArithmeticObjException- If there any arithmetic problems during the conversion- See Also:
getInteger(JsonObject, String, boolean),getLong(JsonObject, String, boolean),getShort(JsonObject, String, boolean),getByte(JsonObject, String, boolean),getDouble(JsonObject, String, boolean),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); } final 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); }
-
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 aJsonArray, and converting it to a Java Type.- Type Parameters:
T- Numeric Boxed-Type, as an instance ofjava.lang.Class- Parameters:
ja- Any instance ofJsonArrayindex- A valid index into'ja'FLAGS- Error-Control / Throw flag constants, defined inJFlagdefaultValue- This is the 'Default Value' returned by this method, if there are any exception or problems converting or extracting the specified number.
The default value is only returned by this method if the appropriate JSON Exception Flag has been passed to the'FLAGS'parameter! Specifically, if'FLAGS'were passed'0', then this parameter is fully-irrelevant and ignored. The exception flags are listed in inner-classJFlagsIf an exception-case is encountered, but the exception-flag for that exception has not been set, then this default-value won't be returned, and that exception will throw instead.- Returns:
- On success, this method returns the converted number (of type
'T'). - Throws:
java.lang.IndexOutOfBoundsException- If'index'is out of the bounds of input array'ja'and none of these Exception-Flags are set:RETURN_NULL_ON_IOB(Abbrev:RN_IOB)RETURN_DEFVAL_ON_IOB(Abbrev:RD_IOB)RETURN_NULL_ON_ANY_ALL(Abbrev:RN_AA)RETURN_DEFVAL_ON_ANY_ALL(Abbrev:RD_AA)
JsonArithmeticArrException- If the number converstion function throws anArithmeticExceptionwhile attempting to convert theJsonNumberinto anumber, and none of these Exception-Flags are set:RETURN_NULL_ON_AEX(Abbrev:RN_AEX)RETURN_DEFVAL_ON_AEX(Abbrev:RN_AEX)RETURN_JAPPROX_ON_AEX(Abbrev:RJA_AEX)RETURN_NULL_ON_ANY_ALL(Abbrev:RN_AA)RETURN_DEFVAL_ON_ANY_ALL(Abbrev:RD_AA)
JsonNullArrException- If theJsonArrayelement located at'index'contains Json-Null, rather than aJsonNumber, and none of these Exception-Flags are set:RETURN_NULL_ON_NULL(Abbrev:RN_N)RETURN_DEFVAL_ON_NULL(Abbrev:RD_N)RETURN_NULL_ON_ANY_ALL(Abbrev:RN_AA)RETURN_DEFVAL_ON_ANY_ALL(Abbrev:RD_AA)
JsonTypeArrException- If theJsonArrayelement located at'index'contains a some other Json-Type rather thanJsonNumber, and none of these Exception-Flags are set:RETURN_NULL_ON_WRONG_JSONTYPE(Abbrev:RN_WT)RETURN_DEFVAL_ON_WRONG_JSONTYPE(Abbrev:RD_WT)RETURN_NULL_ON_ANY_ALL(Abbrev:RN_AA)RETURN_DEFVAL_ON_ANY_ALL(Abbrev:RD_AA)
- See Also:
getInteger(JsonArray, int, int, int),getLong(JsonArray, int, int, long),getShort(JsonArray, int, int, short),getByte(JsonArray, int, int, byte),getDouble(JsonArray, int, int, double),getFloat(JsonArray, int, int, float),ReadNumberJSON.get(JsonArray, int, int, Number),RJInternal.IOOBEX(JsonArray, int, Object, int),RJInternal.JNAEX(JsonArray, int, Object, int, JsonValue.ValueType, Class),RJInternal.JTAEX(JsonArray, int, Object, int, JsonValue.ValueType, JsonValue, Class)- 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); final 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) final 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 aJsonObject, and converting it to a Java Type.- Parameters:
jo- Any instance ofJsonObjectpropertyName- Any property name contained by'jo'FLAGS- Error-Control / Throw flag constants, defined inJFlagdefaultValue- This is the 'Default Value' returned by this method, if there are any exception or problems converting or extracting the specified number.
The default value is only returned by this method if the appropriate JSON Exception Flag has been passed to the'FLAGS'parameter! Specifically, if'FLAGS'were passed'0', then this parameter is fully-irrelevant and ignored. The exception flags are listed in inner-classJFlagsIf an exception-case is encountered, but the exception-flag for that exception has not been set, then this default-value won't be returned, and that exception will throw instead.- Returns:
- On success, this method returns the converted number (of type
'T'). - Throws:
JsonPropMissingException- If'jo'does not have a property with the name'propertyName'and none of these Exception-Flags are set:RETURN_NULL_ON_MISSING(Abbrev:RN_M)RETURN_DEFVAL_ON_MISSING(Abbrev:RD_M)RETURN_NULL_ON_ANY_ALL(Abbrev:RN_AA)RETURN_DEFVAL_ON_ANY_ALL(Abbrev:RD_AA)
JsonArithmeticObjException- If the number converstion function throws anArithmeticExceptionwhile attempting to convert theJsonNumberinto anumber, and none of these Exception-Flags are set:RETURN_NULL_ON_AEX(Abbrev:RN_AEX)RETURN_DEFVAL_ON_AEX(Abbrev:RN_AEX)RETURN_JAPPROX_ON_AEX(Abbrev:RJA_AEX)RETURN_NULL_ON_ANY_ALL(Abbrev:RN_AA)RETURN_DEFVAL_ON_ANY_ALL(Abbrev:RD_AA)
JsonNullObjException- If theJsonObjectproperty specified by'propertyName'contains Json-Null, rather than aJsonNumber, and none of these Exception-Flags are set:RETURN_NULL_ON_NULL(Abbrev:RN_N)RETURN_DEFVAL_ON_NULL(Abbrev:RD_N)RETURN_NULL_ON_ANY_ALL(Abbrev:RN_AA)RETURN_DEFVAL_ON_ANY_ALL(Abbrev:RD_AA)
JsonTypeObjException- If theJsonObjectproperty specified by'propertyName'contains a some other Json-Type rather thanJsonNumber, and none of these Exception-Flags are set:RETURN_NULL_ON_WRONG_JSONTYPE(Abbrev:RN_WT)RETURN_DEFVAL_ON_WRONG_JSONTYPE(Abbrev:RD_WT)RETURN_NULL_ON_ANY_ALL(Abbrev:RN_AA)RETURN_DEFVAL_ON_ANY_ALL(Abbrev:RD_AA)
- See Also:
getInteger(JsonObject, String, int, int),getLong(JsonObject, String, int, long),getShort(JsonObject, String, int, short),getByte(JsonObject, String, int, byte),getDouble(JsonObject, String, int, double),getFloat(JsonObject, String, int, float),ReadNumberJSON.get(JsonObject, String, int, Number),RJInternal.JPMEX(JsonObject, String, Object, int, JsonValue.ValueType, Class),RJInternal.JNOEX(JsonObject, String, Object, int, JsonValue.ValueType, Class),RJInternal.JTOEX(JsonObject, String, Object, int, JsonValue.ValueType, JsonValue, Class)- Code:
- Exact Method Body:
final 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) final 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); }
-
-