Package Torello.Java.JSON
Class ReadBoxedJSON.XL
- java.lang.Object
-
- Torello.Java.JSON.ReadBoxedJSON.XL
-
- Enclosing class:
- ReadBoxedJSON
public static class ReadBoxedJSON.XL extends java.lang.Object
JSON Binding Helper-Class:
JSON-Binding is the art of converting data that has been stored, saved or transmitted usingJava-Script Object Notation
into a Primitive-Type or Object-Type of any Programming Language, for instance Java.JSON
often arrives into Java-Program Memory from an external Internet Connection, and may have traveled hundreds or even thousands of miles from a Host-Server.
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 is never completely assured.
Being able to handle changes that might be made to an API (possibly from great distances away, and without the Software-Manager's consent) is the type of feature that robust JSON-Code simply has to offer.
Binding-Helper Features:- 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
- Primary Helper-Classes for the (Experimental) Google-Chrome
Headless Browser
Package
Utilities for parsing & convertingJsonString
's orJsonNumber
's 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 tool included in the J2EE is available on GitHub, and that is the one used by the Java HTML JAR Library. (See:javax.json.*
)
Primary Classes Used:JsonArray
andJsonObject
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:
Json
,JsonObject
,JsonArray
Hi-Lited Source-Code:- View Here: Torello/Java/JSON/ReadBoxedJSON.java
- Open New Browser-Tab: Torello/Java/JSON/ReadBoxedJSON.java
File Size: 26,590 Bytes Line Count: 494 '\n' Characters Found
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 fields. It is a concept very similar to the Java-Bean's@Stateless
Annotation.
- 1 Constructor(s), 1 declared private, zero-argument constructor
- 14 Method(s), 14 declared static
- 0 Field(s)
-
-
Method Summary
Integer: Retrieve either a JsonNumber
orJsonString
and transform it to a Java Boxed-IntegerModifier and Type Method static Integer
getInteger(JsonArray ja, int i, int FLAGS, int defaultValue, Function<String,Integer> optionalParser)
static Integer
getInteger(JsonObject jo, String propertyName, int FLAGS, int defaultValue, Function<String,Integer> optionalParser)
Long: Retrieve either a JsonNumber
orJsonString
and transform it to a Java Boxed-LongModifier and Type Method static Long
getLong(JsonArray ja, int i, int FLAGS, long defaultValue, Function<String,Long> optionalParser)
static Long
getLong(JsonObject jo, String propertyName, int FLAGS, long defaultValue, Function<String,Long> optionalParser)
Short: Retrieve either a JsonNumber
orJsonString
and transform it to a Java Boxed-ShortModifier and Type Method static Short
getShort(JsonArray ja, int i, int FLAGS, short defaultValue, Function<String,Short> optionalParser)
static Short
getShort(JsonObject jo, String propertyName, int FLAGS, short defaultValue, Function<String,Short> optionalParser)
Byte: Retrieve either a JsonNumber
orJsonString
and transform it to a Java Boxed-ByteModifier and Type Method static Byte
getByte(JsonArray ja, int i, int FLAGS, byte defaultValue, Function<String,Byte> optionalParser)
static Byte
getByte(JsonObject jo, String propertyName, int FLAGS, byte defaultValue, Function<String,Byte> optionalParser)
Double: Retrieve either a JsonNumber
orJsonString
and transform it to a Java Boxed-DoubleModifier and Type Method static Double
getDouble(JsonArray ja, int i, int FLAGS, double defaultValue, Function<String,Double> optionalParser)
static Double
getDouble(JsonObject jo, String propertyName, int FLAGS, double defaultValue, Function<String,Double> optionalParser)
Float: Retrieve either a JsonNumber
orJsonString
and transform it to a Java Boxed-FloatModifier and Type Method static Float
getFloat(JsonArray ja, int i, int FLAGS, float defaultValue, Function<String,Float> optionalParser)
static Float
getFloat(JsonObject jo, String propertyName, int FLAGS, float defaultValue, Function<String,Float> optionalParser)
Boolean: Retrieve either JsonValue.TRUE
,FALSE
or aJsonString
, and transform to Boxed-BooleanModifier and Type Method static Boolean
getBoolean(JsonArray ja, int i, int FLAGS, boolean defaultValue, Function<String,Boolean> optionalParser)
static Boolean
getBoolean(JsonObject jo, String propertyName, int FLAGS, boolean defaultValue, Function<String,Boolean> optionalParser)
-
-
-
Method Detail
-
getInteger
public static java.lang.Integer getInteger (JsonArray ja, int i, int FLAGS, int defaultValue, java.util.function.Function<java.lang.String,java.lang.Integer> optionalParser)
Used to convert aJsonArray
element which can handle either aString
, or aNumber
, and transform that element into a JavaInteger
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether a string or a number is found at the array index location.- Parameters:
ja
- AnyJsonArray
i
- Any index into theJsonArray
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaInteger
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toInteger
parser-function is required to generate the result for this method, thenInteger.parseInt(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonArray
index contained a number, and that number was successfully transformed to aInteger
, then it is returned.
If the array-index was aString
, and thatString
was transformed into aInteger
using either'parser'
- or the default parser, then thatInteger
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseArrException
- If theJsonArray
element located at'index'
contains aJsonString
, this method will attempt to parse thatString
into a JavaInteger
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Integer.parseInt(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullArrException
- If theJsonArray
element located at'index'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonArray
element located at'index'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getInteger(JsonArray, int, int, int)
,ReadBoxedJSON.parseInteger(JsonArray, int, int, int, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ((i >= ja.size()) || ((t=ja.get(i).getValueType()) == NUMBER) || (t != STRING)) ? ReadBoxedJSON.getInteger(ja, i, FLAGS, defaultValue) : ReadBoxedJSON.parseInteger(ja, i, FLAGS, defaultValue, optionalParser);
-
getLong
public static java.lang.Long getLong (JsonArray ja, int i, int FLAGS, long defaultValue, java.util.function.Function<java.lang.String,java.lang.Long> optionalParser)
Used to convert aJsonArray
element which can handle either aString
, or aNumber
, and transform that element into a JavaLong
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether a string or a number is found at the array index location.- Parameters:
ja
- AnyJsonArray
i
- Any index into theJsonArray
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaLong
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toLong
parser-function is required to generate the result for this method, thenLong.parseLong(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonArray
index contained a number, and that number was successfully transformed to aLong
, then it is returned.
If the array-index was aString
, and thatString
was transformed into aLong
using either'parser'
- or the default parser, then thatLong
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseArrException
- If theJsonArray
element located at'index'
contains aJsonString
, this method will attempt to parse thatString
into a JavaLong
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Long.parseLong(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullArrException
- If theJsonArray
element located at'index'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonArray
element located at'index'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getLong(JsonArray, int, int, long)
,ReadBoxedJSON.parseLong(JsonArray, int, int, long, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ((i >= ja.size()) || ((t=ja.get(i).getValueType()) == NUMBER) || (t != STRING)) ? ReadBoxedJSON.getLong(ja, i, FLAGS, defaultValue) : ReadBoxedJSON.parseLong(ja, i, FLAGS, defaultValue, optionalParser);
-
getShort
public static java.lang.Short getShort (JsonArray ja, int i, int FLAGS, short defaultValue, java.util.function.Function<java.lang.String,java.lang.Short> optionalParser)
Used to convert aJsonArray
element which can handle either aString
, or aNumber
, and transform that element into a JavaShort
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether a string or a number is found at the array index location.- Parameters:
ja
- AnyJsonArray
i
- Any index into theJsonArray
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaShort
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toShort
parser-function is required to generate the result for this method, thenShort.parseShort(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonArray
index contained a number, and that number was successfully transformed to aShort
, then it is returned.
If the array-index was aString
, and thatString
was transformed into aShort
using either'parser'
- or the default parser, then thatShort
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseArrException
- If theJsonArray
element located at'index'
contains aJsonString
, this method will attempt to parse thatString
into a JavaShort
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Short.parseShort(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullArrException
- If theJsonArray
element located at'index'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonArray
element located at'index'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getShort(JsonArray, int, int, short)
,ReadBoxedJSON.parseShort(JsonArray, int, int, short, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ((i >= ja.size()) || ((t=ja.get(i).getValueType()) == NUMBER) || (t != STRING)) ? ReadBoxedJSON.getShort(ja, i, FLAGS, defaultValue) : ReadBoxedJSON.parseShort(ja, i, FLAGS, defaultValue, optionalParser);
-
getByte
public static java.lang.Byte getByte (JsonArray ja, int i, int FLAGS, byte defaultValue, java.util.function.Function<java.lang.String,java.lang.Byte> optionalParser)
Used to convert aJsonArray
element which can handle either aString
, or aNumber
, and transform that element into a JavaByte
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether a string or a number is found at the array index location.- Parameters:
ja
- AnyJsonArray
i
- Any index into theJsonArray
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaByte
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toByte
parser-function is required to generate the result for this method, thenByte.parseByte(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonArray
index contained a number, and that number was successfully transformed to aByte
, then it is returned.
If the array-index was aString
, and thatString
was transformed into aByte
using either'parser'
- or the default parser, then thatByte
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseArrException
- If theJsonArray
element located at'index'
contains aJsonString
, this method will attempt to parse thatString
into a JavaByte
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Byte.parseByte(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullArrException
- If theJsonArray
element located at'index'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonArray
element located at'index'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getByte(JsonArray, int, int, byte)
,ReadBoxedJSON.parseByte(JsonArray, int, int, byte, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ((i >= ja.size()) || ((t=ja.get(i).getValueType()) == NUMBER) || (t != STRING)) ? ReadBoxedJSON.getByte(ja, i, FLAGS, defaultValue) : ReadBoxedJSON.parseByte(ja, i, FLAGS, defaultValue, optionalParser);
-
getDouble
public static java.lang.Double getDouble (JsonArray ja, int i, int FLAGS, double defaultValue, java.util.function.Function<java.lang.String,java.lang.Double> optionalParser)
Used to convert aJsonArray
element which can handle either aString
, or aNumber
, and transform that element into a JavaDouble
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether a string or a number is found at the array index location.- Parameters:
ja
- AnyJsonArray
i
- Any index into theJsonArray
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaDouble
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toDouble
parser-function is required to generate the result for this method, thenDouble.parseDouble(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonArray
index contained a number, and that number was successfully transformed to aDouble
, then it is returned.
If the array-index was aString
, and thatString
was transformed into aDouble
using either'parser'
- or the default parser, then thatDouble
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseArrException
- If theJsonArray
element located at'index'
contains aJsonString
, this method will attempt to parse thatString
into a JavaDouble
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Double.parseDouble(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullArrException
- If theJsonArray
element located at'index'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonArray
element located at'index'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getDouble(JsonArray, int, int, double)
,ReadBoxedJSON.parseDouble(JsonArray, int, int, double, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ((i >= ja.size()) || ((t=ja.get(i).getValueType()) == NUMBER) || (t != STRING)) ? ReadBoxedJSON.getDouble(ja, i, FLAGS, defaultValue) : ReadBoxedJSON.parseDouble(ja, i, FLAGS, defaultValue, optionalParser);
-
getFloat
public static java.lang.Float getFloat (JsonArray ja, int i, int FLAGS, float defaultValue, java.util.function.Function<java.lang.String,java.lang.Float> optionalParser)
Used to convert aJsonArray
element which can handle either aString
, or aNumber
, and transform that element into a JavaFloat
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether a string or a number is found at the array index location.- Parameters:
ja
- AnyJsonArray
i
- Any index into theJsonArray
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaFloat
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toFloat
parser-function is required to generate the result for this method, thenFloat.parseFloat(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonArray
index contained a number, and that number was successfully transformed to aFloat
, then it is returned.
If the array-index was aString
, and thatString
was transformed into aFloat
using either'parser'
- or the default parser, then thatFloat
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseArrException
- If theJsonArray
element located at'index'
contains aJsonString
, this method will attempt to parse thatString
into a JavaFloat
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Float.parseFloat(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullArrException
- If theJsonArray
element located at'index'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonArray
element located at'index'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getFloat(JsonArray, int, int, float)
,ReadBoxedJSON.parseFloat(JsonArray, int, int, float, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ((i >= ja.size()) || ((t=ja.get(i).getValueType()) == NUMBER) || (t != STRING)) ? ReadBoxedJSON.getFloat(ja, i, FLAGS, defaultValue) : ReadBoxedJSON.parseFloat(ja, i, FLAGS, defaultValue, optionalParser);
-
getBoolean
public static java.lang.Boolean getBoolean (JsonArray ja, int i, int FLAGS, boolean defaultValue, java.util.function.Function<java.lang.String,java.lang.Boolean> optionalParser)
Used to convert aJsonArray
element which can handle either aString
, or aNumber
, and transform that element into a JavaBoolean
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether a string or a number is found at the array index location.- Parameters:
ja
- AnyJsonArray
i
- Any index into theJsonArray
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaBoolean
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toBoolean
parser-function is required to generate the result for this method, thenBoolean.parseBoolean(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonArray
index contained a number, and that number was successfully transformed to aBoolean
, then it is returned.
If the array-index was aString
, and thatString
was transformed into aBoolean
using either'parser'
- or the default parser, then thatBoolean
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseArrException
- If theJsonArray
element located at'index'
contains aJsonString
, this method will attempt to parse thatString
into a JavaBoolean
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Boolean.parseBoolean(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullArrException
- If theJsonArray
element located at'index'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonArray
element located at'index'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getBoolean(JsonArray, int, int, boolean)
,ReadBoxedJSON.parseBoolean(JsonArray, int, int, boolean, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ( (i >= ja.size()) || ((t=ja.get(i).getValueType()) == TRUE) || (t == FALSE) || (t != STRING) ) ? ReadBoxedJSON.getBoolean(ja, i, FLAGS, defaultValue) : ReadBoxedJSON.parseBoolean(ja, i, FLAGS, defaultValue, optionalParser);
-
getInteger
public static java.lang.Integer getInteger (JsonObject jo, java.lang.String propertyName, int FLAGS, int defaultValue, java.util.function.Function<java.lang.String,java.lang.Integer> optionalParser)
Used to convert aJsonObject
property which can handle either aString
, or aNumber
, and transform that element into a JavaInteger
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether the specified object property contains a string or a number.- Parameters:
jo
- AnyJsonObject
propertyName
- Any of the properties defined in theJsonObject
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaInteger
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toInteger
parser-function is required to generate the result for this method, thenInteger.parseInt(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonObject
property contained a number, and that number was successfully transformed to aInteger
, then it is returned.
If the object-property was aString
, and thatString
was transformed into aInteger
using either'parser'
- or the default parser, then thatInteger
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseObjException
- If theJsonObject
property specified by'propertyName'
contains aJsonString
, this method will attempt to parse thatString
into a JavaInteger
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Integer.parseInt(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullObjException
- If theJsonObject
property specified by'propertyName'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonObject
property specified by'propertyName'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getInteger(JsonObject, String, int, int)
,ReadBoxedJSON.parseInteger(JsonObject, String, int, int, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ( (! jo.containsKey(propertyName)) || ((t = jo.get(propertyName).getValueType()) == NUMBER) || (t != STRING) ) ? ReadBoxedJSON.getInteger(jo, propertyName, FLAGS, defaultValue) : ReadBoxedJSON.parseInteger(jo, propertyName, FLAGS, defaultValue, optionalParser);
-
getLong
public static java.lang.Long getLong (JsonObject jo, java.lang.String propertyName, int FLAGS, long defaultValue, java.util.function.Function<java.lang.String,java.lang.Long> optionalParser)
Used to convert aJsonObject
property which can handle either aString
, or aNumber
, and transform that element into a JavaLong
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether the specified object property contains a string or a number.- Parameters:
jo
- AnyJsonObject
propertyName
- Any of the properties defined in theJsonObject
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaLong
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toLong
parser-function is required to generate the result for this method, thenLong.parseLong(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonObject
property contained a number, and that number was successfully transformed to aLong
, then it is returned.
If the object-property was aString
, and thatString
was transformed into aLong
using either'parser'
- or the default parser, then thatLong
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseObjException
- If theJsonObject
property specified by'propertyName'
contains aJsonString
, this method will attempt to parse thatString
into a JavaLong
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Long.parseLong(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullObjException
- If theJsonObject
property specified by'propertyName'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonObject
property specified by'propertyName'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getLong(JsonObject, String, int, long)
,ReadBoxedJSON.parseLong(JsonObject, String, int, long, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ( (! jo.containsKey(propertyName)) || ((t = jo.get(propertyName).getValueType()) == NUMBER) || (t != STRING) ) ? ReadBoxedJSON.getLong(jo, propertyName, FLAGS, defaultValue) : ReadBoxedJSON.parseLong(jo, propertyName, FLAGS, defaultValue, optionalParser);
-
getShort
public static java.lang.Short getShort (JsonObject jo, java.lang.String propertyName, int FLAGS, short defaultValue, java.util.function.Function<java.lang.String,java.lang.Short> optionalParser)
Used to convert aJsonObject
property which can handle either aString
, or aNumber
, and transform that element into a JavaShort
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether the specified object property contains a string or a number.- Parameters:
jo
- AnyJsonObject
propertyName
- Any of the properties defined in theJsonObject
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaShort
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toShort
parser-function is required to generate the result for this method, thenShort.parseShort(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonObject
property contained a number, and that number was successfully transformed to aShort
, then it is returned.
If the object-property was aString
, and thatString
was transformed into aShort
using either'parser'
- or the default parser, then thatShort
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseObjException
- If theJsonObject
property specified by'propertyName'
contains aJsonString
, this method will attempt to parse thatString
into a JavaShort
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Short.parseShort(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullObjException
- If theJsonObject
property specified by'propertyName'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonObject
property specified by'propertyName'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getShort(JsonObject, String, int, short)
,ReadBoxedJSON.parseShort(JsonObject, String, int, short, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ( (! jo.containsKey(propertyName)) || ((t = jo.get(propertyName).getValueType()) == NUMBER) || (t != STRING) ) ? ReadBoxedJSON.getShort(jo, propertyName, FLAGS, defaultValue) : ReadBoxedJSON.parseShort(jo, propertyName, FLAGS, defaultValue, optionalParser);
-
getByte
public static java.lang.Byte getByte (JsonObject jo, java.lang.String propertyName, int FLAGS, byte defaultValue, java.util.function.Function<java.lang.String,java.lang.Byte> optionalParser)
Used to convert aJsonObject
property which can handle either aString
, or aNumber
, and transform that element into a JavaByte
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether the specified object property contains a string or a number.- Parameters:
jo
- AnyJsonObject
propertyName
- Any of the properties defined in theJsonObject
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaByte
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toByte
parser-function is required to generate the result for this method, thenByte.parseByte(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonObject
property contained a number, and that number was successfully transformed to aByte
, then it is returned.
If the object-property was aString
, and thatString
was transformed into aByte
using either'parser'
- or the default parser, then thatByte
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseObjException
- If theJsonObject
property specified by'propertyName'
contains aJsonString
, this method will attempt to parse thatString
into a JavaByte
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Byte.parseByte(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullObjException
- If theJsonObject
property specified by'propertyName'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonObject
property specified by'propertyName'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getByte(JsonObject, String, int, byte)
,ReadBoxedJSON.parseByte(JsonObject, String, int, byte, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ( (! jo.containsKey(propertyName)) || ((t = jo.get(propertyName).getValueType()) == NUMBER) || (t != STRING) ) ? ReadBoxedJSON.getByte(jo, propertyName, FLAGS, defaultValue) : ReadBoxedJSON.parseByte(jo, propertyName, FLAGS, defaultValue, optionalParser);
-
getDouble
public static java.lang.Double getDouble (JsonObject jo, java.lang.String propertyName, int FLAGS, double defaultValue, java.util.function.Function<java.lang.String,java.lang.Double> optionalParser)
Used to convert aJsonObject
property which can handle either aString
, or aNumber
, and transform that element into a JavaDouble
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether the specified object property contains a string or a number.- Parameters:
jo
- AnyJsonObject
propertyName
- Any of the properties defined in theJsonObject
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaDouble
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toDouble
parser-function is required to generate the result for this method, thenDouble.parseDouble(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonObject
property contained a number, and that number was successfully transformed to aDouble
, then it is returned.
If the object-property was aString
, and thatString
was transformed into aDouble
using either'parser'
- or the default parser, then thatDouble
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseObjException
- If theJsonObject
property specified by'propertyName'
contains aJsonString
, this method will attempt to parse thatString
into a JavaDouble
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Double.parseDouble(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullObjException
- If theJsonObject
property specified by'propertyName'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonObject
property specified by'propertyName'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getDouble(JsonObject, String, int, double)
,ReadBoxedJSON.parseDouble(JsonObject, String, int, double, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ( (! jo.containsKey(propertyName)) || ((t = jo.get(propertyName).getValueType()) == NUMBER) || (t != STRING) ) ? ReadBoxedJSON.getDouble(jo, propertyName, FLAGS, defaultValue) : ReadBoxedJSON.parseDouble(jo, propertyName, FLAGS, defaultValue, optionalParser);
-
getFloat
public static java.lang.Float getFloat (JsonObject jo, java.lang.String propertyName, int FLAGS, float defaultValue, java.util.function.Function<java.lang.String,java.lang.Float> optionalParser)
Used to convert aJsonObject
property which can handle either aString
, or aNumber
, and transform that element into a JavaFloat
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether the specified object property contains a string or a number.- Parameters:
jo
- AnyJsonObject
propertyName
- Any of the properties defined in theJsonObject
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaFloat
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toFloat
parser-function is required to generate the result for this method, thenFloat.parseFloat(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonObject
property contained a number, and that number was successfully transformed to aFloat
, then it is returned.
If the object-property was aString
, and thatString
was transformed into aFloat
using either'parser'
- or the default parser, then thatFloat
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseObjException
- If theJsonObject
property specified by'propertyName'
contains aJsonString
, this method will attempt to parse thatString
into a JavaFloat
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Float.parseFloat(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullObjException
- If theJsonObject
property specified by'propertyName'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonObject
property specified by'propertyName'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getFloat(JsonObject, String, int, float)
,ReadBoxedJSON.parseFloat(JsonObject, String, int, float, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ( (! jo.containsKey(propertyName)) || ((t = jo.get(propertyName).getValueType()) == NUMBER) || (t != STRING) ) ? ReadBoxedJSON.getFloat(jo, propertyName, FLAGS, defaultValue) : ReadBoxedJSON.parseFloat(jo, propertyName, FLAGS, defaultValue, optionalParser);
-
getBoolean
public static java.lang.Boolean getBoolean (JsonObject jo, java.lang.String propertyName, int FLAGS, boolean defaultValue, java.util.function.Function<java.lang.String,java.lang.Boolean> optionalParser)
Used to convert aJsonObject
property which can handle either aString
, or aNumber
, and transform that element into a JavaBoolean
.
This method simply dispatches to one of theReadJSON
methods, depending upon whether the specified object property contains a string or a number.- Parameters:
jo
- AnyJsonObject
propertyName
- Any of the properties defined in theJsonObject
FLAGS
- Return-value / exception-throw constants defined inJFlag
defaultValue
- 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 classJFlags
AGAIN: If 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.optionalParser
- A function wich can map ajava.lang.String
into a JavaBoolean
. This'optionalParser'
is only used if the specified element contains aJsonString
rather than aJsonNumber
. If aJsonNumber
is found, or some other unrelated type, then this parameter is wholly ignored.
NOTE: null may be passed to parameter'optionalParser'
. If null is received, and if it turns out that aString
toBoolean
parser-function is required to generate the result for this method, thenBoolean.parseBoolean(String.trim())
will be used as the default-parser, instead.- Returns:
- If the
JsonObject
property contained a number, and that number was successfully transformed to aBoolean
, then it is returned.
If the object-property was aString
, and thatString
was transformed into aBoolean
using either'parser'
- or the default parser, then thatBoolean
is returned.
In all exception or error cases, parameter'FLAGS'
may indicate that either the default-value be returned, or that null be returned. If the exception-handling flags were not sufficiently set, and an error-case has occured, one of the exceptions listed below is thrown. - 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
)
JsonStrParseObjException
- If theJsonObject
property specified by'propertyName'
contains aJsonString
, this method will attempt to parse thatString
into a JavaBoolean
, using either the user-provided'parser'
(if provided), or otherwise, the default-parser (Boolean.parseBoolean(String.trim())
). This exception will throw if parsing theString
generates an exception throw AND none of these Exception-Flags are set:RETURN_NULL_ON_SPEX
(Abbrev:RN_SPEX
)RETURN_DEFVAL_ON_SPEX
(Abbrev:RD_SPEX
)RETURN_NULL_ON_ANY_ALL
(Abbrev:RN_AA
)RETURN_DEFVAL_ON_ANY_ALL
(Abbrev:RD_AA
)
JsonNullObjException
- If theJsonObject
property specified by'propertyName'
contains Json-Null, rather than aJsonNumber
or aJsonString
, 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 theJsonObject
property specified by'propertyName'
neither contains aJsonNumber
, nor aJsonString
, 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:
ReadBoxedJSON.getBoolean(JsonObject, String, int, boolean)
,ReadBoxedJSON.parseBoolean(JsonObject, String, int, boolean, Function)
- Code:
- Exact Method Body:
JsonValue.ValueType t; return ( (! jo.containsKey(propertyName)) || ((t = jo.get(propertyName).getValueType()) == TRUE) || (t == FALSE) || (t != STRING) ) ? ReadBoxedJSON.getBoolean(jo, propertyName, FLAGS, defaultValue) : ReadBoxedJSON.parseBoolean(jo, propertyName, FLAGS, defaultValue, optionalParser);
-
-