Class RJArrIntoPrimArray


  • public class RJArrIntoPrimArray
    extends java.lang.Object
    RJArrIntoPrimArray 🠞
    • RJArr - Read JsonArray
      This class is used for reading data directly from an already parsed JsonArray instance.

    • Into - Data that is extracted, is sent to a specific User-Provided Destination.

    • DimN - Data is sent to a Primitive Java-Array.
    Utilities for parsing Json Array's and sending the parsed values into a Java-Array

    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 and JsonObject




    The seven methods provided by this class are, also, all declared 'static'. They produce simple, Single-Dimension, Java Primitive-Array's. This makes for a total of seven "Generator Methods" provided in this class' simple A.P.I. There is one method for each of the Primitive-Types included with the JDK, except for type char.

    It might be of some interest to know that the three types for which Oracle has written "Primitive-Stream" types (IntStream, LongStream and DoubleStream) are methods which, in this class, are nothing more than single line convenience Wrapper-Invocations around calls to the class RJArrIntoPrimStream, followed by a call to the Primitive-Stream Helper-Method which is included in all implementations of the Stream-API - which is 'toArray(...)'.

    These three are simple, single-line calls: intArr(...), longArr(...) and doubleArr(...).

    The remaining four Primitive-Types require methods which actually build a Java Boxed-Stream, and then convert the Boxed-Stream into a primitive array. The methods which do this include those for generating: short[], byte[], float[] and boolean[].

    JSON Binding Helper-Class:
    JSON-Binding is the art of converting data that has been stored, saved or transmitted using Java-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





    Arrays from Primitive Stream's
    Java has three Primitive-Stream types: IntStream, LongStream and DoubleStream. These are also easily converted into array's via the following:
    StreamArray
    IntStreamint[] arr = IntStream.toArray()
    LongStreamlong[] arr = LongStream.toArray()
    DoubleStreamdouble[] arr = DoubleStream.toArray()


    It is for this reason that these three array types are not included as methods in this class. If you need an int[]-Array, please use:

    See Also:
    Json, JsonArray



    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
    • 7 Method(s), 7 declared static
    • 0 Field(s)


    • Method Summary

       
      Read the Contents of a Json-Array into a Java Primitive-Array
      Modifier and Type Method
      static boolean[] booleanArr​(JsonArray ja, boolean defaultValue, int FLAGS, Predicate<String> optionalUserParser)
      static byte[] byteArr​(JsonArray ja, byte defaultValue, int FLAGS, ToByteFunction<String> optionalUserParser)
      static double[] doubleArr​(JsonArray ja, double defaultValue, int FLAGS, ToDoubleFunction<String> optionalUserParser)
      static float[] floatArr​(JsonArray ja, float defaultValue, int FLAGS, ToFloatFunction<String> optionalUserParser)
      static int[] intArr​(JsonArray ja, int defaultValue, int FLAGS, ToIntFunction<String> optionalUserParser)
      static long[] longArr​(JsonArray ja, long defaultValue, int FLAGS, ToLongFunction<String> optionalUserParser)
      static short[] shortArr​(JsonArray ja, short defaultValue, int FLAGS, ToShortFunction<String> optionalUserParser)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait