Package Torello.Java

Class StrCSV


  • public class StrCSV
    extends java.lang.Object
    A utility that builds Comma Separated Value String's (and can parse them as well).

    The routines in this class may seem trivial, and they are, but they are geared largely for use in testing, debugging and also use in methods like 'toString()'. Not having to re-write these loops over and over again anytime an array needs to be printed can make such situations mentioned a lot easier. Though the methods in this class have level of complexity that is no where near those in 'StrReplace' or even 'StrCmpr', they still can be very handy for myriad of places when the contents of array need to be printed or inspected quickly - (usually on a single line of text).

    This class' methods, essentially, convert arrays and other lists into a long java.lang.String such that each element of the String is separated by a comma. These routines are also capable of parsing a String whose elements are separated by commas, back into an array.



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


    • Method Summary

       
      Parse CSV
      Modifier and Type Method
      static String[] CSV​(String s)
      static String[] CSV​(String s, boolean performTrim, boolean eliminateZeroLengthStrings)
       
      Generate CSV
      Modifier and Type Method
      static String toCSV​(Iterable<?> i, boolean trim, boolean printNulls, Integer maxLength)
      static <T> String toCSV​(Iterable<T> i, Function<? super T,​String> toString, boolean printNulls, Integer maxLength)
      static String toCSV​(String[] sArr, boolean trim, boolean printNulls, Integer maxLength)
      static <T> String toCSV​(T[][] tArr, IntIntTFunc<? super T,​String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)
      static <T> String toCSV​(T[] tArr, boolean trim, boolean printNulls, Integer maxLength)
      static <T> String toCSV​(T[] tArr, IntTFunction<? super T,​String> toString, boolean printNulls, Integer maxLength)
       
      Generate CSV, Range-Limited
      Modifier and Type Method
      static <T> String toCSV​(T[] tArr, int sPos, int ePos, boolean trim, boolean printNulls, Integer maxLength)
      static <T> String toCSV​(T[] tArr, int sPos, int ePos, IntTFunction<? super T,​String> toString, boolean printNulls, Integer maxLength)
       
      Generate CSV, Primitive-Array
      Modifier and Type Method
      static String toCSV​(boolean[] arr, IntBoolFunction<String> toString, Integer maxLength)
      static String toCSV​(byte[] arr, IntByteFunction<String> toString, Integer maxLength)
      static String toCSV​(char[] arr, IntCharFunction<String> toString, Integer maxLength)
      static String toCSV​(double[] arr, IntDoubleFunction<String> toString, Integer maxLength)
      static String toCSV​(float[] arr, IntFloatFunction<String> toString, Integer maxLength)
      static String toCSV​(int[] arr, BiIntFunction<String> toString, Integer maxLength)
      static String toCSV​(long[] arr, IntLongFunction<String> toString, Integer maxLength)
      static String toCSV​(short[] arr, IntShortFunction<String> toString, Integer maxLength)
       
      Generate CSV, Primitive-Array, Range-Limited
      Modifier and Type Method
      static String toCSV​(boolean[] arr, int sPos, int ePos, IntBoolFunction<String> toString, Integer maxLength)
      static String toCSV​(byte[] arr, int sPos, int ePos, IntByteFunction<String> toString, Integer maxLength)
      static String toCSV​(char[] arr, int sPos, int ePos, IntCharFunction<String> toString, Integer maxLength)
      static String toCSV​(double[] arr, int sPos, int ePos, IntDoubleFunction<String> toString, Integer maxLength)
      static String toCSV​(float[] arr, int sPos, int ePos, IntFloatFunction<String> toString, Integer maxLength)
      static String toCSV​(int[] arr, int sPos, int ePos, BiIntFunction<String> toString, Integer maxLength)
      static String toCSV​(long[] arr, int sPos, int ePos, IntLongFunction<String> toString, Integer maxLength)
      static String toCSV​(short[] arr, int sPos, int ePos, IntShortFunction<String> toString, Integer maxLength)
       
      Generate CSV, 2-D Primitive-Array
      Modifier and Type Method
      static String toCSV​(boolean[][] arr, IntIntBoolFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)
      static String toCSV​(byte[][] arr, IntIntByteFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)
      static String toCSV​(char[][] arr, IntIntCharFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)
      static String toCSV​(double[][] arr, IntIntDoubleFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)
      static String toCSV​(float[][] arr, IntIntFloatFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)
      static String toCSV​(int[][] arr, TriIntFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)
      static String toCSV​(long[][] arr, IntIntLongFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)
      static String toCSV​(short[][] arr, IntIntShortFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)
      • Methods inherited from class java.lang.Object

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

      • CSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String[] CSV​(java.lang.String s,
                                             boolean performTrim,
                                             boolean eliminateZeroLengthStrings)
        This will return a list of String that are in-between each-and-every comma that is found inside the parameter-String 's'

        Java Stream API:
        This method uses Java 8 or 9's package java.util.stream.*. If this package is not familiar, it is usually just a way (after some practice), of (sort-of) converting for-loops into more readable method-calls. Java-Streams instead substitute words such as: 'filter', 'map', 'forEach' and 'toArray'. This method's code is nothing more than that.
        Parameters:
        s - This accepts any java-String, but it is expecting one that contains commas.
        performTrim - If this parameter is set to TRUE, then all String's will be trimmed of white-space before being placed in the returned String-array, by calling Java's String.trim() method.
        eliminateZeroLengthStrings - If this parameter is set to TRUE, then all String's that have zero-length will be eliminated from the returned String[] array.

        NOTE: Regardless of whether or not a trim() operation was performed, all String's that are trimmed of white-space, would have the 'trim' done before the 'eliminate' operation.
        Returns:
        This will return the individual String's from a larger-String that contained comma-separated values.
        Code:
        Exact Method Body:
         Stream<String> stream =
             StringParse.COMMA_REGEX.splitAsStream(s).filter((String csv) -> csv != null);
        
         if (performTrim)
             stream = stream.map((String csv) -> csv.trim());
        
         if (eliminateZeroLengthStrings)
             stream = stream.filter((String csv) -> csv.length() > 0);
        
         return stream.toArray(String[]::new);
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​(java.lang.Iterable<?> i,
                                             boolean trim,
                                             boolean printNulls,
                                             java.lang.Integer maxLength)
        This method will turn the elements of any java Iterable type into a java.lang.String. The returned String shall have the individual elements of parameter 'i' converted to String's, each separated by a comma.
        Parameters:
        i - Any Java Iterable. The Java Object.toString() will be invoked on each of the elements produced by the Iterable, and commas shall be inserted between each element.

        NOTE: The symbols <?> appended to the (almost) 'raw-type' here, are only there to prevent the java-compiler from issuing warnings regarding the use of "Raw Types." This warning is, actually, only issued if the command-line option -Xlint:all option is used.
        trim - This is a boolean, and when set TRUE, the String.trim() shall be invoked on each String inserted into the CSV list before insertion.
        printNulls - This is a boolean, and when set TRUE, each object returned by the iterator shall be checked for a 'null' value before insertion into the output-String - to avoid null-pointer exceptions. Instead the four-character String 'null' will be inserted instead of throwing this exception.

        When this parameter receives FALSE, if the input parameter Iterable<?> i contains a null value, then this method will simply throw a NullPointerException.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        This will return a CSV String containing the individual elements of the input Iterable parameter 'i', where each element has been converted to a String and is separated by a comma.
        Throws:
        java.lang.NullPointerException - If the Iterable returns a null value, and the 'printNulls' parameter were set to FALSE, then this method would throw an exception.
        Code:
        Exact Method Body:
         StringBuilder   sb      = new StringBuilder();
         boolean         first   = true;
        
         if (trim && printNulls)
        
             for (Object o : i)
             {
                 if (o == null) o = "null";
        
                 sb.append((first ? "" : ", ") + o.toString().trim());
                 first = false;
             }
        
         else if (trim && (! printNulls))
        
             for (Object o : i)
             {
                 sb.append((first ? "" : ", ") + o.toString().trim());
                 first = false;
             }
        
         else if ((! trim) && printNulls)
        
             for (Object o : i)
             {
                 if (o == null) o = "null";
            
                 sb.append((first ? "" : ", ") + o.toString());
                 first = false;
             }
        
         else // !trim !printNulls
        
             for (Object o : i)
             {
                 sb.append((first ? "" : ", ") + o.toString());
                 first = false;
             }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
        
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static <T> java.lang.String toCSV​
                    (java.lang.Iterable<T> i,
                     java.util.function.Function<? super T,​java.lang.String> toString,
                     boolean printNulls,
                     java.lang.Integer maxLength)
        
        This method will turn the elements of any java Iterable type into a java.lang.String. The returned String shall have the individual elements of parameter 'i' converted to String's, each separated by a comma.
        Type Parameters:
        T - The type used by the java.lang.Iterable. The 'toString' parameter / function-pointer also must accept this type, or a super-type.
        Parameters:
        i - Any Java Iterable. The functional-interface parameter 'toString' will be invoked on each of the elements produced by the Iterable, and commas shall be inserted between each element.
        toString - This instance of java.util.function.Function<A, B> must have a method that accepts a parameter having type 'T', and returns a String. This is simply an "over-riding" of Java's basic 'toString()' method. In fact, if the class that is being used for variable-type parameter 'T' has a 'toString' method that is sufficient or "good enough", then this method should not be used, but rather the simpler method: toCSV(Iterable, boolean, boolean, Integer).
        printNulls - When this parameter is TRUE, the 'toString.apply(T)' method shall receive a null value, and the String results returned by this method shall be inserted into the output String when the input Iterable 'i' contains a null value. Thusly, the behavior of this method for 'nulls' in the input 'i' parameter should be no different than any other value found within the input Iterable 'i'.

        When this parameter receives FALSE, any time a null value is encountered from the input Iterable<T> 'i', that value shall be skipped and the output String that is returned will have one fewer element in it's CSV list.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        This will return a CSV String containing the individual elements of the input Iterable parameter 'i', where each element has been converted to a String - using the provided 'toString' function - and is separated by a comma.
        Code:
        Exact Method Body:
         StringBuilder   sb      = new StringBuilder();
         boolean         first   = true;
        
         if (printNulls)
        
             for (T t : i)
             {
                 sb.append((first ? "" : ", ") + toString.apply(t));
                 first = false;
             }
        
         else
        
             for (T t : i)
                 if (t != null)
                 {
                     sb.append((first ? "" : ", ") + toString.apply(t));
                     first = false;
                 }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
        
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static <T> java.lang.String toCSV​(T[] tArr,
                                                 int sPos,
                                                 int ePos,
                                                 boolean trim,
                                                 boolean printNulls,
                                                 java.lang.Integer maxLength)
        This method will turn the elements of any java Iterable type into a java.lang.String. The returned String shall have the individual elements of parameter 'i' converted to String's, each separated by a comma.
        Parameters:
        tArr - Any array type 'T'. Java's 'toString' method will be invoked on each of these elements, and returned in a String where each element has been separated by a comma.
        sPos - This is the (integer) Array-index that sets a limit for the left-most Array-position to inspect/search inside the input Array-parameter.

        This value is considered 'inclusive' meaning that the element at this Array-index will be visited by this method.

        NOTE: If this value is negative, or larger than the length of the input-Array, an exception will be thrown.
        ePos - This is the (integer) Array-index that sets a limit for the right-most Array-position to inspect/search inside the input Vector-parameter.

        This value is considered 'exclusive' meaning that the element at this Array-index will not be visited by this method.

        NOTE: If this value is larger than the length of input the Array-parameter, an exception will throw.

        ALSO: Passing a negative value to this parameter, 'ePos', will cause its value to be reset to the length of the input Array-parameter.
        trim - This is a boolean, and when set TRUE, the String.trim() shall be invoked on each String inserted into the CSV list before insertion.
        printNulls - This is a boolean, and when set TRUE, each instance of 'T' contained by 'tArr' shall be checked for a 'null' value before insertion into the output-String - to avoid null-pointer exceptions. If a null is found, the four-character String 'null' will be inserted instead of throwing this exception.

        When this parameter receives FALSE, if a null value is encountered within the input-parameter array T[] tArr, then this method will, in fact, throw a NullPointerException.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        This will return a CSV String containing the individual elements of the input array T[] tArr parameter, where each element shall have been converted to a String and separated by a comma.
        Throws:
        java.lang.NullPointerException - If the Iterable returns a null value, and the 'printNulls' parameter were set to FALSE, then this method would throw an exception.
        java.lang.ArrayIndexOutOfBoundsException - This exception shall be thrown if any of the following are true:

        • If 'sPos' is negative, or if sPos is greater-than-or-equal-to the length of the Array
        • If 'ePos' is zero, or greater than the length of the Array
        • If the value of 'sPos' is a larger integer than 'ePos'. If 'ePos' was negative, it is first reset to Array.length, before this check is done.
        Code:
        Exact Method Body:
         LV              l       = new LV(tArr, sPos, ePos);
         StringBuilder   sb      = new StringBuilder();
         boolean         first   = true;
        
         if (trim && printNulls)
        
             for (int i=l.start; i < l.end; i++)
             {
                 if (tArr[i] == null)
                     sb.append((first ? "" : ", ") + "null");
                 else
                     sb.append((first ? "" : ", ") + tArr[i].toString().trim());
                 first = false;
             }
        
         else if (trim && (! printNulls))
        
             for (int i=l.start; i < l.end; i++)
             {
                 sb.append((first ? "" : ", ") + tArr[i].toString().trim());
                 first = false;
             }
        
         else if ((! trim) && printNulls)
        
             for (int i=l.start; i < l.end; i++)
             {
                 if (tArr[i] == null)
                     sb.append((first ? "" : ", ") + "null");
                 else
                     sb.append((first ? "" : ", ") + tArr[i].toString());
                 first = false;
             }
        
         else // !trim !printNulls
        
             for (int i=l.start; i < l.end; i++)
             {
                 sb.append((first ? "" : ", ") + tArr[i].toString());
                 first = false;
             }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
        
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static <T> java.lang.String toCSV​
                    (T[] tArr,
                     int sPos,
                     int ePos,
                     IntTFunction<? super T,​java.lang.String> toString,
                     boolean printNulls,
                     java.lang.Integer maxLength)
        
        Converts an array of a variable-type parameter T[] to a CSV String

        This version of 'toCSV' allows a programmer to define the exact 'toString()' that is used on each object-instance in the provided array. There is a simpler version of this method where the invokation T.toString() is used instead.
        Type Parameters:
        T - The type used by the T[]-Array. The 'toString' parameter / function-pointer also must accept this type.
        Parameters:
        tArr - An array of Object's of a given variable-type 'T'
        sPos - This is the (integer) Array-index that sets a limit for the left-most Array-position to inspect/search inside the input Array-parameter.

        This value is considered 'inclusive' meaning that the element at this Array-index will be visited by this method.

        NOTE: If this value is negative, or larger than the length of the input-Array, an exception will be thrown.
        ePos - This is the (integer) Array-index that sets a limit for the right-most Array-position to inspect/search inside the input Vector-parameter.

        This value is considered 'exclusive' meaning that the element at this Array-index will not be visited by this method.

        NOTE: If this value is larger than the length of input the Array-parameter, an exception will throw.

        ALSO: Passing a negative value to this parameter, 'ePos', will cause its value to be reset to the length of the input Array-parameter.
        toString - A method that will convert Object's of type 'T' to a String. This parameter may not be null, because in such cases it would be appropriate to use: toCSV(Object[], int, int, boolean, boolean, Integer)

        NOTE: This functional-interface is used instead of simply calling Object.toString() in order to allow a programmer to provide arbitrarily defined toString() methods. If the standard toString() method for a given Object is not sufficient, then provide a different one here using this parameter.

        This 'toString' functional-interface is expected to accept both an instance of a type 'T' variable, AND an integer. The integer that is accepted is simply the array-index where the 'T' variable parameter is located within the array.

        NOTE: This function may return a zero-length String, and when/if it does, the Object located at that array-index shall not be printed to the output-String. Also, if this function ever returns null, then a NullPointerException shall throw immediately.
        printNulls - When this parameter is TRUE, if a null is encountered within the input-parameter array T[] tArr, then null shall be passed to the Functional Interface input-parameter method toString.apply(T), and the String result from that method shall be inserted into the String that is returned.

        When this parameter receives FALSE, then anytime a null value is found within the input-parameter array T[] tArr, it will be skipped completely, and the output String will simply contain one fewer output-String.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        a CSV version of the input parameter 'tArr' where each instance of 'T' shall have been converted to a String using the provided 'toString(...)' method.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - This exception shall be thrown if any of the following are true:

        • If 'sPos' is negative, or if sPos is greater-than-or-equal-to the length of the Array
        • If 'ePos' is zero, or greater than the length of the Array
        • If the value of 'sPos' is a larger integer than 'ePos'. If 'ePos' was negative, it is first reset to Array.length, before this check is done.
        java.lang.NullPointerException - if parameter 'toString' is null, or if any of the return values produced by 'toString' are null
        Code:
        Exact Method Body:
         LV              l   = new LV(tArr, sPos, ePos);
         StringBuilder   sb  = new StringBuilder();
         int             i   = l.start;
         String          s;
        
         if (printNulls)
         {
             for (; i < l.end; i++)
                 if ((s = toString.apply(i, tArr[i])).length() > 0)
                     { sb.append(s); break; }
        
             for (i++; i < l.end; i++)
                 if ((s = toString.apply(i, tArr[i])) == null)   throwNPE(i, tArr[i]);
                 else                                            sb.append(", " + s);
         }
        
         else
         {
             for (; i < l.end; i++)
                 if ((tArr[i] != null) && ((s = toString.apply(i, tArr[i])).length() > 0))
                     { sb.append(s); break; }
        
             for (i++; i < l.end; i++)
                 if (tArr[i] != null)
                     if ((s = toString.apply(i, tArr[i])) == null)   throwNPE(i, tArr[i]);
                     else                                            sb.append(", " + s);
         }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }      
        
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static <T> java.lang.String toCSV​
                    (T[][] tArr,
                     IntIntTFunc<? super T,​java.lang.String> toString,
                     java.util.function.IntPredicate keepRow,
                     boolean separateLines,
                     java.lang.Integer maxLengthInner,
                     java.lang.Integer maxLengthOuter)
        
        This class prints a two dimensional <T>-array to a String.
        Type Parameters:
        T - The type used by the T[][]-Array. The 'toString' parameter / function-pointer also must accept this type.
        Parameters:
        tArr - This may be any Java Two-Dimensional -array.
        toString - This Java Lambda (Functional Interface) Parameter is one which accepts two integers, and a primitive-. The integers provided shall contain the indices to an element of the 2D Array parameter, and the at that Array location. The toString.apply(int, int, ) method inside this lambda should return any Java String to be printed to the output, for the given array-location and value.

        NOTE: This lambda may return a zero-length String, and when or if it does, that particular array-location will be 'skipped' (not printed) to the output String.

        ALSO: This parameter may be null, and if it is, it will be ignored and all array-'s, themselves, will simply be printed to the output String instead.

        FINALLY: If this lambda's 'apply' function ever returns null, it will result in a NullPointerException
        keepRow - This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicate receives an 'int' that corresponds to the first-order array index (the outer-array-index, a.k.a. '[x][]'). When this lambda-Predicate returns TRUE the inner sub-array '[]' will be included in the output-String. When this lamda returns FALSE, the entire sub-array will be eliminated from the output-String.

        AGAIN: When this lamda-Predicate receives null, it is ignored, meaning all sub-arrays are printed to the output-String - or at least until maxLengthInner is reached!.
        separateLines - When this parameter receives TRUE, each of the sub-array's ([]) will be separated by a newline '\n' character. When this parameter is passed FALSE, all [] inner-arrays will be printed to a single-line of text.
        maxLengthInner - This parameter may be null, or negative, and if it is, it shall be ignored. Remember that Java Compiler syntax allows primitive-literals to be passed to function-parameters of type Integer. This means, you may pass '80' here, rather than worrying about passing Integer.valueOf(80). Again, you may also pass 'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.

        When this parameter receives a non-null int, its intention is to specify an output String's 'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximum String length' is reached, an ' ...' (ellipsis) is appended to the end of the printed-String, and the printing logic moves on to the next sub-array.

        NOTE: Unlike parameter maxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the output String - not the number array-element 's.

        FINALLY: Because the output-String sub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than '7'. If it is not, an IllegalArgumentException is thrown. Again, a negative value shall be treated the same as if 'null' were passed.
        maxLengthOuter - This parameter may be null, or negative, and if it is, it will be ignored.

        Again, Java compiler-syntax allows integer literals to be passed directly to this parameter.

        This 'maximum length' specifies how many of the sub-arrays will be printed to the Output-String. If there are more sub-arrays than the value passed to maxLengthOter, an elipsis ' ...' shall be appended to the end of the returned-String.

        NOTE: The meaning of this integer-value is different than that of parameter 'maxLengthInner'. Here, it is used to specify a maximum number of elements (specifically, 'sub-arrays'), while in 'maxLengthInner', it is meant to specify a maximum number of output characters (a.k.a. a String-length).

        Remember that printing a large-two dimensional array will will result in a very long String. In conjunction with the 'separateLines' paramater and/or empty-String return-values from the 'toString' lambda, the length of the output-String can be reasonably sized.
        Returns:
        A printed version of this two-dimensional array.
        Throws:
        java.lang.NullPointerException - If the 'toString' method is non-null, but returns a null value.
        java.lang.IllegalArgumentException - If 'maxLengthInner' is less than '7'.
        Code:
        Exact Method Body:
         // maxLengthInner *MUST* be >= 7, since minimum-string-length is "  [...]"
         // A value of 0 to 6 must throw an exception.
         // A negative value is treated the same as 'null'
        
         if ((maxLengthInner != null) && (maxLengthInner < 7) && (maxLengthInner >= 0))
        
             throw new IllegalArgumentException
                 (IAE_MESSAGE_MAXLENINNER.replace("TOK", maxLengthInner.toString()));
        
         else if ((maxLengthInner != null) && (maxLengthInner < 0)) maxLengthInner = null;
        
         StringBuilder   sbOuter = new StringBuilder();  // Primary StringBuilder
         StringBuilder   sbInner = new StringBuilder();  // StrinBuilder for the sub/inner arrays
         String          s       = null;                 // temp variable
         int             i       = 0;                    // outer-loop loop-counter
         int             numRows = 0;                    // Count sub-arrays
        
         // If the value passed to 'maxLengthOuter' is negative, treat it the same as 'null'
         // SPECIFICALLY: No Max Length.
        
         if ((maxLengthOuter != null) && (maxLengthOuter < 0)) maxLengthOuter = null;
        
         sbOuter.append('[');
        
         for (i=0; i < tArr.length; i++)
         {
             // The "Keep Row" Predicate is used to check whether a sub-array should even be
             // included at all.  If "Keep Row" exists, and it rejects the outer array index,
             // then the entire row itself should be skipped.
        
             if ((keepRow != null) && (! keepRow.test(i))) continue;
        
             numRows++;
             if ((maxLengthOuter != null) && (numRows > maxLengthOuter)) break;
        
             int j = 0;
        
             // System.out.println("end: " + end + ",\ti: " + i + ",\tj: " + j);
             // The purpose to this sub-loop is such that there is a "provided user option" where
             // the 'toString-lambda' may return a ZERO-LENGTH-STRING, and when this happens, the
             // array-location that resulted in a ZERO-LENGTH-STRING shall be ignored/skipped
             // completely.
        
             if (toString != null)
        
                 while (     (j < tArr[i].length)
                         &&  ((s = toString.apply(i, j, tArr[i][j])).length() == 0)
                 )
                     j++;
        
             else s = "" + tArr[i][j].toString();
        
             // If "separateLines" be sure to add a newline.
             if (separateLines) sbOuter.append('\n');
        
             // Add the opening brackets to this new sub-array that was just computed.
             sbInner.append(" [" + s);
             j++;
        
             // Main Printing Loop
             while (j < tArr[i].length)
             {
                 if (toString != null)
                 {
                     if ((s = toString.apply(i, j, tArr[i][j++])).length() > 0)
                         sbInner.append(", " + s);
                 }
        
                 else sbInner.append(", " + tArr[i][j++].toString());
        
                 if ((maxLengthInner != null) && (sbInner.length() > maxLengthInner)) break;
             }
        
             // NOTE: The '+ 1' is needed because, as of yet, the trailing ']' has not been added.
             if ((maxLengthInner != null) && ((sbInner.length() + 1) > maxLengthInner))
             {
                 int     pos = sbInner.length() - 4;
                 char    c   = sbInner.charAt(pos);
        
                 while ((c != ',') && (c != '[')) c = sbInner.charAt(--pos);
        
                 sbInner.setLength(pos+1);
                 sbInner.append((c == '[') ? "..." : " ...");
             }
        
             sbInner.append(']');
             sbOuter.append(sbInner.toString());
             sbInner.setLength(0);
         }
        
         // This shall only execute if the 
         if (i < tArr.length) sbOuter.append((separateLines ? "\n" : "") + "  ...");
        
         sbOuter.append(separateLines ? "\n]" : " ]");
            
         return sbOuter.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (byte[] arr,
                     int sPos,
                     int ePos,
                     IntByteFunction<java.lang.String> toString,
                     java.lang.Integer maxLength)
        
        This method shall separate the byte's from an input array by commas, and print them to a String (which it then returns). The user may specify a functional-interface so that the values inside the CSV-String are not just the array-byte's, themselves, but rather are any modification, or 'dressing up,' of those values as is neccessary.

        It is not mandatory to pass a 'toString' function-pointer to this method. This parameter may be null, and if it is it shall be ignored.
        Parameters:
        arr - Any array of byte.
        sPos - This is the (integer) Array-index that sets a limit for the left-most Array-position to inspect/search inside the input Array-parameter.

        This value is considered 'inclusive' meaning that the element at this Array-index will be visited by this method.

        NOTE: If this value is negative, or larger than the length of the input-Array, an exception will be thrown.
        ePos - This is the (integer) Array-index that sets a limit for the right-most Array-position to inspect/search inside the input Vector-parameter.

        This value is considered 'exclusive' meaning that the element at this Array-index will not be visited by this method.

        NOTE: If this value is larger than the length of input the Array-parameter, an exception will throw.

        ALSO: Passing a negative value to this parameter, 'ePos', will cause its value to be reset to the length of the input Array-parameter.
        toString - This should be an implementation of functional-interface IntByteFunction<String>. The expected inputs and outputs of this function are listed below:

        • Input 1: int i
          This input parameter shall receive the index of the array element being printed.

        • Input 2: byte b
          This input parameter shall receive the actual byte that is located at arr[i].

        • Output: String
          This output parameter must return any String the users wishes to be appended to the comma-separated output String for the passed IntByteFunction and array index.

          NOTE: If this function returns null, NullPointerException will throw, however when this function returns a zero-length String, for a particular array-index and byte combination, then that byte shall not be printed to the output String

        NOTE: This ('toString') parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-String that is returned will simply have the array-numbers themselves, unmodified, printed to the String, and separated by commas.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        A String that contains the byte elements of this array, separated by comma's. If a valid instance of IntByteFunction has been passed to parameter 'toString', then the output of that interface's 'apply(int, byte)' method will be returned, separated by commas.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - This exception shall be thrown if any of the following are true:

        • If 'sPos' is negative, or if sPos is greater-than-or-equal-to the length of the Array
        • If 'ePos' is zero, or greater than the length of the Array
        • If the value of 'sPos' is a larger integer than 'ePos'. If 'ePos' was negative, it is first reset to Array.length, before this check is done.
        java.lang.NullPointerException - If 'toString' returns a null value.
        Code:
        Exact Method Body:
         LV              l   = new LV(sPos, ePos, arr);
         StringBuilder   sb  = new StringBuilder();
         int             i   = l.start;
         String          s;
        
         if (toString == null)
         {
             sb.append(arr[i++]);
             while (i < l.end) sb.append(", " + arr[i++]);
         }
        
         else
         {
             for (; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])).length() > 0)
                     { sb.append(s); break; }
        
             for (i++; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])) == null)    throwNPE(i, arr[i]);
                 else                                            sb.append(", " + s);
         }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
            
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (short[] arr,
                     int sPos,
                     int ePos,
                     IntShortFunction<java.lang.String> toString,
                     java.lang.Integer maxLength)
        
        This method shall separate the short's from an input array by commas, and print them to a String (which it then returns). The user may specify a functional-interface so that the values inside the CSV-String are not just the array-short's, themselves, but rather are any modification, or 'dressing up,' of those values as is neccessary.

        It is not mandatory to pass a 'toString' function-pointer to this method. This parameter may be null, and if it is it shall be ignored.
        Parameters:
        arr - Any array of short-integers.
        sPos - This is the (integer) Array-index that sets a limit for the left-most Array-position to inspect/search inside the input Array-parameter.

        This value is considered 'inclusive' meaning that the element at this Array-index will be visited by this method.

        NOTE: If this value is negative, or larger than the length of the input-Array, an exception will be thrown.
        ePos - This is the (integer) Array-index that sets a limit for the right-most Array-position to inspect/search inside the input Vector-parameter.

        This value is considered 'exclusive' meaning that the element at this Array-index will not be visited by this method.

        NOTE: If this value is larger than the length of input the Array-parameter, an exception will throw.

        ALSO: Passing a negative value to this parameter, 'ePos', will cause its value to be reset to the length of the input Array-parameter.
        toString - This should be an implementation of functional-interface IntShortFunction<String>. The expected inputs and outputs of this function are listed below:

        • Input 1: int i
          This input parameter shall receive the index of the array element being printed.

        • Input 2: short s
          This input parameter shall receive the actual short that is located at arr[i].

        • Output: String
          This output parameter must return any String the users wishes to be appended to the comma-separated output String for the passed IntShortFunction and array index.

          NOTE: If this function returns null, NullPointerException will throw, however when this function returns a zero-length String, for a particular array-index and short combination, then that short shall not be printed to the output String

        NOTE: This ('toString') parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-String that is returned will simply have the array-numbers themselves, unmodified, printed to the String, and separated by commas.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        A String that contains the short elements of this array, separated by comma's. If a valid instance of IntShortFunction has been passed to parameter 'toString', then the output of that interface's 'apply(int, short)' method will be returned, separated by commas.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - This exception shall be thrown if any of the following are true:

        • If 'sPos' is negative, or if sPos is greater-than-or-equal-to the length of the Array
        • If 'ePos' is zero, or greater than the length of the Array
        • If the value of 'sPos' is a larger integer than 'ePos'. If 'ePos' was negative, it is first reset to Array.length, before this check is done.
        java.lang.NullPointerException - If 'toString' returns a null value.
        Code:
        Exact Method Body:
         LV              l   = new LV(sPos, ePos, arr);
         StringBuilder   sb  = new StringBuilder();
         int             i   = l.start;
         String          s;
        
         if (toString == null)
         {
             sb.append(arr[i++]);
             while (i < l.end) sb.append(", " + arr[i++]);
         }
        
         else
         {
             for (; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])).length() > 0)
                     { sb.append(s); break; }
        
             for (i++; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])) == null)    throwNPE(i, arr[i]);
                 else                                            sb.append(", " + s);
         }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
        
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (int[] arr,
                     int sPos,
                     int ePos,
                     BiIntFunction<java.lang.String> toString,
                     java.lang.Integer maxLength)
        
        This method shall separate the int's from an input array by commas, and print them to a String (which it then returns). The user may specify a functional-interface so that the values inside the CSV-String are not just the array-int's, themselves, but rather are any modification, or 'dressing up,' of those values as is neccessary.

        It is not mandatory to pass a 'toString' function-pointer to this method. This parameter may be null, and if it is it shall be ignored.
        Parameters:
        arr - Any array of integers.
        sPos - This is the (integer) Array-index that sets a limit for the left-most Array-position to inspect/search inside the input Array-parameter.

        This value is considered 'inclusive' meaning that the element at this Array-index will be visited by this method.

        NOTE: If this value is negative, or larger than the length of the input-Array, an exception will be thrown.
        ePos - This is the (integer) Array-index that sets a limit for the right-most Array-position to inspect/search inside the input Vector-parameter.

        This value is considered 'exclusive' meaning that the element at this Array-index will not be visited by this method.

        NOTE: If this value is larger than the length of input the Array-parameter, an exception will throw.

        ALSO: Passing a negative value to this parameter, 'ePos', will cause its value to be reset to the length of the input Array-parameter.
        toString - This should be an implementation of functional-interface BiIntFunction<String>. The expected inputs and outputs of this function are listed below:

        • Input 1: int i
          This input parameter shall receive the index of the array element being printed.

        • Input 2: int j
          This input parameter shall receive the actual int that is located at arr[i].

        • Output: String
          This output parameter must return any String the users wishes to be appended to the comma-separated output String for the passed BiIntFunction and array index.

          NOTE: If this function returns null, NullPointerException will throw, however when this function returns a zero-length String, for a particular array-index and int combination, then that int shall not be printed to the output String

        NOTE: This ('toString') parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-String that is returned will simply have the array-numbers themselves, unmodified, printed to the String, and separated by commas.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        A String that contains the int elements of this array, separated by comma's. If a valid instance of BiIntFunction has been passed to parameter 'toString', then the output of that interface's 'apply(int, int)' method will be returned, separated by commas.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - This exception shall be thrown if any of the following are true:

        • If 'sPos' is negative, or if sPos is greater-than-or-equal-to the length of the Array
        • If 'ePos' is zero, or greater than the length of the Array
        • If the value of 'sPos' is a larger integer than 'ePos'. If 'ePos' was negative, it is first reset to Array.length, before this check is done.
        java.lang.NullPointerException - If 'toString' returns a null value.
        Code:
        Exact Method Body:
         LV              l   = new LV(sPos, ePos, arr);
         StringBuilder   sb  = new StringBuilder();
         int             i   = l.start;
         String          s;
        
         if (toString == null)
         {
             sb.append(arr[i++]);
             while (i < l.end) sb.append(", " + arr[i++]);
         }
        
         else
         {
             for (; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])).length() > 0)
                     { sb.append(s); break; }
        
             for (i++; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])) == null)    throwNPE(i, arr[i]);
                 else                                            sb.append(", " + s);
         }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
        
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (long[] arr,
                     int sPos,
                     int ePos,
                     IntLongFunction<java.lang.String> toString,
                     java.lang.Integer maxLength)
        
        This method shall separate the long's from an input array by commas, and print them to a String (which it then returns). The user may specify a functional-interface so that the values inside the CSV-String are not just the array-long's, themselves, but rather are any modification, or 'dressing up,' of those values as is neccessary.

        It is not mandatory to pass a 'toString' function-pointer to this method. This parameter may be null, and if it is it shall be ignored.
        Parameters:
        arr - Any array of long-integers.
        sPos - This is the (integer) Array-index that sets a limit for the left-most Array-position to inspect/search inside the input Array-parameter.

        This value is considered 'inclusive' meaning that the element at this Array-index will be visited by this method.

        NOTE: If this value is negative, or larger than the length of the input-Array, an exception will be thrown.
        ePos - This is the (integer) Array-index that sets a limit for the right-most Array-position to inspect/search inside the input Vector-parameter.

        This value is considered 'exclusive' meaning that the element at this Array-index will not be visited by this method.

        NOTE: If this value is larger than the length of input the Array-parameter, an exception will throw.

        ALSO: Passing a negative value to this parameter, 'ePos', will cause its value to be reset to the length of the input Array-parameter.
        toString - This should be an implementation of functional-interface IntLongFunction<String>. The expected inputs and outputs of this function are listed below:

        • Input 1: int i
          This input parameter shall receive the index of the array element being printed.

        • Input 2: long l
          This input parameter shall receive the actual long that is located at arr[i].

        • Output: String
          This output parameter must return any String the users wishes to be appended to the comma-separated output String for the passed IntLongFunction and array index.

          NOTE: If this function returns null, NullPointerException will throw, however when this function returns a zero-length String, for a particular array-index and long combination, then that long shall not be printed to the output String

        NOTE: This ('toString') parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-String that is returned will simply have the array-numbers themselves, unmodified, printed to the String, and separated by commas.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        A String that contains the long elements of this array, separated by comma's. If a valid instance of IntLongFunction has been passed to parameter 'toString', then the output of that interface's 'apply(int, long)' method will be returned, separated by commas.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - This exception shall be thrown if any of the following are true:

        • If 'sPos' is negative, or if sPos is greater-than-or-equal-to the length of the Array
        • If 'ePos' is zero, or greater than the length of the Array
        • If the value of 'sPos' is a larger integer than 'ePos'. If 'ePos' was negative, it is first reset to Array.length, before this check is done.
        java.lang.NullPointerException - If 'toString' returns a null value.
        Code:
        Exact Method Body:
         LV              l   = new LV(sPos, ePos, arr);
         StringBuilder   sb  = new StringBuilder();
         int             i   = l.start;
         String          s;
        
         if (toString == null)
         {
             sb.append(arr[i++]);
             while (i < l.end) sb.append(", " + arr[i++]);
         }
        
         else
         {
             for (; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])).length() > 0)
                     { sb.append(s); break; }
        
             for (i++; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])) == null)    throwNPE(i, arr[i]);
                 else                                            sb.append(", " + s);
         }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
        
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (float[] arr,
                     int sPos,
                     int ePos,
                     IntFloatFunction<java.lang.String> toString,
                     java.lang.Integer maxLength)
        
        This method shall separate the float's from an input array by commas, and print them to a String (which it then returns). The user may specify a functional-interface so that the values inside the CSV-String are not just the array-float's, themselves, but rather are any modification, or 'dressing up,' of those values as is neccessary.

        It is not mandatory to pass a 'toString' function-pointer to this method. This parameter may be null, and if it is it shall be ignored.
        Parameters:
        arr - Any array of float.
        sPos - This is the (integer) Array-index that sets a limit for the left-most Array-position to inspect/search inside the input Array-parameter.

        This value is considered 'inclusive' meaning that the element at this Array-index will be visited by this method.

        NOTE: If this value is negative, or larger than the length of the input-Array, an exception will be thrown.
        ePos - This is the (integer) Array-index that sets a limit for the right-most Array-position to inspect/search inside the input Vector-parameter.

        This value is considered 'exclusive' meaning that the element at this Array-index will not be visited by this method.

        NOTE: If this value is larger than the length of input the Array-parameter, an exception will throw.

        ALSO: Passing a negative value to this parameter, 'ePos', will cause its value to be reset to the length of the input Array-parameter.
        toString - This should be an implementation of functional-interface IntFloatFunction<String>. The expected inputs and outputs of this function are listed below:

        • Input 1: int i
          This input parameter shall receive the index of the array element being printed.

        • Input 2: float f
          This input parameter shall receive the actual float that is located at arr[i].

        • Output: String
          This output parameter must return any String the users wishes to be appended to the comma-separated output String for the passed IntFloatFunction and array index.

          NOTE: If this function returns null, NullPointerException will throw, however when this function returns a zero-length String, for a particular array-index and float combination, then that float shall not be printed to the output String

        NOTE: This ('toString') parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-String that is returned will simply have the array-numbers themselves, unmodified, printed to the String, and separated by commas.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        A String that contains the float elements of this array, separated by comma's. If a valid instance of IntFloatFunction has been passed to parameter 'toString', then the output of that interface's 'apply(int, float)' method will be returned, separated by commas.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - This exception shall be thrown if any of the following are true:

        • If 'sPos' is negative, or if sPos is greater-than-or-equal-to the length of the Array
        • If 'ePos' is zero, or greater than the length of the Array
        • If the value of 'sPos' is a larger integer than 'ePos'. If 'ePos' was negative, it is first reset to Array.length, before this check is done.
        java.lang.NullPointerException - If 'toString' returns a null value.
        Code:
        Exact Method Body:
         LV              l   = new LV(sPos, ePos, arr);
         StringBuilder   sb  = new StringBuilder();
         int             i   = l.start;
         String          s;
        
         if (toString == null)
         {
             sb.append(arr[i++]);
             while (i < l.end) sb.append(", " + arr[i++]);
         }
        
         else
         {
             for (; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])).length() > 0)
                     { sb.append(s); break; }
        
             for (i++; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])) == null)    throwNPE(i, arr[i]);
                 else                                            sb.append(", " + s);
         }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
            
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (double[] arr,
                     int sPos,
                     int ePos,
                     IntDoubleFunction<java.lang.String> toString,
                     java.lang.Integer maxLength)
        
        This method shall separate the double's from an input array by commas, and print them to a String (which it then returns). The user may specify a functional-interface so that the values inside the CSV-String are not just the array-double's, themselves, but rather are any modification, or 'dressing up,' of those values as is neccessary.

        It is not mandatory to pass a 'toString' function-pointer to this method. This parameter may be null, and if it is it shall be ignored.
        Parameters:
        arr - Any array of double.
        sPos - This is the (integer) Array-index that sets a limit for the left-most Array-position to inspect/search inside the input Array-parameter.

        This value is considered 'inclusive' meaning that the element at this Array-index will be visited by this method.

        NOTE: If this value is negative, or larger than the length of the input-Array, an exception will be thrown.
        ePos - This is the (integer) Array-index that sets a limit for the right-most Array-position to inspect/search inside the input Vector-parameter.

        This value is considered 'exclusive' meaning that the element at this Array-index will not be visited by this method.

        NOTE: If this value is larger than the length of input the Array-parameter, an exception will throw.

        ALSO: Passing a negative value to this parameter, 'ePos', will cause its value to be reset to the length of the input Array-parameter.
        toString - This should be an implementation of functional-interface IntDoubleFunction<String>. The expected inputs and outputs of this function are listed below:

        • Input 1: int i
          This input parameter shall receive the index of the array element being printed.

        • Input 2: double d
          This input parameter shall receive the actual double that is located at arr[i].

        • Output: String
          This output parameter must return any String the users wishes to be appended to the comma-separated output String for the passed IntDoubleFunction and array index.

          NOTE: If this function returns null, NullPointerException will throw, however when this function returns a zero-length String, for a particular array-index and double combination, then that double shall not be printed to the output String

        NOTE: This ('toString') parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-String that is returned will simply have the array-numbers themselves, unmodified, printed to the String, and separated by commas.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        A String that contains the double elements of this array, separated by comma's. If a valid instance of IntDoubleFunction has been passed to parameter 'toString', then the output of that interface's 'apply(int, double)' method will be returned, separated by commas.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - This exception shall be thrown if any of the following are true:

        • If 'sPos' is negative, or if sPos is greater-than-or-equal-to the length of the Array
        • If 'ePos' is zero, or greater than the length of the Array
        • If the value of 'sPos' is a larger integer than 'ePos'. If 'ePos' was negative, it is first reset to Array.length, before this check is done.
        java.lang.NullPointerException - If 'toString' returns a null value.
        Code:
        Exact Method Body:
         LV              l   = new LV(sPos, ePos, arr);
         StringBuilder   sb  = new StringBuilder();
         int             i   = l.start;
         String          s;
        
         if (toString == null)
         {
             sb.append(arr[i++]);
             while (i < l.end) sb.append(", " + arr[i++]);
         }
        
         else
         {
             for (; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])).length() > 0)
                     { sb.append(s); break; }
        
             for (i++; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])) == null)    throwNPE(i, arr[i]);
                 else                                            sb.append(", " + s);
         }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
            
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (boolean[] arr,
                     int sPos,
                     int ePos,
                     IntBoolFunction<java.lang.String> toString,
                     java.lang.Integer maxLength)
        
        This method shall separate the boolean's from an input array by commas, and print them to a String (which it then returns). The user may specify a functional-interface so that the values inside the CSV-String are not just the array-boolean's, themselves, but rather are any modification, or 'dressing up,' of those values as is neccessary.

        It is not mandatory to pass a 'toString' function-pointer to this method. This parameter may be null, and if it is it shall be ignored.
        Parameters:
        arr - Any array of boolean.
        sPos - This is the (integer) Array-index that sets a limit for the left-most Array-position to inspect/search inside the input Array-parameter.

        This value is considered 'inclusive' meaning that the element at this Array-index will be visited by this method.

        NOTE: If this value is negative, or larger than the length of the input-Array, an exception will be thrown.
        ePos - This is the (integer) Array-index that sets a limit for the right-most Array-position to inspect/search inside the input Vector-parameter.

        This value is considered 'exclusive' meaning that the element at this Array-index will not be visited by this method.

        NOTE: If this value is larger than the length of input the Array-parameter, an exception will throw.

        ALSO: Passing a negative value to this parameter, 'ePos', will cause its value to be reset to the length of the input Array-parameter.
        toString - This should be an implementation of functional-interface IntBoolFunction<String>. The expected inputs and outputs of this function are listed below:

        • Input 1: int i
          This input parameter shall receive the index of the array element being printed.

        • Input 2: boolean b
          This input parameter shall receive the actual boolean that is located at arr[i].

        • Output: String
          This output parameter must return any String the users wishes to be appended to the comma-separated output String for the passed IntBoolFunction and array index.

          NOTE: If this function returns null, NullPointerException will throw, however when this function returns a zero-length String, for a particular array-index and boolean combination, then that boolean shall not be printed to the output String

        NOTE: This ('toString') parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-String that is returned will simply have the array-booleans themselves, unmodified, printed to the String, and separated by commas.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        A String that contains the boolean elements of this array, separated by comma's. If a valid instance of IntBoolFunction has been passed to parameter 'toString', then the output of that interface's 'apply(int, boolean)' method will be returned, separated by commas.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - This exception shall be thrown if any of the following are true:

        • If 'sPos' is negative, or if sPos is greater-than-or-equal-to the length of the Array
        • If 'ePos' is zero, or greater than the length of the Array
        • If the value of 'sPos' is a larger integer than 'ePos'. If 'ePos' was negative, it is first reset to Array.length, before this check is done.
        java.lang.NullPointerException - If 'toString' returns a null value.
        Code:
        Exact Method Body:
         LV              l   = new LV(sPos, ePos, arr);
         StringBuilder   sb  = new StringBuilder();
         int             i   = l.start;
         String          s;
        
         if (toString == null)
         {
             sb.append(arr[i++]);
             while (i < l.end) sb.append(", " + arr[i++]);
         }
        
         else
         {
             for (; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])).length() > 0)
                     { sb.append(s); break; }
        
             for (i++; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])) == null)    throwNPE(i, arr[i]);
                 else                                            sb.append(", " + s);
         }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
            
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (char[] arr,
                     int sPos,
                     int ePos,
                     IntCharFunction<java.lang.String> toString,
                     java.lang.Integer maxLength)
        
        This method shall separate the char's from an input array by commas, and print them to a String (which it then returns). The user may specify a functional-interface so that the values inside the CSV-String are not just the array-char's, themselves, but rather are any modification, or 'dressing up,' of those values as is neccessary.

        It is not mandatory to pass a 'toString' function-pointer to this method. This parameter may be null, and if it is it shall be ignored.
        Parameters:
        arr - Any array of boolean.
        sPos - This is the (integer) Array-index that sets a limit for the left-most Array-position to inspect/search inside the input Array-parameter.

        This value is considered 'inclusive' meaning that the element at this Array-index will be visited by this method.

        NOTE: If this value is negative, or larger than the length of the input-Array, an exception will be thrown.
        ePos - This is the (integer) Array-index that sets a limit for the right-most Array-position to inspect/search inside the input Vector-parameter.

        This value is considered 'exclusive' meaning that the element at this Array-index will not be visited by this method.

        NOTE: If this value is larger than the length of input the Array-parameter, an exception will throw.

        ALSO: Passing a negative value to this parameter, 'ePos', will cause its value to be reset to the length of the input Array-parameter.
        toString - This should be an implementation of functional-interface IntCharFunction<String>. The expected inputs and outputs of this function are listed below:

        • Input 1: int i
          This input parameter shall receive the index of the array element being printed.

        • Input 2: char c
          This input parameter shall receive the actual char that is located at arr[i].

        • Output: String
          This output parameter must return any String the users wishes to be appended to the comma-separated output String for the passed IntCharFunction and array index.

          NOTE: If this function returns null, NullPointerException will throw, however when this function returns a zero-length String, for a particular array-index and char combination, then that char shall not be printed to the output String

        NOTE: This ('toString') parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-String that is returned will simply have the array-characters themselves, unmodified, printed to the String, and separated by commas.
        maxLength - Allows a user request that the returned String have length no longer than 'maxLength' characters. If the final-computed CSV-String is longer than this parameter's value, it will be truncated to maxLength - 4, and ' ...' will be appended, instead, to the end of the return-String.

        NOTE: This parameter may be null, or negative, and if it is, it shall simply be ignored, and the fully-computed CSV-String returned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int' variable or literal to be passed to method-parameters of type java.lang.Integer. For example '80' could be passed to this parameter, directly, instead of 'Integer.valueOf(80)'. (Again null may also be passed.)
        Returns:
        A String that contains the char elements of this array, separated by comma's. If a valid instance of IntCharFunction has been passed to parameter 'toString', then the output of that interface's 'apply(int, char)' method will be returned, separated by commas.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - This exception shall be thrown if any of the following are true:

        • If 'sPos' is negative, or if sPos is greater-than-or-equal-to the length of the Array
        • If 'ePos' is zero, or greater than the length of the Array
        • If the value of 'sPos' is a larger integer than 'ePos'. If 'ePos' was negative, it is first reset to Array.length, before this check is done.
        java.lang.NullPointerException - If 'toString' returns a null value.
        Code:
        Exact Method Body:
         LV              l   = new LV(sPos, ePos, arr);
         StringBuilder   sb  = new StringBuilder();
         int             i   = l.start;
         String          s;
        
         if (toString == null)
         {
             sb.append(arr[i++]);
             while (i < l.end) sb.append(", " + arr[i++]);
         }
        
         else
         {
             for (i=l.start; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])).length() > 0)
                     { sb.append(s); break; }
        
             for (i++; i < l.end; i++)
                 if ((s = toString.apply(i, arr[i])) == null)    throwNPE(i, arr[i]);
                 else                                            sb.append(", " + s);
         }
        
         if ((maxLength != null) && (sb.length() > maxLength.intValue()))
         {
             sb.setLength(maxLength - 4);
             sb.append(" ...");
        
             return sb.toString();
         }
            
         return sb.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (byte[][] arr,
                     IntIntByteFunc<java.lang.String> toString,
                     java.util.function.IntPredicate keepRow,
                     boolean separateLines,
                     java.lang.Integer maxLengthInner,
                     java.lang.Integer maxLengthOuter)
        
        This class prints a two dimensional byte-array to a String.
        Parameters:
        arr - This may be any Java Two-Dimensional byte-array.
        toString - This Java Lambda (Functional Interface) Parameter is one which accepts two integers, and a primitive-byte. The integers provided shall contain the indices to an element of the 2D Array parameter, and the byte at that Array location. The toString.apply(int, int, byte) method inside this lambda should return any Java String to be printed to the output, for the given array-location and value.

        NOTE: This lambda may return a zero-length String, and when or if it does, that particular array-location will be 'skipped' (not printed) to the output String.

        ALSO: This parameter may be null, and if it is, it will be ignored and all array-byte's, themselves, will simply be printed to the output String instead.

        FINALLY: If this lambda's 'apply' function ever returns null, it will result in a NullPointerException
        keepRow - This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicate receives an 'int' that corresponds to the first-order array index (the outer-array-index, a.k.a. 'byte[x][]'). When this lambda-Predicate returns TRUE the inner sub-array 'byte[]' will be included in the output-String. When this lamda returns FALSE, the entire sub-array will be eliminated from the output-String.

        AGAIN: When this lamda-Predicate receives null, it is ignored, meaning all sub-arrays are printed to the output-String - or at least until maxLengthInner is reached!.
        separateLines - When this parameter receives TRUE, each of the sub-array's (byte[]) will be separated by a newline '\n' character. When this parameter is passed FALSE, all byte[] inner-arrays will be printed to a single-line of text.
        maxLengthInner - This parameter may be null, or negative, and if it is, it shall be ignored. Remember that Java Compiler syntax allows primitive-literals to be passed to function-parameters of type Integer. This means, you may pass '80' here, rather than worrying about passing Integer.valueOf(80). Again, you may also pass 'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.

        When this parameter receives a non-null int, its intention is to specify an output String's 'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximum String length' is reached, an ' ...' (ellipsis) is appended to the end of the printed-String, and the printing logic moves on to the next sub-array.

        NOTE: Unlike parameter maxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the output String - not the number array-element byte's.

        FINALLY: Because the output-String sub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than '7'. If it is not, an IllegalArgumentException is thrown. Again, a negative value shall be treated the same as if 'null' were passed.
        maxLengthOuter - This parameter may be null, or negative, and if it is, it will be ignored.

        Again, Java compiler-syntax allows integer literals to be passed directly to this parameter.

        This 'maximum length' specifies how many of the sub-arrays will be printed to the Output-String. If there are more sub-arrays than the value passed to maxLengthOter, an elipsis ' ...' shall be appended to the end of the returned-String.

        NOTE: The meaning of this integer-value is different than that of parameter 'maxLengthInner'. Here, it is used to specify a maximum number of elements (specifically, 'sub-arrays'), while in 'maxLengthInner', it is meant to specify a maximum number of output characters (a.k.a. a String-length).

        Remember that printing a large-two dimensional array will will result in a very long String. In conjunction with the 'separateLines' paramater and/or empty-String return-values from the 'toString' lambda, the length of the output-String can be reasonably sized.
        Returns:
        A printed version of this two-dimensional array.
        Throws:
        java.lang.NullPointerException - If the 'toString' method is non-null, but returns a null value.
        java.lang.IllegalArgumentException - If 'maxLengthInner' is less than '7'.
        Code:
        Exact Method Body:
         // maxLengthInner *MUST* be >= 7, since minimum-string-length is "  [...]"
         // A value of 0 to 6 must throw an exception.
         // A negative value is treated the same as 'null'
        
         if ((maxLengthInner != null) && (maxLengthInner < 7) && (maxLengthInner >= 0))
        
             throw new IllegalArgumentException
                 (IAE_MESSAGE_MAXLENINNER.replace("TOK", maxLengthInner.toString()));
        
         else if ((maxLengthInner != null) && (maxLengthInner < 0)) maxLengthInner = null;
        
         StringBuilder   sbOuter = new StringBuilder();  // Primary StringBuilder
         StringBuilder   sbInner = new StringBuilder();  // StrinBuilder for the sub/inner arrays
         String          s       = null;                 // temp variable
         int             i       = 0;                    // outer-loop loop-counter
         int             numRows = 0;                    // Count sub-arrays
        
         // If the value passed to 'maxLengthOuter' is negative, treat it the same as 'null'
         // SPECIFICALLY: No Max Length.
        
         if ((maxLengthOuter != null) && (maxLengthOuter < 0)) maxLengthOuter = null;
        
         sbOuter.append('[');
        
         for (i=0; i < arr.length; i++)
         {
             // The "Keep Row" Predicate is used to check whether a sub-array should even be
             // included at all.  If "Keep Row" exists, and it rejects the outer array index,
             // then the entire row itself should be skipped.
        
             if ((keepRow != null) && (! keepRow.test(i))) continue;
        
             numRows++;
             if ((maxLengthOuter != null) && (numRows > maxLengthOuter)) break;
        
             int j = 0;
        
             // System.out.println("end: " + end + ",\ti: " + i + ",\tj: " + j);
             // The purpose to this sub-loop is such that there is a "provided user option" where
             // the 'toString-lambda' may return a ZERO-LENGTH-STRING, and when this happens, the
             // array-location that resulted in a ZERO-LENGTH-STRING shall be ignored/skipped
             // completely.
        
             if (toString != null)
        
                 while (     (j < arr[i].length)
                         && ((s = toString.apply(i, j, arr[i][j])).length() == 0)
                 )
                     j++;
        
             else s = "" + arr[i][j];
        
             // If "separateLines" be sure to add a newline.
             if (separateLines) sbOuter.append('\n');
        
             // Add the opening brackets to this new sub-array that was just computed.
             sbInner.append(" [" + s);
             j++;
        
             // Main Printing Loop
             while (j < arr[i].length)
             {
                 if (toString != null)
                 {
                     if ((s = toString.apply(i, j, arr[i][j++])).length() > 0)
                         sbInner.append(", " + s);
                 }
        
                 else sbInner.append(", " + arr[i][j++]);
        
                 if ((maxLengthInner != null) && (sbInner.length() > maxLengthInner)) break;
             }
        
             // NOTE: The '+ 1' is needed because, as of yet, the trailing ']' has not been added.
             if ((maxLengthInner != null) && ((sbInner.length() + 1) > maxLengthInner))
             {
                 int     pos = sbInner.length() - 4;
                 char    c   = sbInner.charAt(pos);
        
                 while ((c != ',') && (c != '[')) c = sbInner.charAt(--pos);
        
                 sbInner.setLength(pos+1);
                 sbInner.append((c == '[') ? "..." : " ...");
             }
        
             sbInner.append(']');
             sbOuter.append(sbInner.toString());
             sbInner.setLength(0);
         }
        
         // This shall only execute if the 
         if (i < arr.length) sbOuter.append((separateLines ? "\n" : "") + "  ...");
        
         sbOuter.append(separateLines ? "\n]" : " ]");
            
         return sbOuter.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (short[][] arr,
                     IntIntShortFunc<java.lang.String> toString,
                     java.util.function.IntPredicate keepRow,
                     boolean separateLines,
                     java.lang.Integer maxLengthInner,
                     java.lang.Integer maxLengthOuter)
        
        This class prints a two dimensional short-array to a String.
        Parameters:
        arr - This may be any Java Two-Dimensional short-array.
        toString - This Java Lambda (Functional Interface) Parameter is one which accepts two integers, and a primitive-short. The integers provided shall contain the indices to an element of the 2D Array parameter, and the short at that Array location. The toString.apply(int, int, short) method inside this lambda should return any Java String to be printed to the output, for the given array-location and value.

        NOTE: This lambda may return a zero-length String, and when or if it does, that particular array-location will be 'skipped' (not printed) to the output String.

        ALSO: This parameter may be null, and if it is, it will be ignored and all array-short's, themselves, will simply be printed to the output String instead.

        FINALLY: If this lambda's 'apply' function ever returns null, it will result in a NullPointerException
        keepRow - This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicate receives an 'int' that corresponds to the first-order array index (the outer-array-index, a.k.a. 'short[x][]'). When this lambda-Predicate returns TRUE the inner sub-array 'short[]' will be included in the output-String. When this lamda returns FALSE, the entire sub-array will be eliminated from the output-String.

        AGAIN: When this lamda-Predicate receives null, it is ignored, meaning all sub-arrays are printed to the output-String - or at least until maxLengthInner is reached!.
        separateLines - When this parameter receives TRUE, each of the sub-array's (short[]) will be separated by a newline '\n' character. When this parameter is passed FALSE, all short[] inner-arrays will be printed to a single-line of text.
        maxLengthInner - This parameter may be null, or negative, and if it is, it shall be ignored. Remember that Java Compiler syntax allows primitive-literals to be passed to function-parameters of type Integer. This means, you may pass '80' here, rather than worrying about passing Integer.valueOf(80). Again, you may also pass 'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.

        When this parameter receives a non-null int, its intention is to specify an output String's 'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximum String length' is reached, an ' ...' (ellipsis) is appended to the end of the printed-String, and the printing logic moves on to the next sub-array.

        NOTE: Unlike parameter maxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the output String - not the number array-element short's.

        FINALLY: Because the output-String sub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than '7'. If it is not, an IllegalArgumentException is thrown. Again, a negative value shall be treated the same as if 'null' were passed.
        maxLengthOuter - This parameter may be null, or negative, and if it is, it will be ignored.

        Again, Java compiler-syntax allows integer literals to be passed directly to this parameter.

        This 'maximum length' specifies how many of the sub-arrays will be printed to the Output-String. If there are more sub-arrays than the value passed to maxLengthOter, an elipsis ' ...' shall be appended to the end of the returned-String.

        NOTE: The meaning of this integer-value is different than that of parameter 'maxLengthInner'. Here, it is used to specify a maximum number of elements (specifically, 'sub-arrays'), while in 'maxLengthInner', it is meant to specify a maximum number of output characters (a.k.a. a String-length).

        Remember that printing a large-two dimensional array will will result in a very long String. In conjunction with the 'separateLines' paramater and/or empty-String return-values from the 'toString' lambda, the length of the output-String can be reasonably sized.
        Returns:
        A printed version of this two-dimensional array.
        Throws:
        java.lang.NullPointerException - If the 'toString' method is non-null, but returns a null value.
        java.lang.IllegalArgumentException - If 'maxLengthInner' is less than '7'.
        Code:
        Exact Method Body:
         // maxLengthInner *MUST* be >= 7, since minimum-string-length is "  [...]"
         // A value of 0 to 6 must throw an exception.
         // A negative value is treated the same as 'null'
        
         if ((maxLengthInner != null) && (maxLengthInner < 7) && (maxLengthInner >= 0))
        
             throw new IllegalArgumentException
                 (IAE_MESSAGE_MAXLENINNER.replace("TOK", maxLengthInner.toString()));
        
         else if ((maxLengthInner != null) && (maxLengthInner < 0)) maxLengthInner = null;
        
         StringBuilder   sbOuter = new StringBuilder();  // Primary StringBuilder
         StringBuilder   sbInner = new StringBuilder();  // StrinBuilder for the sub/inner arrays
         String          s       = null;                 // temp variable
         int             i       = 0;                    // outer-loop loop-counter
         int             numRows = 0;                    // Count sub-arrays
        
         // If the value passed to 'maxLengthOuter' is negative, treat it the same as 'null'
         // SPECIFICALLY: No Max Length.
        
         if ((maxLengthOuter != null) && (maxLengthOuter < 0)) maxLengthOuter = null;
        
         sbOuter.append('[');
        
         for (i=0; i < arr.length; i++)
         {
             // The "Keep Row" Predicate is used to check whether a sub-array should even be
             // included at all.  If "Keep Row" exists, and it rejects the outer array index,
             // then the entire row itself should be skipped.
        
             if ((keepRow != null) && (! keepRow.test(i))) continue;
        
             numRows++;
             if ((maxLengthOuter != null) && (numRows > maxLengthOuter)) break;
        
             int j = 0;
        
             // System.out.println("end: " + end + ",\ti: " + i + ",\tj: " + j);
             // The purpose to this sub-loop is such that there is a "provided user option" where
             // the 'toString-lambda' may return a ZERO-LENGTH-STRING, and when this happens, the
             // array-location that resulted in a ZERO-LENGTH-STRING shall be ignored/skipped
             // completely.
        
             if (toString != null)
        
                 while (     (j < arr[i].length)
                         && ((s = toString.apply(i, j, arr[i][j])).length() == 0)
                 )
                     j++;
        
             else s = "" + arr[i][j];
        
             // If "separateLines" be sure to add a newline.
             if (separateLines) sbOuter.append('\n');
        
             // Add the opening brackets to this new sub-array that was just computed.
             sbInner.append(" [" + s);
             j++;
        
             // Main Printing Loop
             while (j < arr[i].length)
             {
                 if (toString != null)
                 {
                     if ((s = toString.apply(i, j, arr[i][j++])).length() > 0)
                         sbInner.append(", " + s);
                 }
        
                 else sbInner.append(", " + arr[i][j++]);
        
                 if ((maxLengthInner != null) && (sbInner.length() > maxLengthInner)) break;
             }
        
             // NOTE: The '+ 1' is needed because, as of yet, the trailing ']' has not been added.
             if ((maxLengthInner != null) && ((sbInner.length() + 1) > maxLengthInner))
             {
                 int     pos = sbInner.length() - 4;
                 char    c   = sbInner.charAt(pos);
        
                 while ((c != ',') && (c != '[')) c = sbInner.charAt(--pos);
        
                 sbInner.setLength(pos+1);
                 sbInner.append((c == '[') ? "..." : " ...");
             }
        
             sbInner.append(']');
             sbOuter.append(sbInner.toString());
             sbInner.setLength(0);
         }
        
         // This shall only execute if the 
         if (i < arr.length) sbOuter.append((separateLines ? "\n" : "") + "  ...");
        
         sbOuter.append(separateLines ? "\n]" : " ]");
            
         return sbOuter.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (int[][] arr,
                     TriIntFunc<java.lang.String> toString,
                     java.util.function.IntPredicate keepRow,
                     boolean separateLines,
                     java.lang.Integer maxLengthInner,
                     java.lang.Integer maxLengthOuter)
        
        This class prints a two dimensional int-array to a String.
        Parameters:
        arr - This may be any Java Two-Dimensional int-array.
        toString - This Java Lambda (Functional Interface) Parameter is one which accepts two integers, and a primitive-int. The integers provided shall contain the indices to an element of the 2D Array parameter, and the int at that Array location. The toString.apply(int, int, int) method inside this lambda should return any Java String to be printed to the output, for the given array-location and value.

        NOTE: This lambda may return a zero-length String, and when or if it does, that particular array-location will be 'skipped' (not printed) to the output String.

        ALSO: This parameter may be null, and if it is, it will be ignored and all array-int's, themselves, will simply be printed to the output String instead.

        FINALLY: If this lambda's 'apply' function ever returns null, it will result in a NullPointerException
        keepRow - This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicate receives an 'int' that corresponds to the first-order array index (the outer-array-index, a.k.a. 'int[x][]'). When this lambda-Predicate returns TRUE the inner sub-array 'int[]' will be included in the output-String. When this lamda returns FALSE, the entire sub-array will be eliminated from the output-String.

        AGAIN: When this lamda-Predicate receives null, it is ignored, meaning all sub-arrays are printed to the output-String - or at least until maxLengthInner is reached!.
        separateLines - When this parameter receives TRUE, each of the sub-array's (int[]) will be separated by a newline '\n' character. When this parameter is passed FALSE, all int[] inner-arrays will be printed to a single-line of text.
        maxLengthInner - This parameter may be null, or negative, and if it is, it shall be ignored. Remember that Java Compiler syntax allows primitive-literals to be passed to function-parameters of type Integer. This means, you may pass '80' here, rather than worrying about passing Integer.valueOf(80). Again, you may also pass 'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.

        When this parameter receives a non-null int, its intention is to specify an output String's 'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximum String length' is reached, an ' ...' (ellipsis) is appended to the end of the printed-String, and the printing logic moves on to the next sub-array.

        NOTE: Unlike parameter maxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the output String - not the number array-element int's.

        FINALLY: Because the output-String sub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than '7'. If it is not, an IllegalArgumentException is thrown. Again, a negative value shall be treated the same as if 'null' were passed.
        maxLengthOuter - This parameter may be null, or negative, and if it is, it will be ignored.

        Again, Java compiler-syntax allows integer literals to be passed directly to this parameter.

        This 'maximum length' specifies how many of the sub-arrays will be printed to the Output-String. If there are more sub-arrays than the value passed to maxLengthOter, an elipsis ' ...' shall be appended to the end of the returned-String.

        NOTE: The meaning of this integer-value is different than that of parameter 'maxLengthInner'. Here, it is used to specify a maximum number of elements (specifically, 'sub-arrays'), while in 'maxLengthInner', it is meant to specify a maximum number of output characters (a.k.a. a String-length).

        Remember that printing a large-two dimensional array will will result in a very long String. In conjunction with the 'separateLines' paramater and/or empty-String return-values from the 'toString' lambda, the length of the output-String can be reasonably sized.
        Returns:
        A printed version of this two-dimensional array.
        Throws:
        java.lang.NullPointerException - If the 'toString' method is non-null, but returns a null value.
        java.lang.IllegalArgumentException - If 'maxLengthInner' is less than '7'.
        Code:
        Exact Method Body:
         // maxLengthInner *MUST* be >= 7, since minimum-string-length is "  [...]"
         // A value of 0 to 6 must throw an exception.
         // A negative value is treated the same as 'null'
        
         if ((maxLengthInner != null) && (maxLengthInner < 7) && (maxLengthInner >= 0))
        
             throw new IllegalArgumentException
                 (IAE_MESSAGE_MAXLENINNER.replace("TOK", maxLengthInner.toString()));
        
         else if ((maxLengthInner != null) && (maxLengthInner < 0)) maxLengthInner = null;
        
         StringBuilder   sbOuter = new StringBuilder();  // Primary StringBuilder
         StringBuilder   sbInner = new StringBuilder();  // StrinBuilder for the sub/inner arrays
         String          s       = null;                 // temp variable
         int             i       = 0;                    // outer-loop loop-counter
         int             numRows = 0;                    // Count sub-arrays
        
         // If the value passed to 'maxLengthOuter' is negative, treat it the same as 'null'
         // SPECIFICALLY: No Max Length.
        
         if ((maxLengthOuter != null) && (maxLengthOuter < 0)) maxLengthOuter = null;
        
         sbOuter.append('[');
        
         for (i=0; i < arr.length; i++)
         {
             // The "Keep Row" Predicate is used to check whether a sub-array should even be
             // included at all.  If "Keep Row" exists, and it rejects the outer array index,
             // then the entire row itself should be skipped.
        
             if ((keepRow != null) && (! keepRow.test(i))) continue;
        
             numRows++;
             if ((maxLengthOuter != null) && (numRows > maxLengthOuter)) break;
        
             int j = 0;
        
             // System.out.println("end: " + end + ",\ti: " + i + ",\tj: " + j);
             // The purpose to this sub-loop is such that there is a "provided user option" where
             // the 'toString-lambda' may return a ZERO-LENGTH-STRING, and when this happens, the
             // array-location that resulted in a ZERO-LENGTH-STRING shall be ignored/skipped
             // completely.
        
             if (toString != null)
        
                 while (     (j < arr[i].length)
                         && ((s = toString.apply(i, j, arr[i][j])).length() == 0)
                 )
                     j++;
        
             else s = "" + arr[i][j];
        
             // If "separateLines" be sure to add a newline.
             if (separateLines) sbOuter.append('\n');
        
             // Add the opening brackets to this new sub-array that was just computed.
             sbInner.append(" [" + s);
             j++;
        
             // Main Printing Loop
             while (j < arr[i].length)
             {
                 if (toString != null)
                 {
                     if ((s = toString.apply(i, j, arr[i][j++])).length() > 0)
                         sbInner.append(", " + s);
                 }
        
                 else sbInner.append(", " + arr[i][j++]);
        
                 if ((maxLengthInner != null) && (sbInner.length() > maxLengthInner)) break;
             }
        
             // NOTE: The '+ 1' is needed because, as of yet, the trailing ']' has not been added.
             if ((maxLengthInner != null) && ((sbInner.length() + 1) > maxLengthInner))
             {
                 int     pos = sbInner.length() - 4;
                 char    c   = sbInner.charAt(pos);
        
                 while ((c != ',') && (c != '[')) c = sbInner.charAt(--pos);
        
                 sbInner.setLength(pos+1);
                 sbInner.append((c == '[') ? "..." : " ...");
             }
        
             sbInner.append(']');
             sbOuter.append(sbInner.toString());
             sbInner.setLength(0);
         }
        
         // This shall only execute if the 
         if (i < arr.length) sbOuter.append((separateLines ? "\n" : "") + "  ...");
        
         sbOuter.append(separateLines ? "\n]" : " ]");
            
         return sbOuter.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (long[][] arr,
                     IntIntLongFunc<java.lang.String> toString,
                     java.util.function.IntPredicate keepRow,
                     boolean separateLines,
                     java.lang.Integer maxLengthInner,
                     java.lang.Integer maxLengthOuter)
        
        This class prints a two dimensional long-array to a String.
        Parameters:
        arr - This may be any Java Two-Dimensional long-array.
        toString - This Java Lambda (Functional Interface) Parameter is one which accepts two integers, and a primitive-long. The integers provided shall contain the indices to an element of the 2D Array parameter, and the long at that Array location. The toString.apply(int, int, long) method inside this lambda should return any Java String to be printed to the output, for the given array-location and value.

        NOTE: This lambda may return a zero-length String, and when or if it does, that particular array-location will be 'skipped' (not printed) to the output String.

        ALSO: This parameter may be null, and if it is, it will be ignored and all array-long's, themselves, will simply be printed to the output String instead.

        FINALLY: If this lambda's 'apply' function ever returns null, it will result in a NullPointerException
        keepRow - This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicate receives an 'int' that corresponds to the first-order array index (the outer-array-index, a.k.a. 'long[x][]'). When this lambda-Predicate returns TRUE the inner sub-array 'long[]' will be included in the output-String. When this lamda returns FALSE, the entire sub-array will be eliminated from the output-String.

        AGAIN: When this lamda-Predicate receives null, it is ignored, meaning all sub-arrays are printed to the output-String - or at least until maxLengthInner is reached!.
        separateLines - When this parameter receives TRUE, each of the sub-array's (long[]) will be separated by a newline '\n' character. When this parameter is passed FALSE, all long[] inner-arrays will be printed to a single-line of text.
        maxLengthInner - This parameter may be null, or negative, and if it is, it shall be ignored. Remember that Java Compiler syntax allows primitive-literals to be passed to function-parameters of type Integer. This means, you may pass '80' here, rather than worrying about passing Integer.valueOf(80). Again, you may also pass 'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.

        When this parameter receives a non-null int, its intention is to specify an output String's 'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximum String length' is reached, an ' ...' (ellipsis) is appended to the end of the printed-String, and the printing logic moves on to the next sub-array.

        NOTE: Unlike parameter maxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the output String - not the number array-element long's.

        FINALLY: Because the output-String sub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than '7'. If it is not, an IllegalArgumentException is thrown. Again, a negative value shall be treated the same as if 'null' were passed.
        maxLengthOuter - This parameter may be null, or negative, and if it is, it will be ignored.

        Again, Java compiler-syntax allows integer literals to be passed directly to this parameter.

        This 'maximum length' specifies how many of the sub-arrays will be printed to the Output-String. If there are more sub-arrays than the value passed to maxLengthOter, an elipsis ' ...' shall be appended to the end of the returned-String.

        NOTE: The meaning of this integer-value is different than that of parameter 'maxLengthInner'. Here, it is used to specify a maximum number of elements (specifically, 'sub-arrays'), while in 'maxLengthInner', it is meant to specify a maximum number of output characters (a.k.a. a String-length).

        Remember that printing a large-two dimensional array will will result in a very long String. In conjunction with the 'separateLines' paramater and/or empty-String return-values from the 'toString' lambda, the length of the output-String can be reasonably sized.
        Returns:
        A printed version of this two-dimensional array.
        Throws:
        java.lang.NullPointerException - If the 'toString' method is non-null, but returns a null value.
        java.lang.IllegalArgumentException - If 'maxLengthInner' is less than '7'.
        Code:
        Exact Method Body:
         // maxLengthInner *MUST* be >= 7, since minimum-string-length is "  [...]"
         // A value of 0 to 6 must throw an exception.
         // A negative value is treated the same as 'null'
        
         if ((maxLengthInner != null) && (maxLengthInner < 7) && (maxLengthInner >= 0))
        
             throw new IllegalArgumentException
                 (IAE_MESSAGE_MAXLENINNER.replace("TOK", maxLengthInner.toString()));
        
         else if ((maxLengthInner != null) && (maxLengthInner < 0)) maxLengthInner = null;
        
         StringBuilder   sbOuter = new StringBuilder();  // Primary StringBuilder
         StringBuilder   sbInner = new StringBuilder();  // StrinBuilder for the sub/inner arrays
         String          s       = null;                 // temp variable
         int             i       = 0;                    // outer-loop loop-counter
         int             numRows = 0;                    // Count sub-arrays
        
         // If the value passed to 'maxLengthOuter' is negative, treat it the same as 'null'
         // SPECIFICALLY: No Max Length.
        
         if ((maxLengthOuter != null) && (maxLengthOuter < 0)) maxLengthOuter = null;
        
         sbOuter.append('[');
        
         for (i=0; i < arr.length; i++)
         {
             // The "Keep Row" Predicate is used to check whether a sub-array should even be
             // included at all.  If "Keep Row" exists, and it rejects the outer array index,
             // then the entire row itself should be skipped.
        
             if ((keepRow != null) && (! keepRow.test(i))) continue;
        
             numRows++;
             if ((maxLengthOuter != null) && (numRows > maxLengthOuter)) break;
        
             int j = 0;
        
             // System.out.println("end: " + end + ",\ti: " + i + ",\tj: " + j);
             // The purpose to this sub-loop is such that there is a "provided user option" where
             // the 'toString-lambda' may return a ZERO-LENGTH-STRING, and when this happens, the
             // array-location that resulted in a ZERO-LENGTH-STRING shall be ignored/skipped
             // completely.
        
             if (toString != null)
        
                 while (     (j < arr[i].length)
                         && ((s = toString.apply(i, j, arr[i][j])).length() == 0)
                 )
                     j++;
        
             else s = "" + arr[i][j];
        
             // If "separateLines" be sure to add a newline.
             if (separateLines) sbOuter.append('\n');
        
             // Add the opening brackets to this new sub-array that was just computed.
             sbInner.append(" [" + s);
             j++;
        
             // Main Printing Loop
             while (j < arr[i].length)
             {
                 if (toString != null)
                 {
                     if ((s = toString.apply(i, j, arr[i][j++])).length() > 0)
                         sbInner.append(", " + s);
                 }
        
                 else sbInner.append(", " + arr[i][j++]);
        
                 if ((maxLengthInner != null) && (sbInner.length() > maxLengthInner)) break;
             }
        
             // NOTE: The '+ 1' is needed because, as of yet, the trailing ']' has not been added.
             if ((maxLengthInner != null) && ((sbInner.length() + 1) > maxLengthInner))
             {
                 int     pos = sbInner.length() - 4;
                 char    c   = sbInner.charAt(pos);
        
                 while ((c != ',') && (c != '[')) c = sbInner.charAt(--pos);
        
                 sbInner.setLength(pos+1);
                 sbInner.append((c == '[') ? "..." : " ...");
             }
        
             sbInner.append(']');
             sbOuter.append(sbInner.toString());
             sbInner.setLength(0);
         }
        
         // This shall only execute if the 
         if (i < arr.length) sbOuter.append((separateLines ? "\n" : "") + "  ...");
        
         sbOuter.append(separateLines ? "\n]" : " ]");
            
         return sbOuter.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (float[][] arr,
                     IntIntFloatFunc<java.lang.String> toString,
                     java.util.function.IntPredicate keepRow,
                     boolean separateLines,
                     java.lang.Integer maxLengthInner,
                     java.lang.Integer maxLengthOuter)
        
        This class prints a two dimensional float-array to a String.
        Parameters:
        arr - This may be any Java Two-Dimensional float-array.
        toString - This Java Lambda (Functional Interface) Parameter is one which accepts two integers, and a primitive-float. The integers provided shall contain the indices to an element of the 2D Array parameter, and the float at that Array location. The toString.apply(int, int, float) method inside this lambda should return any Java String to be printed to the output, for the given array-location and value.

        NOTE: This lambda may return a zero-length String, and when or if it does, that particular array-location will be 'skipped' (not printed) to the output String.

        ALSO: This parameter may be null, and if it is, it will be ignored and all array-float's, themselves, will simply be printed to the output String instead.

        FINALLY: If this lambda's 'apply' function ever returns null, it will result in a NullPointerException
        keepRow - This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicate receives an 'int' that corresponds to the first-order array index (the outer-array-index, a.k.a. 'float[x][]'). When this lambda-Predicate returns TRUE the inner sub-array 'float[]' will be included in the output-String. When this lamda returns FALSE, the entire sub-array will be eliminated from the output-String.

        AGAIN: When this lamda-Predicate receives null, it is ignored, meaning all sub-arrays are printed to the output-String - or at least until maxLengthInner is reached!.
        separateLines - When this parameter receives TRUE, each of the sub-array's (float[]) will be separated by a newline '\n' character. When this parameter is passed FALSE, all float[] inner-arrays will be printed to a single-line of text.
        maxLengthInner - This parameter may be null, or negative, and if it is, it shall be ignored. Remember that Java Compiler syntax allows primitive-literals to be passed to function-parameters of type Integer. This means, you may pass '80' here, rather than worrying about passing Integer.valueOf(80). Again, you may also pass 'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.

        When this parameter receives a non-null int, its intention is to specify an output String's 'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximum String length' is reached, an ' ...' (ellipsis) is appended to the end of the printed-String, and the printing logic moves on to the next sub-array.

        NOTE: Unlike parameter maxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the output String - not the number array-element float's.

        FINALLY: Because the output-String sub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than '7'. If it is not, an IllegalArgumentException is thrown. Again, a negative value shall be treated the same as if 'null' were passed.
        maxLengthOuter - This parameter may be null, or negative, and if it is, it will be ignored.

        Again, Java compiler-syntax allows integer literals to be passed directly to this parameter.

        This 'maximum length' specifies how many of the sub-arrays will be printed to the Output-String. If there are more sub-arrays than the value passed to maxLengthOter, an elipsis ' ...' shall be appended to the end of the returned-String.

        NOTE: The meaning of this integer-value is different than that of parameter 'maxLengthInner'. Here, it is used to specify a maximum number of elements (specifically, 'sub-arrays'), while in 'maxLengthInner', it is meant to specify a maximum number of output characters (a.k.a. a String-length).

        Remember that printing a large-two dimensional array will will result in a very long String. In conjunction with the 'separateLines' paramater and/or empty-String return-values from the 'toString' lambda, the length of the output-String can be reasonably sized.
        Returns:
        A printed version of this two-dimensional array.
        Throws:
        java.lang.NullPointerException - If the 'toString' method is non-null, but returns a null value.
        java.lang.IllegalArgumentException - If 'maxLengthInner' is less than '7'.
        Code:
        Exact Method Body:
         // maxLengthInner *MUST* be >= 7, since minimum-string-length is "  [...]"
         // A value of 0 to 6 must throw an exception.
         // A negative value is treated the same as 'null'
        
         if ((maxLengthInner != null) && (maxLengthInner < 7) && (maxLengthInner >= 0))
        
             throw new IllegalArgumentException
                 (IAE_MESSAGE_MAXLENINNER.replace("TOK", maxLengthInner.toString()));
        
         else if ((maxLengthInner != null) && (maxLengthInner < 0)) maxLengthInner = null;
        
         StringBuilder   sbOuter = new StringBuilder();  // Primary StringBuilder
         StringBuilder   sbInner = new StringBuilder();  // StrinBuilder for the sub/inner arrays
         String          s       = null;                 // temp variable
         int             i       = 0;                    // outer-loop loop-counter
         int             numRows = 0;                    // Count sub-arrays
        
         // If the value passed to 'maxLengthOuter' is negative, treat it the same as 'null'
         // SPECIFICALLY: No Max Length.
        
         if ((maxLengthOuter != null) && (maxLengthOuter < 0)) maxLengthOuter = null;
        
         sbOuter.append('[');
        
         for (i=0; i < arr.length; i++)
         {
             // The "Keep Row" Predicate is used to check whether a sub-array should even be
             // included at all.  If "Keep Row" exists, and it rejects the outer array index,
             // then the entire row itself should be skipped.
        
             if ((keepRow != null) && (! keepRow.test(i))) continue;
        
             numRows++;
             if ((maxLengthOuter != null) && (numRows > maxLengthOuter)) break;
        
             int j = 0;
        
             // System.out.println("end: " + end + ",\ti: " + i + ",\tj: " + j);
             // The purpose to this sub-loop is such that there is a "provided user option" where
             // the 'toString-lambda' may return a ZERO-LENGTH-STRING, and when this happens, the
             // array-location that resulted in a ZERO-LENGTH-STRING shall be ignored/skipped
             // completely.
        
             if (toString != null)
        
                 while (     (j < arr[i].length)
                         && ((s = toString.apply(i, j, arr[i][j])).length() == 0)
                 )
                     j++;
        
             else s = "" + arr[i][j];
        
             // If "separateLines" be sure to add a newline.
             if (separateLines) sbOuter.append('\n');
        
             // Add the opening brackets to this new sub-array that was just computed.
             sbInner.append(" [" + s);
             j++;
        
             // Main Printing Loop
             while (j < arr[i].length)
             {
                 if (toString != null)
                 {
                     if ((s = toString.apply(i, j, arr[i][j++])).length() > 0)
                         sbInner.append(", " + s);
                 }
        
                 else sbInner.append(", " + arr[i][j++]);
        
                 if ((maxLengthInner != null) && (sbInner.length() > maxLengthInner)) break;
             }
        
             // NOTE: The '+ 1' is needed because, as of yet, the trailing ']' has not been added.
             if ((maxLengthInner != null) && ((sbInner.length() + 1) > maxLengthInner))
             {
                 int     pos = sbInner.length() - 4;
                 char    c   = sbInner.charAt(pos);
        
                 while ((c != ',') && (c != '[')) c = sbInner.charAt(--pos);
        
                 sbInner.setLength(pos+1);
                 sbInner.append((c == '[') ? "..." : " ...");
             }
        
             sbInner.append(']');
             sbOuter.append(sbInner.toString());
             sbInner.setLength(0);
         }
        
         // This shall only execute if the 
         if (i < arr.length) sbOuter.append((separateLines ? "\n" : "") + "  ...");
        
         sbOuter.append(separateLines ? "\n]" : " ]");
            
         return sbOuter.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (double[][] arr,
                     IntIntDoubleFunc<java.lang.String> toString,
                     java.util.function.IntPredicate keepRow,
                     boolean separateLines,
                     java.lang.Integer maxLengthInner,
                     java.lang.Integer maxLengthOuter)
        
        This class prints a two dimensional double-array to a String.
        Parameters:
        arr - This may be any Java Two-Dimensional double-array.
        toString - This Java Lambda (Functional Interface) Parameter is one which accepts two integers, and a primitive-double. The integers provided shall contain the indices to an element of the 2D Array parameter, and the double at that Array location. The toString.apply(int, int, double) method inside this lambda should return any Java String to be printed to the output, for the given array-location and value.

        NOTE: This lambda may return a zero-length String, and when or if it does, that particular array-location will be 'skipped' (not printed) to the output String.

        ALSO: This parameter may be null, and if it is, it will be ignored and all array-double's, themselves, will simply be printed to the output String instead.

        FINALLY: If this lambda's 'apply' function ever returns null, it will result in a NullPointerException
        keepRow - This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicate receives an 'int' that corresponds to the first-order array index (the outer-array-index, a.k.a. 'double[x][]'). When this lambda-Predicate returns TRUE the inner sub-array 'double[]' will be included in the output-String. When this lamda returns FALSE, the entire sub-array will be eliminated from the output-String.

        AGAIN: When this lamda-Predicate receives null, it is ignored, meaning all sub-arrays are printed to the output-String - or at least until maxLengthInner is reached!.
        separateLines - When this parameter receives TRUE, each of the sub-array's (double[]) will be separated by a newline '\n' character. When this parameter is passed FALSE, all double[] inner-arrays will be printed to a single-line of text.
        maxLengthInner - This parameter may be null, or negative, and if it is, it shall be ignored. Remember that Java Compiler syntax allows primitive-literals to be passed to function-parameters of type Integer. This means, you may pass '80' here, rather than worrying about passing Integer.valueOf(80). Again, you may also pass 'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.

        When this parameter receives a non-null int, its intention is to specify an output String's 'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximum String length' is reached, an ' ...' (ellipsis) is appended to the end of the printed-String, and the printing logic moves on to the next sub-array.

        NOTE: Unlike parameter maxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the output String - not the number array-element double's.

        FINALLY: Because the output-String sub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than '7'. If it is not, an IllegalArgumentException is thrown. Again, a negative value shall be treated the same as if 'null' were passed.
        maxLengthOuter - This parameter may be null, or negative, and if it is, it will be ignored.

        Again, Java compiler-syntax allows integer literals to be passed directly to this parameter.

        This 'maximum length' specifies how many of the sub-arrays will be printed to the Output-String. If there are more sub-arrays than the value passed to maxLengthOter, an elipsis ' ...' shall be appended to the end of the returned-String.

        NOTE: The meaning of this integer-value is different than that of parameter 'maxLengthInner'. Here, it is used to specify a maximum number of elements (specifically, 'sub-arrays'), while in 'maxLengthInner', it is meant to specify a maximum number of output characters (a.k.a. a String-length).

        Remember that printing a large-two dimensional array will will result in a very long String. In conjunction with the 'separateLines' paramater and/or empty-String return-values from the 'toString' lambda, the length of the output-String can be reasonably sized.
        Returns:
        A printed version of this two-dimensional array.
        Throws:
        java.lang.NullPointerException - If the 'toString' method is non-null, but returns a null value.
        java.lang.IllegalArgumentException - If 'maxLengthInner' is less than '7'.
        Code:
        Exact Method Body:
         // maxLengthInner *MUST* be >= 7, since minimum-string-length is "  [...]"
         // A value of 0 to 6 must throw an exception.
         // A negative value is treated the same as 'null'
        
         if ((maxLengthInner != null) && (maxLengthInner < 7) && (maxLengthInner >= 0))
        
             throw new IllegalArgumentException
                 (IAE_MESSAGE_MAXLENINNER.replace("TOK", maxLengthInner.toString()));
        
         else if ((maxLengthInner != null) && (maxLengthInner < 0)) maxLengthInner = null;
        
         StringBuilder   sbOuter = new StringBuilder();  // Primary StringBuilder
         StringBuilder   sbInner = new StringBuilder();  // StrinBuilder for the sub/inner arrays
         String          s       = null;                 // temp variable
         int             i       = 0;                    // outer-loop loop-counter
         int             numRows = 0;                    // Count sub-arrays
        
         // If the value passed to 'maxLengthOuter' is negative, treat it the same as 'null'
         // SPECIFICALLY: No Max Length.
         if ((maxLengthOuter != null) && (maxLengthOuter < 0)) maxLengthOuter = null;
        
         sbOuter.append('[');
        
         for (i=0; i < arr.length; i++)
         {
             // The "Keep Row" Predicate is used to check whether a sub-array should even be
             // included at all.  If "Keep Row" exists, and it rejects the outer array index,
             // then the entire row itself should be skipped.
        
             if ((keepRow != null) && (! keepRow.test(i))) continue;
        
             numRows++;
             if ((maxLengthOuter != null) && (numRows > maxLengthOuter)) break;
        
             int j = 0;
        
             // System.out.println("end: " + end + ",\ti: " + i + ",\tj: " + j);
             // The purpose to this sub-loop is such that there is a "provided user option" where
             // the 'toString-lambda' may return a ZERO-LENGTH-STRING, and when this happens, the
             // array-location that resulted in a ZERO-LENGTH-STRING shall be ignored/skipped
             // completely.
        
             if (toString != null)
        
                 while (     (j < arr[i].length)
                         && ((s = toString.apply(i, j, arr[i][j])).length() == 0)
                 )
                     j++;
        
             else s = "" + arr[i][j];
        
             // If "separateLines" be sure to add a newline.
             if (separateLines) sbOuter.append('\n');
        
             // Add the opening brackets to this new sub-array that was just computed.
             sbInner.append(" [" + s);
             j++;
        
             // Main Printing Loop
             while (j < arr[i].length)
             {
                 if (toString != null)
                 {
                     if ((s = toString.apply(i, j, arr[i][j++])).length() > 0)
                         sbInner.append(", " + s);
                 }
        
                 else sbInner.append(", " + arr[i][j++]);
        
                 if ((maxLengthInner != null) && (sbInner.length() > maxLengthInner)) break;
             }
        
             // NOTE: The '+ 1' is needed because, as of yet, the trailing ']' has not been added.
             if ((maxLengthInner != null) && ((sbInner.length() + 1) > maxLengthInner))
             {
                 int     pos = sbInner.length() - 4;
                 char    c   = sbInner.charAt(pos);
        
                 while ((c != ',') && (c != '[')) c = sbInner.charAt(--pos);
        
                 sbInner.setLength(pos+1);
                 sbInner.append((c == '[') ? "..." : " ...");
             }
        
             sbInner.append(']');
             sbOuter.append(sbInner.toString());
             sbInner.setLength(0);
         }
        
         // This shall only execute if the 
         if (i < arr.length) sbOuter.append((separateLines ? "\n" : "") + "  ...");
        
         sbOuter.append(separateLines ? "\n]" : " ]");
            
         return sbOuter.toString();
        
      • toCSV

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (char[][] arr,
                     IntIntCharFunc<java.lang.String> toString,
                     java.util.function.IntPredicate keepRow,
                     boolean separateLines,
                     java.lang.Integer maxLengthInner,
                     java.lang.Integer maxLengthOuter)
        
        This class prints a two dimensional char-array to a String.
        Parameters:
        arr - This may be any Java Two-Dimensional char-array.
        toString - This Java Lambda (Functional Interface) Parameter is one which accepts two integers, and a primitive-char. The integers provided shall contain the indices to an element of the 2D Array parameter, and the char at that Array location. The toString.apply(int, int, char) method inside this lambda should return any Java String to be printed to the output, for the given array-location and value.

        NOTE: This lambda may return a zero-length String, and when or if it does, that particular array-location will be 'skipped' (not printed) to the output String.

        ALSO: This parameter may be null, and if it is, it will be ignored and all array-char's, themselves, will simply be printed to the output String instead.

        FINALLY: If this lambda's 'apply' function ever returns null, it will result in a NullPointerException
        keepRow - This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicate receives an 'int' that corresponds to the first-order array index (the outer-array-index, a.k.a. 'char[x][]'). When this lambda-Predicate returns TRUE the inner sub-array 'char[]' will be included in the output-String. When this lamda returns FALSE, the entire sub-array will be eliminated from the output-String.

        AGAIN: When this lamda-Predicate receives null, it is ignored, meaning all sub-arrays are printed to the output-String - or at least until maxLengthInner is reached!.
        separateLines - When this parameter receives TRUE, each of the sub-array's (char[]) will be separated by a newline '\n' character. When this parameter is passed FALSE, all char[] inner-arrays will be printed to a single-line of text.
        maxLengthInner - This parameter may be null, or negative, and if it is, it shall be ignored. Remember that Java Compiler syntax allows primitive-literals to be passed to function-parameters of type Integer. This means, you may pass '80' here, rather than worrying about passing Integer.valueOf(80). Again, you may also pass 'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.

        When this parameter receives a non-null int, its intention is to specify an output String's 'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximum String length' is reached, an ' ...' (ellipsis) is appended to the end of the printed-String, and the printing logic moves on to the next sub-array.

        NOTE: Unlike parameter maxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the output String - not the number array-element char's.

        FINALLY: Because the output-String sub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than '7'. If it is not, an IllegalArgumentException is thrown. Again, a negative value shall be treated the same as if 'null' were passed.
        maxLengthOuter - This parameter may be null, or negative, and if it is, it will be ignored.

        Again, Java compiler-syntax allows integer literals to be passed directly to this parameter.

        This 'maximum length' specifies how many of the sub-arrays will be printed to the Output-String. If there are more sub-arrays than the value passed to maxLengthOter, an elipsis ' ...' shall be appended to the end of the returned-String.

        NOTE: The meaning of this integer-value is different than that of parameter 'maxLengthInner'. Here, it is used to specify a maximum number of elements (specifically, 'sub-arrays'), while in 'maxLengthInner', it is meant to specify a maximum number of output characters (a.k.a. a String-length).

        Remember that printing a large-two dimensional array will will result in a very long String. In conjunction with the 'separateLines' paramater and/or empty-String return-values from the 'toString' lambda, the length of the output-String can be reasonably sized.
        Returns:
        A printed version of this two-dimensional array.
        Throws:
        java.lang.NullPointerException - If the 'toString' method is non-null, but returns a null value.
        java.lang.IllegalArgumentException - If 'maxLengthInner' is less than '7'.
        Code:
        Exact Method Body:
         // maxLengthInner *MUST* be >= 7, since minimum-string-length is "  [...]"
         // A value of 0 to 6 must throw an exception.
         // A negative value is treated the same as 'null'
        
         if ((maxLengthInner != null) && (maxLengthInner < 7) && (maxLengthInner >= 0))
        
             throw new IllegalArgumentException
                 (IAE_MESSAGE_MAXLENINNER.replace("TOK", maxLengthInner.toString()));
        
         else if ((maxLengthInner != null) && (maxLengthInner < 0)) maxLengthInner = null;
        
         StringBuilder   sbOuter = new StringBuilder();  // Primary StringBuilder
         StringBuilder   sbInner = new StringBuilder();  // StrinBuilder for the sub/inner arrays
         String          s       = null;                 // temp variable
         int             i       = 0;                    // outer-loop loop-counter
         int             numRows = 0;                    // Count sub-arrays
        
         // If the value passed to 'maxLengthOuter' is negative, treat it the same as 'null'
         // SPECIFICALLY: No Max Length.
        
         if ((maxLengthOuter != null) && (maxLengthOuter < 0)) maxLengthOuter = null;
        
         sbOuter.append('[');
        
         for (i=0; i < arr.length; i++)
         {
             // The "Keep Row" Predicate is used to check whether a sub-array should even be
             // included at all.  If "Keep Row" exists, and it rejects the outer array index,
             // then the entire row itself should be skipped.
        
             if ((keepRow != null) && (! keepRow.test(i))) continue;
        
             numRows++;
             if ((maxLengthOuter != null) && (numRows > maxLengthOuter)) break;
        
             int j = 0;
        
             // System.out.println("end: " + end + ",\ti: " + i + ",\tj: " + j);
             // The purpose to this sub-loop is such that there is a "provided user option" where
             // the 'toString-lambda' may return a ZERO-LENGTH-STRING, and when this happens, the
             // array-location that resulted in a ZERO-LENGTH-STRING shall be ignored/skipped
             // completely.
        
             if (toString != null)
        
                 while (     (j < arr[i].length)
                         && ((s = toString.apply(i, j, arr[i][j])).length() == 0)
                 )
                     j++;
        
             else s = "" + arr[i][j];
        
             // If "separateLines" be sure to add a newline.
             if (separateLines) sbOuter.append('\n');
        
             // Add the opening brackets to this new sub-array that was just computed.
             sbInner.append(" [" + s);
             j++;
        
             // Main Printing Loop
             while (j < arr[i].length)
             {
                 if (toString != null)
                 {
                     if ((s = toString.apply(i, j, arr[i][j++])).length() > 0)
                         sbInner.append(", " + s);
                 }
        
                 else sbInner.append(", " + arr[i][j++]);
        
                 if ((maxLengthInner != null) && (sbInner.length() > maxLengthInner)) break;
             }
        
             // NOTE: The '+ 1' is needed because, as of yet, the trailing ']' has not been added.
             if ((maxLengthInner != null) && ((sbInner.length() + 1) > maxLengthInner))
             {
                 int     pos = sbInner.length() - 4;
                 char    c   = sbInner.charAt(pos);
        
                 while ((c != ',') && (c != '[')) c = sbInner.charAt(--pos);
        
                 sbInner.setLength(pos+1);
                 sbInner.append((c == '[') ? "..." : " ...");
             }
        
             sbInner.append(']');
             sbOuter.append(sbInner.toString());
             sbInner.setLength(0);
         }
        
         // This shall only execute if the 
         if (i < arr.length) sbOuter.append((separateLines ? "\n" : "") + "  ...");
        
         sbOuter.append(separateLines ? "\n]" : " ]");
            
         return sbOuter.toString();
        
      • toCSV

        🡅     🗕  🗗  🗖
        public static java.lang.String toCSV​
                    (boolean[][] arr,
                     IntIntBoolFunc<java.lang.String> toString,
                     java.util.function.IntPredicate keepRow,
                     boolean separateLines,
                     java.lang.Integer maxLengthInner,
                     java.lang.Integer maxLengthOuter)
        
        This class prints a two dimensional boolean-array to a String.
        Parameters:
        arr - This may be any Java Two-Dimensional boolean-array.
        toString - This Java Lambda (Functional Interface) Parameter is one which accepts two integers, and a primitive-boolean. The integers provided shall contain the indices to an element of the 2D Array parameter, and the boolean at that Array location. The toString.apply(int, int, boolean) method inside this lambda should return any Java String to be printed to the output, for the given array-location and value.

        NOTE: This lambda may return a zero-length String, and when or if it does, that particular array-location will be 'skipped' (not printed) to the output String.

        ALSO: This parameter may be null, and if it is, it will be ignored and all array-boolean's, themselves, will simply be printed to the output String instead.

        FINALLY: If this lambda's 'apply' function ever returns null, it will result in a NullPointerException
        keepRow - This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicate receives an 'int' that corresponds to the first-order array index (the outer-array-index, a.k.a. 'boolean[x][]'). When this lambda-Predicate returns TRUE the inner sub-array 'boolean[]' will be included in the output-String. When this lamda returns FALSE, the entire sub-array will be eliminated from the output-String.

        AGAIN: When this lamda-Predicate receives null, it is ignored, meaning all sub-arrays are printed to the output-String - or at least until maxLengthInner is reached!.
        separateLines - When this parameter receives TRUE, each of the sub-array's (boolean[]) will be separated by a newline '\n' character. When this parameter is passed FALSE, all boolean[] inner-arrays will be printed to a single-line of text.
        maxLengthInner - This parameter may be null, or negative, and if it is, it shall be ignored. Remember that Java Compiler syntax allows primitive-literals to be passed to function-parameters of type Integer. This means, you may pass '80' here, rather than worrying about passing Integer.valueOf(80). Again, you may also pass 'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.

        When this parameter receives a non-null int, its intention is to specify an output String's 'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximum String length' is reached, an ' ...' (ellipsis) is appended to the end of the printed-String, and the printing logic moves on to the next sub-array.

        NOTE: Unlike parameter maxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the output String - not the number array-element boolean's.

        FINALLY: Because the output-String sub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than '7'. If it is not, an IllegalArgumentException is thrown. Again, a negative value shall be treated the same as if 'null' were passed.
        maxLengthOuter - This parameter may be null, or negative, and if it is, it will be ignored.

        Again, Java compiler-syntax allows integer literals to be passed directly to this parameter.

        This 'maximum length' specifies how many of the sub-arrays will be printed to the Output-String. If there are more sub-arrays than the value passed to maxLengthOter, an elipsis ' ...' shall be appended to the end of the returned-String.

        NOTE: The meaning of this integer-value is different than that of parameter 'maxLengthInner'. Here, it is used to specify a maximum number of elements (specifically, 'sub-arrays'), while in 'maxLengthInner', it is meant to specify a maximum number of output characters (a.k.a. a String-length).

        Remember that printing a large-two dimensional array will will result in a very long String. In conjunction with the 'separateLines' paramater and/or empty-String return-values from the 'toString' lambda, the length of the output-String can be reasonably sized.
        Returns:
        A printed version of this two-dimensional array.
        Throws:
        java.lang.NullPointerException - If the 'toString' method is non-null, but returns a null value.
        java.lang.IllegalArgumentException - If 'maxLengthInner' is less than '7'.
        Code:
        Exact Method Body:
         // maxLengthInner *MUST* be >= 7, since minimum-string-length is "  [...]"
         // A value of 0 to 6 must throw an exception.
         // A negative value is treated the same as 'null'
        
         if ((maxLengthInner != null) && (maxLengthInner < 7) && (maxLengthInner >= 0))
        
             throw new IllegalArgumentException
                 (IAE_MESSAGE_MAXLENINNER.replace("TOK", maxLengthInner.toString()));
        
         else if ((maxLengthInner != null) && (maxLengthInner < 0)) maxLengthInner = null;
        
         StringBuilder   sbOuter = new StringBuilder();  // Primary StringBuilder
         StringBuilder   sbInner = new StringBuilder();  // StrinBuilder for the sub/inner arrays
         String          s       = null;                 // temp variable
         int             i       = 0;                    // outer-loop loop-counter
         int             numRows = 0;                    // Count sub-arrays
        
         // If the value passed to 'maxLengthOuter' is negative, treat it the same as 'null'
         // SPECIFICALLY: No Max Length.
        
         if ((maxLengthOuter != null) && (maxLengthOuter < 0)) maxLengthOuter = null;
        
         sbOuter.append('[');
        
         for (i=0; i < arr.length; i++)
         {
             // The "Keep Row" Predicate is used to check whether a sub-array should even be
             // included at all.  If "Keep Row" exists, and it rejects the outer array index,
             // then the entire row itself should be skipped.
        
             if ((keepRow != null) && (! keepRow.test(i))) continue;
        
             numRows++;
             if ((maxLengthOuter != null) && (numRows > maxLengthOuter)) break;
        
             int j = 0;
        
             // System.out.println("end: " + end + ",\ti: " + i + ",\tj: " + j);
             // The purpose to this sub-loop is such that there is a "provided user option" where
             // the 'toString-lambda' may return a ZERO-LENGTH-STRING, and when this happens, the
             // array-location that resulted in a ZERO-LENGTH-STRING shall be ignored/skipped
             // completely.
        
             if (toString != null)
        
                 while (     (j < arr[i].length)
                         && ((s = toString.apply(i, j, arr[i][j])).length() == 0)
                 )
                     j++;
        
             else s = "" + arr[i][j];
        
             // If "separateLines" be sure to add a newline.
             if (separateLines) sbOuter.append('\n');
        
             // Add the opening brackets to this new sub-array that was just computed.
             sbInner.append(" [" + s);
             j++;
        
             // Main Printing Loop
             while (j < arr[i].length)
             {
                 if (toString != null)
                 {
                     if ((s = toString.apply(i, j, arr[i][j++])).length() > 0)
                         sbInner.append(", " + s);
                 }
        
                 else sbInner.append(", " + arr[i][j++]);
        
                 if ((maxLengthInner != null) && (sbInner.length() > maxLengthInner)) break;
             }
        
             // NOTE: The '+ 1' is needed because, as of yet, the trailing ']' has not been added.
             if ((maxLengthInner != null) && ((sbInner.length() + 1) > maxLengthInner))
             {
                 int     pos = sbInner.length() - 4;
                 char    c   = sbInner.charAt(pos);
        
                 while ((c != ',') && (c != '[')) c = sbInner.charAt(--pos);
        
                 sbInner.setLength(pos+1);
                 sbInner.append((c == '[') ? "..." : " ...");
             }
        
             sbInner.append(']');
             sbOuter.append(sbInner.toString());
             sbInner.setLength(0);
         }
        
         // This shall only execute if the 
         if (i < arr.length) sbOuter.append((separateLines ? "\n" : "") + "  ...");
        
         sbOuter.append(separateLines ? "\n]" : " ]");
            
         return sbOuter.toString();