001package Torello.Java;
002
003import Torello.Java.Function.*;
004import Torello.JavaDoc.LinkJavaSource;
005
006import java.util.*;
007import java.util.function.*;
008import java.util.stream.*;
009
010/**
011 * A utility that builds Comma Separated Value String's (and can parse them as well).
012 * 
013 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=STR_CSV>
014 */
015@Torello.JavaDoc.StaticFunctional
016public class StrCSV
017{
018    private StrCSV() { }
019
020    // Package-Private: Exception-Message Helper used by the Helper-CSV Classes
021    static void throwNPE(int i, Object o)
022    {
023        throw new NullPointerException(
024            "The toString Lambda provided to this method returned null for array-index " +
025            "[" + i + "].  At this index, the array contents were [" + o.toString() + "]"
026        );
027    }
028
029    // Package-Private: Exception-Message Helper used by the Helper-CSV Classes
030    static final String IAE_MESSAGE_MAXLENINNER =
031        "The value passed to parameter 'maxLengthInner' was [TOK].  " +
032        "However, BECAUSE this value represents a minimum String length for a subarray, " +
033        "AND BECAUSE an ellipsis, space and brackets are appended, this parameter may not " +
034        "have a positive value less than 7.";
035
036
037    // ********************************************************************************************
038    // ********************************************************************************************
039    // From CSV to Array
040    // ********************************************************************************************
041    // ********************************************************************************************
042
043
044    /**
045     * Convenience Method.
046     * <BR />Invokes: {@link #CSV(String, boolean, boolean)}.
047     */
048    public static String[] CSV(String s) { return CSV(s, true, true); }
049
050    /**
051     * This will return a list of {@code String} that are in-between each-and-every comma that is
052     * found inside the parameter-{@code String} {@code 's'}
053     *
054     * <BR /><BR /><B CLASS=JDDescLabel>Java Stream API:</B>
055     * 
056     * <BR />This method uses Java 8 or 9's {@code package java.util.stream.*}.  If this package is
057     * not familiar, it is usually just a way (after some practice), of (sort-of) converting
058     * for-loops into more readable method-calls.  Java-Streams instead substitute words such as:
059     * {@code 'filter', 'map', 'forEach'} and {@code 'toArray'}. This method's code is nothing more
060     * than that.
061     *
062     * @param s This accepts any java-{@code String}, but it is expecting one that contains commas.
063     * 
064     * @param performTrim If this parameter is set to {@code TRUE}, then all {@code String's} will
065     * be trimmed of white-space before being placed in the returned {@code String}-array, by
066     * calling Java's {@code String.trim()} method.
067     * 
068     * @param eliminateZeroLengthStrings If this parameter is set to {@code TRUE}, then all 
069     * {@code String's} that have zero-length will be eliminated from the returned {@code String[]}
070     * array.
071     * 
072     * <BR /><BR /><B><SPAN STYLE="color: red;">NOTE:</B></SPAN> Regardless of whether or not a
073     * {@code trim()} operation was performed, all {@code String's} that are trimmed of
074     * white-space, would have the {@code 'trim'} done <B><I>before</B></I> the {@code 'eliminate'}
075     * operation.
076     * 
077     * @return This will return the individual {@code String's} from a larger-{@code String} that
078     * contained comma-separated values.
079     */
080    public static String[] CSV(String s, boolean performTrim, boolean eliminateZeroLengthStrings)
081    {
082        Stream<String> stream =
083            StringParse.COMMA_REGEX.splitAsStream(s).filter((String csv) -> csv != null);
084
085        if (performTrim)
086            stream = stream.map((String csv) -> csv.trim());
087
088        if (eliminateZeroLengthStrings)
089            stream = stream.filter((String csv) -> csv.length() > 0);
090
091        return stream.toArray(String[]::new);
092    }
093
094
095    // ********************************************************************************************
096    // ********************************************************************************************
097    // To CSV, Object Arrays, Iterables
098    // ********************************************************************************************
099    // ********************************************************************************************
100
101
102    /**
103     * Convenience Method.
104     * <BR />See Documentation: {@link #toCSV(Iterable, boolean, boolean, Integer)}
105     * <BR />Converts: {@code String[] Array} to {@code List<String>}.
106     */
107    @LinkJavaSource(handle="IterableCSV", name="toCSV1")
108    public static String toCSV(String[] sArr, boolean trim, boolean printNulls, Integer maxLength)
109    { return IterableCSV.toCSV1(Arrays.asList(sArr), trim, printNulls, maxLength); }
110
111    /**
112     * This method will turn the elements of any java {@code Iterable} type into a 
113     * {@code java.lang.String}.  The returned {@code String} shall have the individual elements
114     * of parameter {@code 'i'} converted to {@code String's}, each separated by a comma.
115     * 
116     * @param i Any Java {@code Iterable}.  The Java {@code Object.toString()} will be invoked on
117     * each of the elements produced by the {@code Iterable}, and commas shall be inserted between
118     * each element.
119     * 
120     * <EMBED CLASS='external-html' DATA-FILE-ID=RAWTYPES>
121     * 
122     * @param trim This is a boolean, and when set {@code TRUE}, the {@code String.trim()} shall be
123     * invoked on each {@code String} inserted into the CSV list before insertion.
124     * 
125     * @param printNulls This is a boolean, and when set {@code TRUE}, each object returned by the
126     * iterator shall be checked for a 'null' value before insertion into the output-{@code String}
127     * - <I>to avoid null-pointer exceptions</I>.  Instead the four-character {@code String} 'null'
128     * will be inserted instead of throwing this exception.
129     * 
130     * <BR /><BR />When this parameter receives {@code FALSE}, if the input parameter
131     * {@code Iterable<?> i} contains a null value, then this method will simply throw a 
132     * {@code NullPointerException}.
133     * 
134     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
135     * 
136     * @return This will return a CSV {@code String} containing the individual elements of the
137     * input {@code Iterable} parameter {@code 'i'}, where each element has been converted to a
138     * {@code String} and is separated by a comma.
139     * 
140     * @throws NullPointerException If the {@code Iterable} returns a null value, and the
141     * {@code 'printNulls'} parameter were set to {@code FALSE}, then this method would throw
142     * an exception.
143     */
144    @LinkJavaSource(handle="IterableCSV", name="toCSV1")
145    public static String toCSV(Iterable<?> i, boolean trim, boolean printNulls, Integer maxLength)
146    { return IterableCSV.toCSV1(i, trim, printNulls, maxLength); }
147
148    /**
149     * This method will turn the elements of any java {@code Iterable} type into a 
150     * {@code java.lang.String}.  The returned {@code String} shall have the individual elements
151     * of parameter {@code 'i'} converted to {@code String's}, each separated by a comma.
152     * 
153     * @param <T> The type used by the {@code java.lang.Iterable}.  The {@code 'toString'} 
154     * parameter / function-pointer also must accept this type, or a super-type.
155     * 
156     * @param i Any Java {@code Iterable}.  The functional-interface parameter {@code 'toString'}
157     * will be invoked on each of the elements produced by the {@code Iterable}, and commas shall
158     * be inserted between each element.
159     * 
160     * @param toString This instance of {@code java.util.function.Function<A, B>} must have a
161     * method that accepts a parameter having type {@code 'T'}, and returns a {@code String}.  This
162     * is simply an "over-riding" of Java's basic {@code 'toString()'} method.  In fact, if the
163     * class that is being used for variable-type parameter {@code 'T'} has a {@code 'toString'}
164     * method that is sufficient or "good enough", then this method should not be used, but
165     * rather the simpler method: {@link #toCSV(Iterable, boolean, boolean, Integer)}.
166     * 
167     * @param printNulls When this parameter is {@code TRUE}, the {@code 'toString.apply(T)'}
168     * method shall receive a null value, and the {@code String} results returned by this method
169     * shall be inserted into the output {@code String} when the input {@code Iterable 'i'}
170     * contains a null value.  Thusly, the behavior of this method for 'nulls' in the input
171     * {@code 'i'} parameter should be <I>no different than any other value found within the input
172     * {@code Iterable 'i'}.</I>
173     * 
174     * <BR /><BR />When this parameter receives {@code FALSE}, any time a null value is encountered
175     * from the input {@code Iterable<T> 'i'}, that value shall be skipped and the output
176     * {@code String} that is returned will have one fewer element in it's CSV list.
177     * 
178     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
179     * 
180     * @return This will return a CSV {@code String} containing the individual elements of the
181     * input {@code Iterable} parameter {@code 'i'}, where each element has been converted to a
182     * {@code String} - <I>using the provided {@code 'toString'}</I> function - and is separated by
183     * a comma.
184     */
185    @LinkJavaSource(handle="IterableCSV", name="toCSV2")
186    public static <T> String toCSV(
187            Iterable<T> i, Function<? super T, String> toString,
188            boolean printNulls, Integer maxLength
189        )
190    { return IterableCSV.toCSV2(i, toString, printNulls, maxLength); }
191
192    /**
193     * Convenience Method.
194     * <BR />See Documentation: {@link #toCSV(Object[], int, int, boolean, boolean, Integer)}
195     */
196    @LinkJavaSource(handle="TArr1D", name="toCSV1")
197    public static <T> String toCSV
198        (T[] tArr, boolean trim, boolean printNulls, Integer maxLength)
199    { return TArr1D.toCSV1(tArr, 0, -1, trim, printNulls, maxLength); }
200
201    /**
202     * This method will turn the elements of any java {@code Iterable} type into a 
203     * {@code java.lang.String}.  The returned {@code String} shall have the individual elements
204     * of parameter {@code 'i'} converted to {@code String's}, each separated by a comma.
205     * 
206     * @param tArr Any array type {@code 'T'}.  Java's {@code 'toString'} method will be invoked
207     * on each of these elements, and returned in a {@code String} where each element has been
208     * separated by a comma.
209     * 
210     * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSARRAY>
211     * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSARRAY>
212     * 
213     * @param trim This is a boolean, and when set {@code TRUE}, the {@code String.trim()} shall be
214     * invoked on each {@code String} inserted into the CSV list before insertion.
215     * 
216     * @param printNulls This is a boolean, and when set {@code TRUE}, each instance of {@code 'T'}
217     * contained by {@code 'tArr'} shall be checked for a 'null' value before insertion into the
218     * output-{@code String} - <I>to avoid null-pointer exceptions</I>.  If a null is found, the
219     * four-character {@code String} 'null' will be inserted instead of throwing this exception.
220     * 
221     * <BR /><BR />When this parameter receives {@code FALSE}, if a null value is encountered within
222     * the input-parameter array {@code T[] tArr}, then this method will, in fact, throw a 
223     * NullPointerException.
224     * 
225     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
226     * 
227     * @return This will return a CSV {@code String} containing the individual elements of the
228     * input array {@code T[] tArr} parameter, where each element shall have been converted to a
229     * {@code String} and separated by a comma.
230     * 
231     * @throws NullPointerException If the {@code Iterable} returns a null value, and the
232     * {@code 'printNulls'} parameter were set to {@code FALSE}, then this method would throw
233     * an exception.
234     * 
235     * @throws ArrayIndexOutOfBoundsException <EMBED CLASS='external-html' DATA-FILE-ID=AIOOB_EX>
236     */
237    @LinkJavaSource(handle="TArr1D", name="toCSV1")
238    public static <T> String toCSV
239        (T[] tArr, int sPos, int ePos, boolean trim, boolean printNulls, Integer maxLength)
240    { return TArr1D.toCSV1(tArr, sPos, ePos, trim, printNulls, maxLength); }
241
242    /**
243     * Convenience Method.
244     * <BR />See Documentation: {@link #toCSV(Object[], int, int, IntTFunction, boolean, Integer)}
245     */
246    @LinkJavaSource(handle="TArr1D", name="toCSV2")
247    public static <T> String toCSV
248        (T[] tArr, IntTFunction<? super T, String> toString, boolean printNulls, Integer maxLength)
249    { return TArr1D.toCSV2(tArr, 0, -1, toString, printNulls, maxLength); }
250
251    /**
252     * Converts an array of a variable-type parameter {@code T[]} to a CSV {@code String}
253     * 
254     * <BR /><BR />This version of {@code 'toCSV'} allows a programmer to define the exact
255     * {@code 'toString()'} that is used on each object-instance in the provided array.  There
256     * is a simpler version of this method where the invokation {@code T.toString()} is 
257     * used instead.
258     * 
259     * @param <T> The type used by the {@code T[]}-Array.  The {@code 'toString'}
260     * parameter / function-pointer also must accept this type.
261     * 
262     * @param tArr An array of {@code Object's} of a given variable-type {@code 'T'}
263     * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSARRAY>
264     * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSARRAY>
265     * 
266     * @param toString A method that will convert {@code Object's} of type {@code 'T'} to a
267     * {@code String}.  This parameter <I><B>may not</I></B> be null, because in such cases it
268     * would be appropriate to use: {@link #toCSV(Object[], int, int, boolean, boolean, Integer)}
269     * 
270     * <BR /><BR /><B STYLE="color: red;">NOTE:</B> This functional-interface is used
271     * instead of simply calling {@code Object.toString()} in order to allow a programmer to
272     * provide arbitrarily defined {@code toString()} methods.  If the standard {@code toString()}
273     * method for a given {@code Object} is not sufficient, then provide a different one here using
274     * this parameter.
275     * 
276     * <BR /><BR />This {@code 'toString'} functional-interface is expected to accept both an
277     * instance of a type {@code 'T'} variable, <B><I>AND</I></B> an integer.  The integer that is
278     * accepted is simply the array-index where the {@code 'T'} variable parameter is located
279     * within the array.
280     * 
281     * <BR /><BR /><B STYLE="color: red;">NOTE:</B> This function may return a zero-length
282     * {@code String}, and when/if it does, the {@code Object} located at that array-index shall
283     * not be printed to the output-{@code String}.  Also, if this function ever returns null, then
284     * a {@code NullPointerException} shall throw immediately.
285     * 
286     * @param printNulls When this parameter is {@code TRUE}, if a null is encountered within the
287     * input-parameter array {@code T[] tArr}, then null shall be passed to the Functional
288     * Interface input-parameter method {@code toString.apply(T)}, and the {@code String} result
289     * from that method shall be inserted into the {@code String} that is returned.
290     * 
291     * <BR /><BR />When this parameter receives {@code FALSE}, then anytime a null value is found
292     * within the input-parameter array {@code T[] tArr}, it will be skipped completely, and the
293     * output {@code String} will simply contain one fewer output-{@code String}.
294     * 
295     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
296     * 
297     * @return a CSV version of the input parameter {@code 'tArr'} where each instance of
298     * {@code 'T'} shall have been converted to a {@code String} using the provided
299     * {@code 'toString(...)'} method.
300     * 
301     * @throws ArrayIndexOutOfBoundsException <EMBED CLASS='external-html' DATA-FILE-ID=AIOOB_EX>
302     * @throws NullPointerException if parameter {@code 'toString'} is null, or if any of the
303     * return values produced by {@code 'toString'} are null
304     */
305    @LinkJavaSource(handle="TArr1D", name="toCSV2")
306    public static <T> String toCSV(
307            T[] tArr, int sPos, int ePos, IntTFunction<? super T, String> toString,
308            boolean printNulls, Integer maxLength
309        )
310    { return TArr1D.toCSV2(tArr, sPos, ePos, toString, printNulls, maxLength); }
311
312    /**
313     * <EMBED CLASS=defs DATA-Type="<T>">
314     * This class prints a two dimensional {@code <T>}-array to a {@code String}.
315     * 
316     * @param <T> The type used by the {@code T[][]}-Array.  The {@code 'toString'}
317     * parameter / function-pointer also must accept this type.
318     * 
319     * @param tArr           <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_ARR_2D>
320     * @param toString       <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TSTR_2DARR>
321     * @param keepRow        <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SUB_PRED>
322     * @param separateLines  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SEPL_LINE>
323     * @param maxLengthInner <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN_IN>
324     * @param maxLengthOuter <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAXLEN_OUT>
325     * @return               A printed version of this two-dimensional array.
326     * 
327     * @throws NullPointerException If the {@code 'toString'} method is non-null, but returns a
328     * null value.
329     * 
330     * @throws IllegalArgumentException If {@code 'maxLengthInner'} is less than {@code '7'}.
331     */
332    @LinkJavaSource(handle="TArr2D")
333    public static <T> String toCSV(
334            T[][] tArr, IntIntTFunc<? super T, String> toString, IntPredicate keepRow,
335            boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter
336        )
337    {
338        return TArr2D.toCSV
339            (tArr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
340    }
341
342
343    // ********************************************************************************************
344    // ********************************************************************************************
345    // One Dimensional Primitive Arrays
346    // ********************************************************************************************
347    // ********************************************************************************************
348
349
350    /**
351     * Convenience Method.
352     * <BR />See Documentation: {@link #toCSV(byte[], int, int, IntByteFunction, Integer)}
353     */
354    @LinkJavaSource(handle="Byte1D")
355    public static String toCSV
356        (byte[] arr, IntByteFunction<String> toString, Integer maxLength)
357    { return Byte1D.toCSV(arr, 0, -1, toString, maxLength); }
358
359    /**
360     * <EMBED CLASS=defs DATA-ArrType=byte DATA-Lambda=IntByteFunction DATA-VarName=b>
361     * <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAIN_DESC>
362     * 
363     * @param arr       Any array of {@code byte}.
364     * @param sPos      <EMBED CLASS='external-html' DATA-FILE-ID=SPOSARRAY>
365     * @param ePos      <EMBED CLASS='external-html' DATA-FILE-ID=EPOSARRAY>
366     * @param toString  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TO_STRING DATA-word=numbers>
367     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
368     * @return          <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_RETURN>
369     * 
370     * @throws ArrayIndexOutOfBoundsException <EMBED CLASS='external-html' DATA-FILE-ID=AIOOB_EX>
371     * @throws NullPointerException           If {@code 'toString'} returns a null value.
372     */
373    @LinkJavaSource(handle="Byte1D")
374    public static String toCSV
375        (byte[] arr, int sPos, int ePos, IntByteFunction<String> toString, Integer maxLength)
376    { return Byte1D.toCSV(arr, sPos, ePos, toString, maxLength); }
377
378    /**
379     * Convenience Method.
380     * <BR />See Documentation: {@link #toCSV(short[], int, int, IntShortFunction, Integer)}
381     */
382    @LinkJavaSource(handle="Short1D")
383    public static String toCSV
384        (short[] arr, IntShortFunction<String> toString, Integer maxLength)
385    { return Short1D.toCSV(arr, 0, -1, toString, maxLength); }
386
387    /**
388     * <EMBED CLASS=defs DATA-ArrType=short DATA-Lambda=IntShortFunction DATA-VarName=s>
389     * <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAIN_DESC>
390     * 
391     * @param arr       Any array of {@code short}-integers.
392     * @param sPos      <EMBED CLASS='external-html' DATA-FILE-ID=SPOSARRAY>
393     * @param ePos      <EMBED CLASS='external-html' DATA-FILE-ID=EPOSARRAY>
394     * @param toString  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TO_STRING DATA-word=numbers>
395     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
396     * @return          <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_RETURN>
397     * 
398     * @throws ArrayIndexOutOfBoundsException <EMBED CLASS='external-html' DATA-FILE-ID=AIOOB_EX>
399     * @throws NullPointerException           If {@code 'toString'} returns a null value.
400     */
401    @LinkJavaSource(handle="Short1D")
402    public static String toCSV
403        (short[] arr, int sPos, int ePos, IntShortFunction<String> toString, Integer maxLength)
404    { return Short1D.toCSV(arr, sPos, ePos, toString, maxLength); }
405
406    /**
407     * Convenience Method.
408     * <BR />See Documentation: {@link #toCSV(int[], int, int, BiIntFunction, Integer)}
409     */
410    @LinkJavaSource(handle="Int1D")
411    public static String toCSV
412        (int[] arr, BiIntFunction<String> toString, Integer maxLength)
413    { return Int1D.toCSV(arr, 0, -1, toString, maxLength); }
414
415    /**
416     * <EMBED CLASS=defs DATA-ArrType=int DATA-Lambda=BiIntFunction DATA-VarName=j>
417     * <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAIN_DESC>
418     * 
419     * @param arr       Any array of integers.
420     * @param sPos      <EMBED CLASS='external-html' DATA-FILE-ID=SPOSARRAY>
421     * @param ePos      <EMBED CLASS='external-html' DATA-FILE-ID=EPOSARRAY>
422     * @param toString  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TO_STRING DATA-word=numbers>
423     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
424     * @return          <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_RETURN>
425     * 
426     * @throws ArrayIndexOutOfBoundsException <EMBED CLASS='external-html' DATA-FILE-ID=AIOOB_EX>
427     * @throws NullPointerException           If {@code 'toString'} returns a null value.
428     */
429    @LinkJavaSource(handle="Int1D")
430    public static String toCSV
431        (int[] arr, int sPos, int ePos, BiIntFunction<String> toString, Integer maxLength)
432    { return Int1D.toCSV(arr, sPos, ePos, toString, maxLength); }
433
434    /**
435     * Convenience Method.
436     * <BR />See Documentation: {@link #toCSV(long[], int, int, IntLongFunction, Integer)}
437     */
438    @LinkJavaSource(handle="Long1D")
439    public static String toCSV
440        (long[] arr, IntLongFunction<String> toString, Integer maxLength)
441    { return Long1D.toCSV(arr, 0, -1, toString, maxLength); }
442
443    /**
444     * <EMBED CLASS=defs DATA-ArrType=long DATA-Lambda=IntLongFunction DATA-VarName=l>
445     * <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAIN_DESC>
446     * 
447     * @param arr       Any array of {@code long}-integers.
448     * @param sPos      <EMBED CLASS='external-html' DATA-FILE-ID=SPOSARRAY>
449     * @param ePos      <EMBED CLASS='external-html' DATA-FILE-ID=EPOSARRAY>
450     * @param toString  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TO_STRING DATA-word=numbers>
451     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
452     * @return          <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_RETURN>
453     * 
454     * @throws ArrayIndexOutOfBoundsException <EMBED CLASS='external-html' DATA-FILE-ID=AIOOB_EX>
455     * @throws NullPointerException           If {@code 'toString'} returns a null value.
456     */
457    @LinkJavaSource(handle="Long1D")
458    public static String toCSV
459        (long[] arr, int sPos, int ePos, IntLongFunction<String> toString, Integer maxLength)
460    { return Long1D.toCSV(arr, sPos, ePos, toString, maxLength); }
461
462    /**
463     * Convenience Method.
464     * <BR />See Documentation: {@link #toCSV(float[], int, int, IntFloatFunction, Integer)}
465     */
466    @LinkJavaSource(handle="Float1D")
467    public static String toCSV
468        (float[] arr, IntFloatFunction<String> toString, Integer maxLength)
469    { return Float1D.toCSV(arr, 0, -1, toString, maxLength); }
470
471    /**
472     * <EMBED CLASS=defs DATA-ArrType=float DATA-Lambda=IntFloatFunction DATA-VarName=f>
473     * <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAIN_DESC>
474     * 
475     * @param arr       Any array of {@code float}.
476     * @param sPos      <EMBED CLASS='external-html' DATA-FILE-ID=SPOSARRAY>
477     * @param ePos      <EMBED CLASS='external-html' DATA-FILE-ID=EPOSARRAY>
478     * @param toString  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TO_STRING DATA-word=numbers>
479     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
480     * @return          <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_RETURN>
481     * 
482     * @throws ArrayIndexOutOfBoundsException <EMBED CLASS='external-html' DATA-FILE-ID=AIOOB_EX>
483     * @throws NullPointerException           If {@code 'toString'} returns a null value.
484     */
485    @LinkJavaSource(handle="Float1D")
486    public static String toCSV
487        (float[] arr, int sPos, int ePos, IntFloatFunction<String> toString, Integer maxLength)
488    { return Float1D.toCSV(arr, sPos, ePos, toString, maxLength); }
489    
490    /**
491     * Convenience Method.
492     * <BR />See Documentation: {@link #toCSV(double[], int, int, IntDoubleFunction, Integer)}
493     */
494    @LinkJavaSource(handle="Double1D")
495    public static String toCSV
496        (double[] arr, IntDoubleFunction<String> toString, Integer maxLength)
497    { return Double1D.toCSV(arr, 0, -1, toString, maxLength); }
498
499    /**
500     * <EMBED CLASS=defs DATA-ArrType=double DATA-Lambda=IntDoubleFunction DATA-VarName=d>
501     * <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAIN_DESC>
502     * 
503     * @param arr       Any array of {@code double}.
504     * @param sPos      <EMBED CLASS='external-html' DATA-FILE-ID=SPOSARRAY>
505     * @param ePos      <EMBED CLASS='external-html' DATA-FILE-ID=EPOSARRAY>
506     * @param toString  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TO_STRING DATA-word=numbers>
507     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
508     * @return          <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_RETURN>
509     * 
510     * @throws ArrayIndexOutOfBoundsException <EMBED CLASS='external-html' DATA-FILE-ID=AIOOB_EX>
511     * @throws NullPointerException           If {@code 'toString'} returns a null value.
512     */
513    @LinkJavaSource(handle="Double1D")
514    public static String toCSV
515        (double[] arr, int sPos, int ePos, IntDoubleFunction<String> toString, Integer maxLength)
516    { return Double1D.toCSV(arr, sPos, ePos, toString, maxLength); }
517
518    /**
519     * Convenience Method.
520     * <BR />See Documentation: {@link #toCSV(boolean[], int, int, IntBoolFunction, Integer)}
521     */
522    @LinkJavaSource(handle="Boolean1D")
523    public static String toCSV
524        (boolean[] arr, IntBoolFunction<String> toString, Integer maxLength)
525    { return Boolean1D.toCSV(arr, 0, -1, toString, maxLength); }
526
527    /**
528     * <EMBED CLASS=defs DATA-ArrType=boolean DATA-Lambda=IntBoolFunction DATA-VarName=b>
529     * <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAIN_DESC>
530     * 
531     * @param arr       Any array of {@code boolean}.
532     * @param sPos      <EMBED CLASS='external-html' DATA-FILE-ID=SPOSARRAY>
533     * @param ePos      <EMBED CLASS='external-html' DATA-FILE-ID=EPOSARRAY>
534     * @param toString  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TO_STRING DATA-word=booleans>
535     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
536     * @return          <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_RETURN>
537     * 
538     * @throws ArrayIndexOutOfBoundsException <EMBED CLASS='external-html' DATA-FILE-ID=AIOOB_EX>
539     * @throws NullPointerException           If {@code 'toString'} returns a null value.
540     */
541    @LinkJavaSource(handle="Boolean1D")
542    public static String toCSV
543        (boolean[] arr, int sPos, int ePos, IntBoolFunction<String> toString, Integer maxLength)
544    { return Boolean1D.toCSV(arr, sPos, ePos, toString, maxLength); }
545
546    /**
547     * Convenience Method.
548     * <BR />See Documentation: {@link #toCSV(char[], int, int, IntCharFunction, Integer)}
549     */
550    @LinkJavaSource(handle="Char1D")
551    public static String toCSV
552        (char[] arr, IntCharFunction<String> toString, Integer maxLength)
553    { return Char1D.toCSV(arr, 0, -1, toString, maxLength); }
554
555    /**
556     * <EMBED CLASS=defs DATA-ArrType=char DATA-Lambda=IntCharFunction DATA-VarName=c>
557     * <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAIN_DESC>
558     * 
559     * @param arr       Any array of {@code boolean}.
560     * @param sPos      <EMBED CLASS='external-html' DATA-FILE-ID=SPOSARRAY>
561     * @param ePos      <EMBED CLASS='external-html' DATA-FILE-ID=EPOSARRAY>
562     * @param toString  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TO_STRING DATA-word=characters>
563     * @param maxLength <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN>
564     * @return          <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_RETURN>
565     * 
566     * @throws ArrayIndexOutOfBoundsException <EMBED CLASS='external-html' DATA-FILE-ID=AIOOB_EX>
567     * @throws NullPointerException           If {@code 'toString'} returns a null value.
568     */
569    @LinkJavaSource(handle="Char1D")
570    public static String toCSV
571        (char[] arr, int sPos, int ePos, IntCharFunction<String> toString, Integer maxLength)
572    { return Char1D.toCSV(arr, sPos, ePos, toString, maxLength); }
573
574
575    // ********************************************************************************************
576    // ********************************************************************************************
577    // Two Dimensional Primitive Arrays
578    // ********************************************************************************************
579    // ********************************************************************************************
580
581
582    /**
583     * <EMBED CLASS=defs DATA-Type=byte>
584     * This class prints a two dimensional {@code byte}-array to a {@code String}.
585     * 
586     * @param arr            <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_ARR_2D>
587     * @param toString       <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TSTR_2DARR>
588     * @param keepRow        <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SUB_PRED>
589     * @param separateLines  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SEPL_LINE>
590     * @param maxLengthInner <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN_IN>
591     * @param maxLengthOuter <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAXLEN_OUT>
592     * @return               A printed version of this two-dimensional array.
593     * 
594     * @throws NullPointerException If the {@code 'toString'} method is non-null, but returns a
595     * null value.
596     * @throws IllegalArgumentException If {@code 'maxLengthInner'} is less than {@code '7'}.
597     */
598    @LinkJavaSource(handle="Byte2D")
599    public static String toCSV(
600            byte[][] arr, IntIntByteFunc<String> toString, IntPredicate keepRow,
601            boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter
602        )
603    {
604        return Byte2D.toCSV
605            (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
606    }
607
608    /**
609     * <EMBED CLASS=defs DATA-Type=short>
610     * This class prints a two dimensional {@code short}-array to a {@code String}.
611     * 
612     * @param arr            <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_ARR_2D>
613     * @param toString       <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TSTR_2DARR>
614     * @param keepRow        <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SUB_PRED>
615     * @param separateLines  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SEPL_LINE>
616     * @param maxLengthInner <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN_IN>
617     * @param maxLengthOuter <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAXLEN_OUT>
618     * @return               A printed version of this two-dimensional array.
619     * 
620     * @throws NullPointerException If the {@code 'toString'} method is non-null, but returns a
621     * null value.
622     * 
623     * @throws IllegalArgumentException If {@code 'maxLengthInner'} is less than {@code '7'}.
624     */
625    @LinkJavaSource(handle="Short2D")
626    public static String toCSV(
627            short[][] arr, IntIntShortFunc<String> toString, IntPredicate keepRow,
628            boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter
629        )
630    {
631        return Short2D.toCSV
632            (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
633    }
634
635    /**
636     * <EMBED CLASS=defs DATA-Type=int>
637     * This class prints a two dimensional {@code int}-array to a {@code String}.
638     * 
639     * @param arr            <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_ARR_2D>
640     * @param toString       <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TSTR_2DARR>
641     * @param keepRow        <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SUB_PRED>
642     * @param separateLines  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SEPL_LINE>
643     * @param maxLengthInner <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN_IN>
644     * @param maxLengthOuter <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAXLEN_OUT>
645     * @return               A printed version of this two-dimensional array.
646     * 
647     * @throws NullPointerException If the {@code 'toString'} method is non-null, but returns a
648     * null value.
649     * 
650     * @throws IllegalArgumentException If {@code 'maxLengthInner'} is less than {@code '7'}.
651     */
652    @LinkJavaSource(handle="Int2D")
653    public static String toCSV(
654            int[][] arr, TriIntFunc<String> toString, IntPredicate keepRow,
655            boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter
656        )
657    {
658        return Int2D.toCSV
659            (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
660    }
661
662    /**
663     * <EMBED CLASS=defs DATA-Type=long>
664     * This class prints a two dimensional {@code long}-array to a {@code String}.
665     * 
666     * @param arr            <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_ARR_2D>
667     * @param toString       <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TSTR_2DARR>
668     * @param keepRow        <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SUB_PRED>
669     * @param separateLines  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SEPL_LINE>
670     * @param maxLengthInner <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN_IN>
671     * @param maxLengthOuter <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAXLEN_OUT>
672     * @return               A printed version of this two-dimensional array.
673     * 
674     * @throws NullPointerException If the {@code 'toString'} method is non-null, but returns a
675     * null value.
676     * 
677     * @throws IllegalArgumentException If {@code 'maxLengthInner'} is less than {@code '7'}.
678     */
679    @LinkJavaSource(handle="Long2D")
680    public static String toCSV(
681            long[][] arr, IntIntLongFunc<String> toString, IntPredicate keepRow,
682            boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter
683        )
684    {
685        return Long2D.toCSV
686            (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
687    }
688
689    /**
690     * <EMBED CLASS=defs DATA-Type=float>
691     * This class prints a two dimensional {@code float}-array to a {@code String}.
692     * 
693     * @param arr            <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_ARR_2D>
694     * @param toString       <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TSTR_2DARR>
695     * @param keepRow        <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SUB_PRED>
696     * @param separateLines  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SEPL_LINE>
697     * @param maxLengthInner <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN_IN>
698     * @param maxLengthOuter <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAXLEN_OUT>
699     * @return               A printed version of this two-dimensional array.
700     * 
701     * @throws NullPointerException If the {@code 'toString'} method is non-null, but returns a
702     * null value.
703     * 
704     * @throws IllegalArgumentException If {@code 'maxLengthInner'} is less than {@code '7'}.
705     */
706    @LinkJavaSource(handle="Float2D")
707    public static String toCSV(
708            float[][] arr, IntIntFloatFunc<String> toString, IntPredicate keepRow,
709            boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter
710        )
711    {
712        return Float2D.toCSV
713            (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
714    }
715
716    /**
717     * <EMBED CLASS=defs DATA-Type=double>
718     * This class prints a two dimensional {@code double}-array to a {@code String}.
719     * 
720     * @param arr            <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_ARR_2D>
721     * @param toString       <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TSTR_2DARR>
722     * @param keepRow        <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SUB_PRED>
723     * @param separateLines  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SEPL_LINE>
724     * @param maxLengthInner <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN_IN>
725     * @param maxLengthOuter <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAXLEN_OUT>
726     * @return               A printed version of this two-dimensional array.
727     * 
728     * @throws NullPointerException If the {@code 'toString'} method is non-null, but returns a
729     * null value.
730     * 
731     * @throws IllegalArgumentException If {@code 'maxLengthInner'} is less than {@code '7'}.
732     */
733    @LinkJavaSource(handle="Double2D")
734    public static String toCSV(
735            double[][] arr, IntIntDoubleFunc<String> toString, IntPredicate keepRow,
736            boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter
737        )
738    {
739        return Double2D.toCSV
740            (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
741    }
742
743    /**
744     * <EMBED CLASS=defs DATA-Type=char>
745     * This class prints a two dimensional {@code char}-array to a {@code String}.
746     * 
747     * @param arr            <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_ARR_2D>
748     * @param toString       <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TSTR_2DARR>
749     * @param keepRow        <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SUB_PRED>
750     * @param separateLines  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SEPL_LINE>
751     * @param maxLengthInner <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN_IN>
752     * @param maxLengthOuter <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAXLEN_OUT>
753     * @return               A printed version of this two-dimensional array.
754     * 
755     * @throws NullPointerException If the {@code 'toString'} method is non-null, but returns a
756     * null value.
757     * 
758     * @throws IllegalArgumentException If {@code 'maxLengthInner'} is less than {@code '7'}.
759     */
760    @LinkJavaSource(handle="Char2D")
761    public static String toCSV(
762            char[][] arr, IntIntCharFunc<String> toString, IntPredicate keepRow,
763            boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter
764        )
765    {
766       return Char2D.toCSV
767           (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
768    }
769
770    /**
771     * <EMBED CLASS=defs DATA-Type=boolean>
772     * This class prints a two dimensional {@code boolean}-array to a {@code String}.
773     * 
774     * @param arr            <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_ARR_2D>
775     * @param toString       <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_TSTR_2DARR>
776     * @param keepRow        <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SUB_PRED>
777     * @param separateLines  <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_SEPL_LINE>
778     * @param maxLengthInner <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAX_LEN_IN>
779     * @param maxLengthOuter <EMBED CLASS='external-html' DATA-FILE-ID=SCSV_MAXLEN_OUT>
780     * @return               A printed version of this two-dimensional array.
781     * 
782     * @throws NullPointerException If the {@code 'toString'} method is non-null, but returns a
783     * null value.
784     * 
785     * @throws IllegalArgumentException If {@code 'maxLengthInner'} is less than {@code '7'}.
786     */
787    @LinkJavaSource(handle="Boolean2D")
788    public static String toCSV(
789            boolean[][] arr, IntIntBoolFunc<String> toString, IntPredicate keepRow,
790            boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter
791        )
792    {
793        return Boolean2D.toCSV
794            (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
795    }
796}