Package Torello.Java.JSON
Class RJArrIntoPrimConsumer
- java.lang.Object
-
- Torello.Java.JSON.RJArrIntoPrimConsumer
-
public class RJArrIntoPrimConsumer extends java.lang.Object
RJArrIntoPrimConsumer 🠞RJArr
- ReadJsonArray
This class is used for reading data directly from an already parsedJsonArray
instance.
Into
- Data that is extracted, is sent to a specific User-Provided Destination.
DimN
- Data is sent to a Java Primitive-Consumer.
Utilities for parsing Json Array's and sending the parsed values into a Java Consumer of Boxed-Primitives.
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
Each of the methods in this class, all declared'static'
, accept a standardJsonArray
as input, and make a (User-Specified) "Best Efforts" attempt to convert each of the elements of the array into Java-Primitives. Each Json-Array Element that is successfully converted into a primitive is subsequently passed to a (User-Provided) Java-Consumer.
This class is capable of processing 7 of the 8 Java-Primitives that the language makes available. The'char'
type is not accomodated by the Array-Processing Classes in this Json-Package. For each method in this class, the user is expected to provide a singleJsonArray
as input, along with one of the appropriate & matching Java Primitive-Consumer. For thePrimitive-Consumer's
which aren't actually provided by the packagejava.util.function
, the ones within packageTorello.Java.Function
should be supplied, instead.
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
Hi-Lited Source-Code:This File's Source Code:
- View Here: Torello/Java/JSON/RJArrIntoPrimConsumer.java
- Open New Browser-Tab: Torello/Java/JSON/RJArrIntoPrimConsumer.java
File Size: 20,533 Bytes Line Count: 521 '\n' Characters Found
Build a Settings-Record, Helper Class:
- View Here: BASIC_TYPES.java
- Open New Browser-Tab: BASIC_TYPES.java
File Size: 27,692 Bytes Line Count: 586 '\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
Read the Contents of a Json-Array into a Java Primitive-Consumer Modifier and Type Method static void
booleanArr(JsonArray ja, boolean defaultValue, int FLAGS, Predicate<String> optionalUserParser, BoolConsumer c)
static void
byteArr(JsonArray ja, byte defaultValue, int FLAGS, ToByteFunction<String> optionalUserParser, ByteConsumer c)
static void
doubleArr(JsonArray ja, double defaultValue, int FLAGS, ToDoubleFunction<String> optionalUserParser, DoubleConsumer c)
static void
floatArr(JsonArray ja, float defaultValue, int FLAGS, ToFloatFunction<String> optionalUserParser, FloatConsumer c)
static void
intArr(JsonArray ja, int defaultValue, int FLAGS, ToIntFunction<String> optionalUserParser, IntConsumer c)
static void
longArr(JsonArray ja, long defaultValue, int FLAGS, ToLongFunction<String> optionalUserParser, LongConsumer c)
static void
shortArr(JsonArray ja, short defaultValue, int FLAGS, ToShortFunction<String> optionalUserParser, ShortConsumer c)
Read the Contents of a Json-Array into a Primitive-Consumer, w/ Array-Indices Modifier and Type Method static void
booleanArr2(JsonArray ja, boolean defaultValue, int FLAGS, Predicate<String> optionalUserParser, IntIntBoolCons c)
static void
byteArr2(JsonArray ja, byte defaultValue, int FLAGS, ToByteFunction<String> optionalUserParser, IntIntByteCons c)
static void
doubleArr2(JsonArray ja, double defaultValue, int FLAGS, ToDoubleFunction<String> optionalUserParser, IntIntDoubleCons c)
static void
floatArr2(JsonArray ja, float defaultValue, int FLAGS, ToFloatFunction<String> optionalUserParser, IntIntFloatCons c)
static void
intArr2(JsonArray ja, int defaultValue, int FLAGS, ToIntFunction<String> optionalUserParser, TriIntCons c)
static void
longArr2(JsonArray ja, long defaultValue, int FLAGS, ToLongFunction<String> optionalUserParser, IntIntLongCons c)
static void
shortArr2(JsonArray ja, short defaultValue, int FLAGS, ToShortFunction<String> optionalUserParser, IntIntShortCons c)
-
-
-
Method Detail
-
intArr
public static void intArr (JsonArray ja, int defaultValue, int FLAGS, java.util.function.ToIntFunction<java.lang.String> optionalUserParser, java.util.function.IntConsumer c)
Java-Consumer which accepts Primitive-IntegersInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Integer
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Lambda-Signature: Like void accept (int value)
Example:
IntConsumer myConsumer = (int primVal) -> System.out.println(primVal); RJArrIntoBoxedConsumer.intArr(ja, -1, 0, null, myConsumer);
-
shortArr
public static void shortArr (JsonArray ja, short defaultValue, int FLAGS, ToShortFunction<java.lang.String> optionalUserParser, ShortConsumer c)
Java-Consumer which accepts Primitive Short-IntegersInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Short
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Lambda-Signature: Like void accept (short value)
Example:
ShortConsumer myConsumer = (short primVal) -> System.out.println(primVal); RJArrIntoBoxedConsumer.shortArr(ja, -1, 0, null, myConsumer);
-
byteArr
public static void byteArr (JsonArray ja, byte defaultValue, int FLAGS, ToByteFunction<java.lang.String> optionalUserParser, ByteConsumer c)
Java-Consumer which accepts Primitive-BytesInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Byte
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Lambda-Signature: Like void accept (byte value)
Example:
ByteConsumer myConsumer = (byte primVal) -> System.out.println(primVal); RJArrIntoBoxedConsumer.byteArr(ja, -1, 0, null, myConsumer);
-
longArr
public static void longArr (JsonArray ja, long defaultValue, int FLAGS, java.util.function.ToLongFunction<java.lang.String> optionalUserParser, java.util.function.LongConsumer c)
Java-Consumer which accepts Primitive Long-IntegersInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Long
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Lambda-Signature: Like void accept (long value)
Example:
LongConsumer myConsumer = (long primVal) -> System.out.println(primVal); RJArrIntoBoxedConsumer.longArr(ja, -1, 0, null, myConsumer);
-
doubleArr
public static void doubleArr (JsonArray ja, double defaultValue, int FLAGS, java.util.function.ToDoubleFunction<java.lang.String> optionalUserParser, java.util.function.DoubleConsumer c)
Java-Consumer which accepts Primitive-DoublesInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Double
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Lambda-Signature: Like void accept (double value)
Example:
DoubleConsumer myConsumer = (double primVal) -> System.out.println(primVal); RJArrIntoBoxedConsumer.doubleArr(ja, -1, 0, null, myConsumer);
-
floatArr
public static void floatArr (JsonArray ja, float defaultValue, int FLAGS, ToFloatFunction<java.lang.String> optionalUserParser, FloatConsumer c)
Java-Consumer which accepts Primitive-FloatsInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Float
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Lambda-Signature: Like void accept (float value)
Example:
FloatConsumer myConsumer = (float primVal) -> System.out.println(primVal); RJArrIntoBoxedConsumer.floatArr(ja, -1, 0, null, myConsumer);
-
booleanArr
public static void booleanArr (JsonArray ja, boolean defaultValue, int FLAGS, java.util.function.Predicate<java.lang.String> optionalUserParser, BoolConsumer c)
Java-Consumer which accepts Primitive-BooleansInvokes: Method ProcessJsonArray.booleanToJava(JsonArray, SettingsRec)
Passes: Java Boolean
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Lambda-Signature: Like void accept (boolean value)
Example:
BoolConsumer myConsumer = (boolean primVal) -> System.out.println(primVal); RJArrIntoBoxedConsumer.booleanArr(ja, -1, 0, null, myConsumer);
-
intArr2
public static void intArr2 (JsonArray ja, int defaultValue, int FLAGS, java.util.function.ToIntFunction<java.lang.String> optionalUserParser, TriIntCons c)
Java-Consumer which accepts Primitive-Integers & Array-IndicesInvokes: ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Integer
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Input-Consumer: Interface TriIntCons
Lambda-Signature: Like void accept (int jsonArrIndex, int javaArrIndex, int value)
Example:
TriIntCons myConsumer = (int i1, int i2, int primVal) -> System.out.println("jsonArr[" + i1 + "], javaArr[" + i2 + "]: " + primVal); RJArrIntoBoxedConsumer.intArr2(ja, -1, 0, null, myConsumer);
-
shortArr2
public static void shortArr2 (JsonArray ja, short defaultValue, int FLAGS, ToShortFunction<java.lang.String> optionalUserParser, IntIntShortCons c)
Java-Consumer which accepts Primitive Short-Integers & Array-IndicesInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Short
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Input-Consumer: Interface IntIntShortCons
Lambda-Signature: Like void accept (int jsonArrIndex, int javaArrIndex, short value)
Example:
IntIntShortCons myConsumer = (int i1, int i2, short primVal) -> System.out.println("jsonArr[" + i1 + "], javaArr[" + i2 + "]: " + primVal); RJArrIntoBoxedConsumer.shortArr2(ja, -1, 0, null, myConsumer);
-
byteArr2
public static void byteArr2 (JsonArray ja, byte defaultValue, int FLAGS, ToByteFunction<java.lang.String> optionalUserParser, IntIntByteCons c)
Java-Consumer which accepts Primitive-Bytes & Array-IndicesInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Byte
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Input-Consumer: Interface IntIntByteCons
Lambda-Signature: Like void accept (int jsonArrIndex, int javaArrIndex, byte value)
Example:
IntIntByteCons myConsumer = (int i1, int i2, byte primVal) -> System.out.println("jsonArr[" + i1 + "], javaArr[" + i2 + "]: " + primVal); RJArrIntoBoxedConsumer.byteArr2(ja, -1, 0, null, myConsumer);
-
longArr2
public static void longArr2 (JsonArray ja, long defaultValue, int FLAGS, java.util.function.ToLongFunction<java.lang.String> optionalUserParser, IntIntLongCons c)
Java-Consumer which accepts Primitive Long-Integers & Array-IndicesInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Long
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Input-Consumer: Interface IntIntLongCons
Lambda-Signature: Like void accept (int jsonArrIndex, int javaArrIndex, long value)
Example:
IntIntLongCons myConsumer = (int i1, int i2, long primVal) -> System.out.println("jsonArr[" + i1 + "], javaArr[" + i2 + "]: " + primVal); RJArrIntoBoxedConsumer.longArr2(ja, -1, 0, null, myConsumer);
-
doubleArr2
public static void doubleArr2 (JsonArray ja, double defaultValue, int FLAGS, java.util.function.ToDoubleFunction<java.lang.String> optionalUserParser, IntIntDoubleCons c)
Java-Consumer which accepts Primitive-Doubles & Array-IndicesInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Double
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Input-Consumer: Interface IntIntDoubleCons
Lambda-Signature: Like void accept (int jsonArrIndex, int javaArrIndex, double value)
Example:
IntIntDoubleCons myConsumer = (int i1, int i2, double primVal) -> System.out.println("jsonArr[" + i1 + "], javaArr[" + i2 + "]: " + primVal); RJArrIntoBoxedConsumer.doubleArr2(ja, -1, 0, null, myConsumer);
-
floatArr2
public static void floatArr2 (JsonArray ja, float defaultValue, int FLAGS, ToFloatFunction<java.lang.String> optionalUserParser, IntIntFloatCons c)
Java-Consumer which accepts Primitive-Floats & Array-IndicesInvokes: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
Passes: Java Float
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Input-Consumer: Interface IntIntFloatCons
Lambda-Signature: Like void accept (int jsonArrIndex, int javaArrIndex, float value)
Example:
IntIntFloatCons myConsumer = (int i1, int i2, float primVal) -> System.out.println("jsonArr[" + i1 + "], javaArr[" + i2 + "]: " + primVal); RJArrIntoBoxedConsumer.floatArr2(ja, -1, 0, null, myConsumer);
-
booleanArr2
public static void booleanArr2 (JsonArray ja, boolean defaultValue, int FLAGS, java.util.function.Predicate<java.lang.String> optionalUserParser, IntIntBoolCons c)
Java-Consumer which accepts Primitive-Booleans & Array-IndicesInvokes: Method ProcessJsonArray.booleanToJava(JsonArray, SettingsRec)
Passes: Java Boolean
Settings-RecordRemoves: Any JFlag
masks which might insert null-entries in the return-streamSee: Class JFlag
for information about parameter'FLAGS'
See: Flag JFlag.NOT_ALLOWED_RET_NULL_MASKS
for a list of all disallowed & filtered flags.Input-Consumer: Interface IntIntBoolCons
Lambda-Signature: Like void accept (int jsonArrIndex, int javaArrIndex, boolean value)
Example:
IntIntBoolCons myConsumer = (int i1, int i2, boolean primVal) -> System.out.println("jsonArr[" + i1 + "], javaArr[" + i2 + "]: " + primVal); RJArrIntoBoxedConsumer.booleanArr2(ja, -1, 0, null, myConsumer);
-
-