Package Torello.Java
Class StrCSV
- java.lang.Object
-
- Torello.Java.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 longjava.lang.Stringsuch that each element of theStringis separated by a comma. These routines are also capable of parsing aStringwhose elements are separated by commas, back into an array.
Hi-Lited Source-Code:- View Here: Torello/Java/StrCSV.java
- Open New Browser-Tab: Torello/Java/StrCSV.java
File Size: 41,181 Bytes Line Count: 796 '\n' Characters Found
Stateless Class:This class neither contains any program-state, nor can it be instantiated. The@StaticFunctionalAnnotation may also be called 'The Spaghetti Report'.Static-Functionalclasses are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's@StatelessAnnotation.
- 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 StringtoCSV(Iterable<?> i, boolean trim, boolean printNulls, Integer maxLength)static <T> StringtoCSV(Iterable<T> i, Function<? super T,String> toString, boolean printNulls, Integer maxLength)static StringtoCSV(String[] sArr, boolean trim, boolean printNulls, Integer maxLength)static <T> StringtoCSV(T[][] tArr, IntIntTFunc<? super T,String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)static <T> StringtoCSV(T[] tArr, boolean trim, boolean printNulls, Integer maxLength)static <T> StringtoCSV(T[] tArr, IntTFunction<? super T,String> toString, boolean printNulls, Integer maxLength)Generate CSV, Range-Limited Modifier and Type Method static <T> StringtoCSV(T[] tArr, int sPos, int ePos, boolean trim, boolean printNulls, Integer maxLength)static <T> StringtoCSV(T[] tArr, int sPos, int ePos, IntTFunction<? super T,String> toString, boolean printNulls, Integer maxLength)Generate CSV, Primitive-Array Modifier and Type Method static StringtoCSV(boolean[] arr, IntBoolFunction<String> toString, Integer maxLength)static StringtoCSV(byte[] arr, IntByteFunction<String> toString, Integer maxLength)static StringtoCSV(char[] arr, IntCharFunction<String> toString, Integer maxLength)static StringtoCSV(double[] arr, IntDoubleFunction<String> toString, Integer maxLength)static StringtoCSV(float[] arr, IntFloatFunction<String> toString, Integer maxLength)static StringtoCSV(int[] arr, BiIntFunction<String> toString, Integer maxLength)static StringtoCSV(long[] arr, IntLongFunction<String> toString, Integer maxLength)static StringtoCSV(short[] arr, IntShortFunction<String> toString, Integer maxLength)Generate CSV, Primitive-Array, Range-Limited Modifier and Type Method static StringtoCSV(boolean[] arr, int sPos, int ePos, IntBoolFunction<String> toString, Integer maxLength)static StringtoCSV(byte[] arr, int sPos, int ePos, IntByteFunction<String> toString, Integer maxLength)static StringtoCSV(char[] arr, int sPos, int ePos, IntCharFunction<String> toString, Integer maxLength)static StringtoCSV(double[] arr, int sPos, int ePos, IntDoubleFunction<String> toString, Integer maxLength)static StringtoCSV(float[] arr, int sPos, int ePos, IntFloatFunction<String> toString, Integer maxLength)static StringtoCSV(int[] arr, int sPos, int ePos, BiIntFunction<String> toString, Integer maxLength)static StringtoCSV(long[] arr, int sPos, int ePos, IntLongFunction<String> toString, Integer maxLength)static StringtoCSV(short[] arr, int sPos, int ePos, IntShortFunction<String> toString, Integer maxLength)Generate CSV, 2-D Primitive-Array Modifier and Type Method static StringtoCSV(boolean[][] arr, IntIntBoolFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)static StringtoCSV(byte[][] arr, IntIntByteFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)static StringtoCSV(char[][] arr, IntIntCharFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)static StringtoCSV(double[][] arr, IntIntDoubleFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)static StringtoCSV(float[][] arr, IntIntFloatFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)static StringtoCSV(int[][] arr, TriIntFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)static StringtoCSV(long[][] arr, IntIntLongFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)static StringtoCSV(short[][] arr, IntIntShortFunc<String> toString, IntPredicate keepRow, boolean separateLines, Integer maxLengthInner, Integer maxLengthOuter)
-
-
-
Method Detail
-
CSV
public static java.lang.String[] CSV(java.lang.String s)
- Code:
- Exact Method Body:
return CSV(s, true, true);
-
CSV
public static java.lang.String[] CSV(java.lang.String s, boolean performTrim, boolean eliminateZeroLengthStrings)
This will return a list ofStringthat 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'spackage 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 toTRUE, then allString'swill be trimmed of white-space before being placed in the returnedString-array, by calling Java'sString.trim()method.eliminateZeroLengthStrings- If this parameter is set toTRUE, then allString'sthat have zero-length will be eliminated from the returnedString[]array.
NOTE: Regardless of whether or not atrim()operation was performed, allString'sthat are trimmed of white-space, would have the'trim'done before the'eliminate'operation.- Returns:
- This will return the individual
String'sfrom a larger-Stringthat 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.String[] sArr, boolean trim, boolean printNulls, java.lang.Integer maxLength)
Convenience Method
See Documentation:toCSV(Iterable, boolean, boolean, Integer)
Converts:String[] ArraytoList<String>.- Code:
- Exact Method Body:
return IterableCSV.toCSV1(Arrays.asList(sArr), trim, printNulls, maxLength);
-
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 javaIterabletype into ajava.lang.String. The returnedStringshall have the individual elements of parameter'i'converted toString's, each separated by a comma.- Parameters:
i- Any JavaIterable. The JavaObject.toString()will be invoked on each of the elements produced by theIterable, and commas shall be inserted between each element.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:alloption is used.trim- This is a boolean, and when setTRUE, theString.trim()shall be invoked on eachStringinserted into the CSV list before insertion.printNulls- This is a boolean, and when setTRUE, 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-characterString'null' will be inserted instead of throwing this exception.
When this parameter receivesFALSE, if the input parameterIterable<?> icontains a null value, then this method will simply throw aNullPointerException.maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- This will return a CSV
Stringcontaining the individual elements of the inputIterableparameter'i', where each element has been converted to aStringand is separated by a comma. - Throws:
java.lang.NullPointerException- If theIterablereturns a null value, and the'printNulls'parameter were set toFALSE, then this method would throw an exception.- Code:
- Exact Method Body:
return IterableCSV.toCSV1(i, trim, printNulls, maxLength);
-
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 javaIterabletype into ajava.lang.String. The returnedStringshall have the individual elements of parameter'i'converted toString's, each separated by a comma.- Type Parameters:
T- The type used by thejava.lang.Iterable. The'toString'parameter / function-pointer also must accept this type, or a super-type.- Parameters:
i- Any JavaIterable. The functional-interface parameter'toString'will be invoked on each of the elements produced by theIterable, and commas shall be inserted between each element.toString- This instance ofjava.util.function.Function<A, B>must have a method that accepts a parameter having type'T', and returns aString. 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 isTRUE, the'toString.apply(T)'method shall receive a null value, and theStringresults returned by this method shall be inserted into the outputStringwhen the inputIterable '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 inputIterable 'i'.
When this parameter receivesFALSE, any time a null value is encountered from the inputIterable<T> 'i', that value shall be skipped and the outputStringthat is returned will have one fewer element in it's CSV list.maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- This will return a CSV
Stringcontaining the individual elements of the inputIterableparameter'i', where each element has been converted to aString- using the provided'toString'function - and is separated by a comma. - Code:
- Exact Method Body:
return IterableCSV.toCSV2(i, toString, printNulls, maxLength);
-
toCSV
public static <T> java.lang.String toCSV(T[] tArr, boolean trim, boolean printNulls, java.lang.Integer maxLength)
- Code:
- Exact Method Body:
return TArr1D.toCSV1(tArr, 0, -1, trim, printNulls, maxLength);
-
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 javaIterabletype into ajava.lang.String. The returnedStringshall have the individual elements of parameter'i'converted toString'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 aStringwhere each element has been separated by a comma.sPos- This is the (integer)Array-index that sets a limit for the left-mostArray-position to inspect/search inside the inputArray-parameter. This value is considered 'inclusive' meaning that the element at thisArray-index will be visited by this method.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-mostArray-position to inspect/search inside the inputVector-parameter. This value is considered 'exclusive' meaning that the element at thisArray-index will not be visited by this method.If this value is larger than the length of input theArray-parameter, an exception will throw.
Passing a negative value to this parameter,'ePos', will cause its value to be reset to the length of the inputArray-parameter.trim- This is a boolean, and when setTRUE, theString.trim()shall be invoked on eachStringinserted into the CSV list before insertion.printNulls- This is a boolean, and when setTRUE, 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-characterString'null' will be inserted instead of throwing this exception.
When this parameter receivesFALSE, if a null value is encountered within the input-parameter arrayT[] tArr, then this method will, in fact, throw a NullPointerException.maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- This will return a CSV
Stringcontaining the individual elements of the input arrayT[] tArrparameter, where each element shall have been converted to aStringand separated by a comma. - Throws:
java.lang.NullPointerException- If theIterablereturns a null value, and the'printNulls'parameter were set toFALSE, 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 ifsPosis greater-than-or-equal-to thelengthof theArray - If
'ePos'is zero, or greater than the length of theArray - If the value of
'sPos'is a larger integer than'ePos'. If'ePos'was negative, it is first reset toArray.length, before this check is done.
- If
- Code:
- Exact Method Body:
return TArr1D.toCSV1(tArr, sPos, ePos, trim, printNulls, maxLength);
-
toCSV
public static <T> java.lang.String toCSV (T[] tArr, IntTFunction<? super T,java.lang.String> toString, boolean printNulls, java.lang.Integer maxLength)
- Code:
- Exact Method Body:
return TArr1D.toCSV2(tArr, 0, -1, toString, printNulls, maxLength);
-
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 parameterT[]to a CSVString
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 invokationT.toString()is used instead.- Type Parameters:
T- The type used by theT[]-Array. The'toString'parameter / function-pointer also must accept this type.- Parameters:
tArr- An array ofObject'sof a given variable-type'T'sPos- This is the (integer)Array-index that sets a limit for the left-mostArray-position to inspect/search inside the inputArray-parameter. This value is considered 'inclusive' meaning that the element at thisArray-index will be visited by this method.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-mostArray-position to inspect/search inside the inputVector-parameter. This value is considered 'exclusive' meaning that the element at thisArray-index will not be visited by this method.If this value is larger than the length of input theArray-parameter, an exception will throw.
Passing a negative value to this parameter,'ePos', will cause its value to be reset to the length of the inputArray-parameter.toString- A method that will convertObject'sof type'T'to aString. 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 callingObject.toString()in order to allow a programmer to provide arbitrarily definedtoString()methods. If the standardtoString()method for a givenObjectis 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-lengthString, and when/if it does, theObjectlocated at that array-index shall not be printed to the output-String. Also, if this function ever returns null, then aNullPointerExceptionshall throw immediately.printNulls- When this parameter isTRUE, if a null is encountered within the input-parameter arrayT[] tArr, then null shall be passed to the Functional Interface input-parameter methodtoString.apply(T), and theStringresult from that method shall be inserted into theStringthat is returned.
When this parameter receivesFALSE, then anytime a null value is found within the input-parameter arrayT[] tArr, it will be skipped completely, and the outputStringwill simply contain one fewer output-String.maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- a CSV version of the input parameter
'tArr'where each instance of'T'shall have been converted to aStringusing 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 ifsPosis greater-than-or-equal-to thelengthof theArray - If
'ePos'is zero, or greater than the length of theArray - If the value of
'sPos'is a larger integer than'ePos'. If'ePos'was negative, it is first reset toArray.length, before this check is done.
- If
java.lang.NullPointerException- if parameter'toString'is null, or if any of the return values produced by'toString'are null- Code:
- Exact Method Body:
return TArr1D.toCSV2(tArr, sPos, ePos, toString, printNulls, maxLength);
-
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 aString.- Type Parameters:
T- The type used by theT[][]-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 theat that Array location. ThetoString.apply(int, int,method inside this lambda should return any Java) Stringto be printed to the output, for the given array-location and value.Note: This lambda may return a zero-lengthString, and when or if it does, that particular array-location will be 'skipped' (not printed) to the outputString.
Also: This parameter may be null, and if it is, it will be ignored and all array-, themselves, will simply be printed to the output's Stringinstead.
Finally: If this lambda's'apply'function ever returns null, it will result in aNullPointerExceptionkeepRow- This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicatereceives an'int'that corresponds to the first-order array index (the outer-array-index, a.k.a.'). When this lambda-[x][]' PredicatereturnsTRUEthe inner sub-array'will be included in the output-[]' String. When this lamda returnsFALSE, the entire sub-array will be eliminated from the output-String.Again: When this lamda-Predicatereceives null, it is ignored, meaning all sub-arrays are printed to the output-String- or at least untilmaxLengthInneris 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, allinner-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 typeInteger. This means, you may pass'80'here, rather than worrying about passingInteger.valueOf(80). Again, you may also pass'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.
When this parameter receives a non-nullint, its intention is to specify an outputString's'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximumStringlength' 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 parametermaxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the outputString- not the number array-element's .
Finally: Because the output-Stringsub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than'7'. If it is not, anIllegalArgumentExceptionis 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 tomaxLengthOter, 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. aString-length).
Remember that printing a large-two dimensional array will will result in a very longString. In conjunction with the'separateLines'paramater and/or empty-Stringreturn-values from the'toString'lambda, the length of the output-Stringcan 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:
return TArr2D.toCSV (tArr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
-
toCSV
public static java.lang.String toCSV (byte[] arr, IntByteFunction<java.lang.String> toString, java.lang.Integer maxLength)
- Code:
- Exact Method Body:
return Byte1D.toCSV(arr, 0, -1, toString, maxLength);
-
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 thebyte'sfrom an input array by commas, and print them to aString(which it then returns). The user may specify a functional-interface so that the values inside the CSV-Stringare 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 ofbyte.sPos- This is the (integer)Array-index that sets a limit for the left-mostArray-position to inspect/search inside the inputArray-parameter. This value is considered 'inclusive' meaning that the element at thisArray-index will be visited by this method.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-mostArray-position to inspect/search inside the inputVector-parameter. This value is considered 'exclusive' meaning that the element at thisArray-index will not be visited by this method.If this value is larger than the length of input theArray-parameter, an exception will throw.
Passing a negative value to this parameter,'ePos', will cause its value to be reset to the length of the inputArray-parameter.toString- This should be an implementation of functional-interfaceIntByteFunction<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 actualbytethat is located atarr[i].
- Output:
String
This output parameter must return anyStringthe users wishes to be appended to the comma-separated outputStringfor the passedIntByteFunctionand array index.
NOTE: If this function returns null,NullPointerExceptionwill throw, however when this function returns a zero-lengthString, for a particular array-index andbytecombination, then thatbyteshall not be printed to the outputString
This 'toString' parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-Stringthat is returned will simply have the array-numbers themselves, unmodified, printed to theString, and separated by commas.- Input 1:
maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- A
Stringthat contains thebyteelements of this array, separated by comma's. If a valid instance ofIntByteFunctionhas 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 ifsPosis greater-than-or-equal-to thelengthof theArray - If
'ePos'is zero, or greater than the length of theArray - If the value of
'sPos'is a larger integer than'ePos'. If'ePos'was negative, it is first reset toArray.length, before this check is done.
- If
java.lang.NullPointerException- If'toString'returns a null value.- Code:
- Exact Method Body:
return Byte1D.toCSV(arr, sPos, ePos, toString, maxLength);
-
toCSV
public static java.lang.String toCSV (short[] arr, IntShortFunction<java.lang.String> toString, java.lang.Integer maxLength)
- Code:
- Exact Method Body:
return Short1D.toCSV(arr, 0, -1, toString, maxLength);
-
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 theshort'sfrom an input array by commas, and print them to aString(which it then returns). The user may specify a functional-interface so that the values inside the CSV-Stringare 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 ofshort-integers.sPos- This is the (integer)Array-index that sets a limit for the left-mostArray-position to inspect/search inside the inputArray-parameter. This value is considered 'inclusive' meaning that the element at thisArray-index will be visited by this method.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-mostArray-position to inspect/search inside the inputVector-parameter. This value is considered 'exclusive' meaning that the element at thisArray-index will not be visited by this method.If this value is larger than the length of input theArray-parameter, an exception will throw.
Passing a negative value to this parameter,'ePos', will cause its value to be reset to the length of the inputArray-parameter.toString- This should be an implementation of functional-interfaceIntShortFunction<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 actualshortthat is located atarr[i].
- Output:
String
This output parameter must return anyStringthe users wishes to be appended to the comma-separated outputStringfor the passedIntShortFunctionand array index.
NOTE: If this function returns null,NullPointerExceptionwill throw, however when this function returns a zero-lengthString, for a particular array-index andshortcombination, then thatshortshall not be printed to the outputString
This 'toString' parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-Stringthat is returned will simply have the array-numbers themselves, unmodified, printed to theString, and separated by commas.- Input 1:
maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- A
Stringthat contains theshortelements of this array, separated by comma's. If a valid instance ofIntShortFunctionhas 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 ifsPosis greater-than-or-equal-to thelengthof theArray - If
'ePos'is zero, or greater than the length of theArray - If the value of
'sPos'is a larger integer than'ePos'. If'ePos'was negative, it is first reset toArray.length, before this check is done.
- If
java.lang.NullPointerException- If'toString'returns a null value.- Code:
- Exact Method Body:
return Short1D.toCSV(arr, sPos, ePos, toString, maxLength);
-
toCSV
public static java.lang.String toCSV (int[] arr, BiIntFunction<java.lang.String> toString, java.lang.Integer maxLength)
- Code:
- Exact Method Body:
return Int1D.toCSV(arr, 0, -1, toString, maxLength);
-
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 theint'sfrom an input array by commas, and print them to aString(which it then returns). The user may specify a functional-interface so that the values inside the CSV-Stringare 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-mostArray-position to inspect/search inside the inputArray-parameter. This value is considered 'inclusive' meaning that the element at thisArray-index will be visited by this method.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-mostArray-position to inspect/search inside the inputVector-parameter. This value is considered 'exclusive' meaning that the element at thisArray-index will not be visited by this method.If this value is larger than the length of input theArray-parameter, an exception will throw.
Passing a negative value to this parameter,'ePos', will cause its value to be reset to the length of the inputArray-parameter.toString- This should be an implementation of functional-interfaceBiIntFunction<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 actualintthat is located atarr[i].
- Output:
String
This output parameter must return anyStringthe users wishes to be appended to the comma-separated outputStringfor the passedBiIntFunctionand array index.
NOTE: If this function returns null,NullPointerExceptionwill throw, however when this function returns a zero-lengthString, for a particular array-index andintcombination, then thatintshall not be printed to the outputString
This 'toString' parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-Stringthat is returned will simply have the array-numbers themselves, unmodified, printed to theString, and separated by commas.- Input 1:
maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- A
Stringthat contains theintelements of this array, separated by comma's. If a valid instance ofBiIntFunctionhas 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 ifsPosis greater-than-or-equal-to thelengthof theArray - If
'ePos'is zero, or greater than the length of theArray - If the value of
'sPos'is a larger integer than'ePos'. If'ePos'was negative, it is first reset toArray.length, before this check is done.
- If
java.lang.NullPointerException- If'toString'returns a null value.- Code:
- Exact Method Body:
return Int1D.toCSV(arr, sPos, ePos, toString, maxLength);
-
toCSV
public static java.lang.String toCSV (long[] arr, IntLongFunction<java.lang.String> toString, java.lang.Integer maxLength)
- Code:
- Exact Method Body:
return Long1D.toCSV(arr, 0, -1, toString, maxLength);
-
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 thelong'sfrom an input array by commas, and print them to aString(which it then returns). The user may specify a functional-interface so that the values inside the CSV-Stringare 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 oflong-integers.sPos- This is the (integer)Array-index that sets a limit for the left-mostArray-position to inspect/search inside the inputArray-parameter. This value is considered 'inclusive' meaning that the element at thisArray-index will be visited by this method.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-mostArray-position to inspect/search inside the inputVector-parameter. This value is considered 'exclusive' meaning that the element at thisArray-index will not be visited by this method.If this value is larger than the length of input theArray-parameter, an exception will throw.
Passing a negative value to this parameter,'ePos', will cause its value to be reset to the length of the inputArray-parameter.toString- This should be an implementation of functional-interfaceIntLongFunction<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 actuallongthat is located atarr[i].
- Output:
String
This output parameter must return anyStringthe users wishes to be appended to the comma-separated outputStringfor the passedIntLongFunctionand array index.
NOTE: If this function returns null,NullPointerExceptionwill throw, however when this function returns a zero-lengthString, for a particular array-index andlongcombination, then thatlongshall not be printed to the outputString
This 'toString' parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-Stringthat is returned will simply have the array-numbers themselves, unmodified, printed to theString, and separated by commas.- Input 1:
maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- A
Stringthat contains thelongelements of this array, separated by comma's. If a valid instance ofIntLongFunctionhas 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 ifsPosis greater-than-or-equal-to thelengthof theArray - If
'ePos'is zero, or greater than the length of theArray - If the value of
'sPos'is a larger integer than'ePos'. If'ePos'was negative, it is first reset toArray.length, before this check is done.
- If
java.lang.NullPointerException- If'toString'returns a null value.- Code:
- Exact Method Body:
return Long1D.toCSV(arr, sPos, ePos, toString, maxLength);
-
toCSV
public static java.lang.String toCSV (float[] arr, IntFloatFunction<java.lang.String> toString, java.lang.Integer maxLength)
- Code:
- Exact Method Body:
return Float1D.toCSV(arr, 0, -1, toString, maxLength);
-
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 thefloat'sfrom an input array by commas, and print them to aString(which it then returns). The user may specify a functional-interface so that the values inside the CSV-Stringare 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 offloat.sPos- This is the (integer)Array-index that sets a limit for the left-mostArray-position to inspect/search inside the inputArray-parameter. This value is considered 'inclusive' meaning that the element at thisArray-index will be visited by this method.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-mostArray-position to inspect/search inside the inputVector-parameter. This value is considered 'exclusive' meaning that the element at thisArray-index will not be visited by this method.If this value is larger than the length of input theArray-parameter, an exception will throw.
Passing a negative value to this parameter,'ePos', will cause its value to be reset to the length of the inputArray-parameter.toString- This should be an implementation of functional-interfaceIntFloatFunction<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 actualfloatthat is located atarr[i].
- Output:
String
This output parameter must return anyStringthe users wishes to be appended to the comma-separated outputStringfor the passedIntFloatFunctionand array index.
NOTE: If this function returns null,NullPointerExceptionwill throw, however when this function returns a zero-lengthString, for a particular array-index andfloatcombination, then thatfloatshall not be printed to the outputString
This 'toString' parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-Stringthat is returned will simply have the array-numbers themselves, unmodified, printed to theString, and separated by commas.- Input 1:
maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- A
Stringthat contains thefloatelements of this array, separated by comma's. If a valid instance ofIntFloatFunctionhas 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 ifsPosis greater-than-or-equal-to thelengthof theArray - If
'ePos'is zero, or greater than the length of theArray - If the value of
'sPos'is a larger integer than'ePos'. If'ePos'was negative, it is first reset toArray.length, before this check is done.
- If
java.lang.NullPointerException- If'toString'returns a null value.- Code:
- Exact Method Body:
return Float1D.toCSV(arr, sPos, ePos, toString, maxLength);
-
toCSV
public static java.lang.String toCSV (double[] arr, IntDoubleFunction<java.lang.String> toString, java.lang.Integer maxLength)
- Code:
- Exact Method Body:
return Double1D.toCSV(arr, 0, -1, toString, maxLength);
-
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 thedouble'sfrom an input array by commas, and print them to aString(which it then returns). The user may specify a functional-interface so that the values inside the CSV-Stringare 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 ofdouble.sPos- This is the (integer)Array-index that sets a limit for the left-mostArray-position to inspect/search inside the inputArray-parameter. This value is considered 'inclusive' meaning that the element at thisArray-index will be visited by this method.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-mostArray-position to inspect/search inside the inputVector-parameter. This value is considered 'exclusive' meaning that the element at thisArray-index will not be visited by this method.If this value is larger than the length of input theArray-parameter, an exception will throw.
Passing a negative value to this parameter,'ePos', will cause its value to be reset to the length of the inputArray-parameter.toString- This should be an implementation of functional-interfaceIntDoubleFunction<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 actualdoublethat is located atarr[i].
- Output:
String
This output parameter must return anyStringthe users wishes to be appended to the comma-separated outputStringfor the passedIntDoubleFunctionand array index.
NOTE: If this function returns null,NullPointerExceptionwill throw, however when this function returns a zero-lengthString, for a particular array-index anddoublecombination, then thatdoubleshall not be printed to the outputString
This 'toString' parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-Stringthat is returned will simply have the array-numbers themselves, unmodified, printed to theString, and separated by commas.- Input 1:
maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- A
Stringthat contains thedoubleelements of this array, separated by comma's. If a valid instance ofIntDoubleFunctionhas 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 ifsPosis greater-than-or-equal-to thelengthof theArray - If
'ePos'is zero, or greater than the length of theArray - If the value of
'sPos'is a larger integer than'ePos'. If'ePos'was negative, it is first reset toArray.length, before this check is done.
- If
java.lang.NullPointerException- If'toString'returns a null value.- Code:
- Exact Method Body:
return Double1D.toCSV(arr, sPos, ePos, toString, maxLength);
-
toCSV
public static java.lang.String toCSV (boolean[] arr, IntBoolFunction<java.lang.String> toString, java.lang.Integer maxLength)
- Code:
- Exact Method Body:
return Boolean1D.toCSV(arr, 0, -1, toString, maxLength);
-
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 theboolean'sfrom an input array by commas, and print them to aString(which it then returns). The user may specify a functional-interface so that the values inside the CSV-Stringare 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 ofboolean.sPos- This is the (integer)Array-index that sets a limit for the left-mostArray-position to inspect/search inside the inputArray-parameter. This value is considered 'inclusive' meaning that the element at thisArray-index will be visited by this method.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-mostArray-position to inspect/search inside the inputVector-parameter. This value is considered 'exclusive' meaning that the element at thisArray-index will not be visited by this method.If this value is larger than the length of input theArray-parameter, an exception will throw.
Passing a negative value to this parameter,'ePos', will cause its value to be reset to the length of the inputArray-parameter.toString- This should be an implementation of functional-interfaceIntBoolFunction<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 actualbooleanthat is located atarr[i].
- Output:
String
This output parameter must return anyStringthe users wishes to be appended to the comma-separated outputStringfor the passedIntBoolFunctionand array index.
NOTE: If this function returns null,NullPointerExceptionwill throw, however when this function returns a zero-lengthString, for a particular array-index andbooleancombination, then thatbooleanshall not be printed to the outputString
This 'toString' parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-Stringthat is returned will simply have the array-booleans themselves, unmodified, printed to theString, and separated by commas.- Input 1:
maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- A
Stringthat contains thebooleanelements of this array, separated by comma's. If a valid instance ofIntBoolFunctionhas 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 ifsPosis greater-than-or-equal-to thelengthof theArray - If
'ePos'is zero, or greater than the length of theArray - If the value of
'sPos'is a larger integer than'ePos'. If'ePos'was negative, it is first reset toArray.length, before this check is done.
- If
java.lang.NullPointerException- If'toString'returns a null value.- Code:
- Exact Method Body:
return Boolean1D.toCSV(arr, sPos, ePos, toString, maxLength);
-
toCSV
public static java.lang.String toCSV (char[] arr, IntCharFunction<java.lang.String> toString, java.lang.Integer maxLength)
- Code:
- Exact Method Body:
return Char1D.toCSV(arr, 0, -1, toString, maxLength);
-
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 thechar'sfrom an input array by commas, and print them to aString(which it then returns). The user may specify a functional-interface so that the values inside the CSV-Stringare 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 ofboolean.sPos- This is the (integer)Array-index that sets a limit for the left-mostArray-position to inspect/search inside the inputArray-parameter. This value is considered 'inclusive' meaning that the element at thisArray-index will be visited by this method.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-mostArray-position to inspect/search inside the inputVector-parameter. This value is considered 'exclusive' meaning that the element at thisArray-index will not be visited by this method.If this value is larger than the length of input theArray-parameter, an exception will throw.
Passing a negative value to this parameter,'ePos', will cause its value to be reset to the length of the inputArray-parameter.toString- This should be an implementation of functional-interfaceIntCharFunction<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 actualcharthat is located atarr[i].
- Output:
String
This output parameter must return anyStringthe users wishes to be appended to the comma-separated outputStringfor the passedIntCharFunctionand array index.
NOTE: If this function returns null,NullPointerExceptionwill throw, however when this function returns a zero-lengthString, for a particular array-index andcharcombination, then thatcharshall not be printed to the outputString
This 'toString' parameter may be null. If null is, indeed, passed to this function-pointer / functional-interface parameter, then the output CSV-Stringthat is returned will simply have the array-characters themselves, unmodified, printed to theString, and separated by commas.- Input 1:
maxLength- Allows a user request that the returnedStringhave length no longer than'maxLength'characters. If the final-computed CSV-Stringis longer than this parameter's value, it will be truncated tomaxLength - 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-Stringreturned. Furthermore, don't forget that Java Compiler syntax rules allow a primitive-'int'variable or literal to be passed to method-parameters of typejava.lang.Integer. For example'80'could be passed to this parameter, directly, instead of'Integer.valueOf(80)'. (Againnullmay also be passed.)- Returns:
- A
Stringthat contains thecharelements of this array, separated by comma's. If a valid instance ofIntCharFunctionhas 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 ifsPosis greater-than-or-equal-to thelengthof theArray - If
'ePos'is zero, or greater than the length of theArray - If the value of
'sPos'is a larger integer than'ePos'. If'ePos'was negative, it is first reset toArray.length, before this check is done.
- If
java.lang.NullPointerException- If'toString'returns a null value.- Code:
- Exact Method Body:
return Char1D.toCSV(arr, sPos, ePos, toString, maxLength);
-
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 dimensionalbyte-array to aString.- Parameters:
arr- This may be any Java Two-Dimensionalbyte-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 thebyteat that Array location. ThetoString.apply(int, int, byte)method inside this lambda should return any JavaStringto be printed to the output, for the given array-location and value.Note: This lambda may return a zero-lengthString, and when or if it does, that particular array-location will be 'skipped' (not printed) to the outputString.
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 outputStringinstead.
Finally: If this lambda's'apply'function ever returns null, it will result in aNullPointerExceptionkeepRow- This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicatereceives an'int'that corresponds to the first-order array index (the outer-array-index, a.k.a.'byte[x][]'). When this lambda-PredicatereturnsTRUEthe inner sub-array'byte[]'will be included in the output-String. When this lamda returnsFALSE, the entire sub-array will be eliminated from the output-String.Again: When this lamda-Predicatereceives null, it is ignored, meaning all sub-arrays are printed to the output-String- or at least untilmaxLengthInneris 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, allbyte[]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 typeInteger. This means, you may pass'80'here, rather than worrying about passingInteger.valueOf(80). Again, you may also pass'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.
When this parameter receives a non-nullint, its intention is to specify an outputString's'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximumStringlength' 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 parametermaxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the outputString- not the number array-element byte's.
Finally: Because the output-Stringsub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than'7'. If it is not, anIllegalArgumentExceptionis 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 tomaxLengthOter, 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. aString-length).
Remember that printing a large-two dimensional array will will result in a very longString. In conjunction with the'separateLines'paramater and/or empty-Stringreturn-values from the'toString'lambda, the length of the output-Stringcan 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:
return Byte2D.toCSV (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
-
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 dimensionalshort-array to aString.- Parameters:
arr- This may be any Java Two-Dimensionalshort-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 theshortat that Array location. ThetoString.apply(int, int, short)method inside this lambda should return any JavaStringto be printed to the output, for the given array-location and value.Note: This lambda may return a zero-lengthString, and when or if it does, that particular array-location will be 'skipped' (not printed) to the outputString.
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 outputStringinstead.
Finally: If this lambda's'apply'function ever returns null, it will result in aNullPointerExceptionkeepRow- This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicatereceives an'int'that corresponds to the first-order array index (the outer-array-index, a.k.a.'short[x][]'). When this lambda-PredicatereturnsTRUEthe inner sub-array'short[]'will be included in the output-String. When this lamda returnsFALSE, the entire sub-array will be eliminated from the output-String.Again: When this lamda-Predicatereceives null, it is ignored, meaning all sub-arrays are printed to the output-String- or at least untilmaxLengthInneris 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, allshort[]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 typeInteger. This means, you may pass'80'here, rather than worrying about passingInteger.valueOf(80). Again, you may also pass'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.
When this parameter receives a non-nullint, its intention is to specify an outputString's'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximumStringlength' 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 parametermaxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the outputString- not the number array-element short's.
Finally: Because the output-Stringsub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than'7'. If it is not, anIllegalArgumentExceptionis 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 tomaxLengthOter, 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. aString-length).
Remember that printing a large-two dimensional array will will result in a very longString. In conjunction with the'separateLines'paramater and/or empty-Stringreturn-values from the'toString'lambda, the length of the output-Stringcan 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:
return Short2D.toCSV (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
-
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 dimensionalint-array to aString.- Parameters:
arr- This may be any Java Two-Dimensionalint-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 theintat that Array location. ThetoString.apply(int, int, int)method inside this lambda should return any JavaStringto be printed to the output, for the given array-location and value.Note: This lambda may return a zero-lengthString, and when or if it does, that particular array-location will be 'skipped' (not printed) to the outputString.
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 outputStringinstead.
Finally: If this lambda's'apply'function ever returns null, it will result in aNullPointerExceptionkeepRow- This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicatereceives an'int'that corresponds to the first-order array index (the outer-array-index, a.k.a.'int[x][]'). When this lambda-PredicatereturnsTRUEthe inner sub-array'int[]'will be included in the output-String. When this lamda returnsFALSE, the entire sub-array will be eliminated from the output-String.Again: When this lamda-Predicatereceives null, it is ignored, meaning all sub-arrays are printed to the output-String- or at least untilmaxLengthInneris 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, allint[]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 typeInteger. This means, you may pass'80'here, rather than worrying about passingInteger.valueOf(80). Again, you may also pass'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.
When this parameter receives a non-nullint, its intention is to specify an outputString's'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximumStringlength' 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 parametermaxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the outputString- not the number array-element int's.
Finally: Because the output-Stringsub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than'7'. If it is not, anIllegalArgumentExceptionis 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 tomaxLengthOter, 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. aString-length).
Remember that printing a large-two dimensional array will will result in a very longString. In conjunction with the'separateLines'paramater and/or empty-Stringreturn-values from the'toString'lambda, the length of the output-Stringcan 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:
return Int2D.toCSV (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
-
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 dimensionallong-array to aString.- Parameters:
arr- This may be any Java Two-Dimensionallong-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 thelongat that Array location. ThetoString.apply(int, int, long)method inside this lambda should return any JavaStringto be printed to the output, for the given array-location and value.Note: This lambda may return a zero-lengthString, and when or if it does, that particular array-location will be 'skipped' (not printed) to the outputString.
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 outputStringinstead.
Finally: If this lambda's'apply'function ever returns null, it will result in aNullPointerExceptionkeepRow- This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicatereceives an'int'that corresponds to the first-order array index (the outer-array-index, a.k.a.'long[x][]'). When this lambda-PredicatereturnsTRUEthe inner sub-array'long[]'will be included in the output-String. When this lamda returnsFALSE, the entire sub-array will be eliminated from the output-String.Again: When this lamda-Predicatereceives null, it is ignored, meaning all sub-arrays are printed to the output-String- or at least untilmaxLengthInneris 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, alllong[]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 typeInteger. This means, you may pass'80'here, rather than worrying about passingInteger.valueOf(80). Again, you may also pass'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.
When this parameter receives a non-nullint, its intention is to specify an outputString's'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximumStringlength' 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 parametermaxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the outputString- not the number array-element long's.
Finally: Because the output-Stringsub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than'7'. If it is not, anIllegalArgumentExceptionis 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 tomaxLengthOter, 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. aString-length).
Remember that printing a large-two dimensional array will will result in a very longString. In conjunction with the'separateLines'paramater and/or empty-Stringreturn-values from the'toString'lambda, the length of the output-Stringcan 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:
return Long2D.toCSV (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
-
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 dimensionalfloat-array to aString.- Parameters:
arr- This may be any Java Two-Dimensionalfloat-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 thefloatat that Array location. ThetoString.apply(int, int, float)method inside this lambda should return any JavaStringto be printed to the output, for the given array-location and value.Note: This lambda may return a zero-lengthString, and when or if it does, that particular array-location will be 'skipped' (not printed) to the outputString.
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 outputStringinstead.
Finally: If this lambda's'apply'function ever returns null, it will result in aNullPointerExceptionkeepRow- This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicatereceives an'int'that corresponds to the first-order array index (the outer-array-index, a.k.a.'float[x][]'). When this lambda-PredicatereturnsTRUEthe inner sub-array'float[]'will be included in the output-String. When this lamda returnsFALSE, the entire sub-array will be eliminated from the output-String.Again: When this lamda-Predicatereceives null, it is ignored, meaning all sub-arrays are printed to the output-String- or at least untilmaxLengthInneris 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, allfloat[]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 typeInteger. This means, you may pass'80'here, rather than worrying about passingInteger.valueOf(80). Again, you may also pass'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.
When this parameter receives a non-nullint, its intention is to specify an outputString's'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximumStringlength' 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 parametermaxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the outputString- not the number array-element float's.
Finally: Because the output-Stringsub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than'7'. If it is not, anIllegalArgumentExceptionis 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 tomaxLengthOter, 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. aString-length).
Remember that printing a large-two dimensional array will will result in a very longString. In conjunction with the'separateLines'paramater and/or empty-Stringreturn-values from the'toString'lambda, the length of the output-Stringcan 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:
return Float2D.toCSV (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
-
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 dimensionaldouble-array to aString.- Parameters:
arr- This may be any Java Two-Dimensionaldouble-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 thedoubleat that Array location. ThetoString.apply(int, int, double)method inside this lambda should return any JavaStringto be printed to the output, for the given array-location and value.Note: This lambda may return a zero-lengthString, and when or if it does, that particular array-location will be 'skipped' (not printed) to the outputString.
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 outputStringinstead.
Finally: If this lambda's'apply'function ever returns null, it will result in aNullPointerExceptionkeepRow- This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicatereceives an'int'that corresponds to the first-order array index (the outer-array-index, a.k.a.'double[x][]'). When this lambda-PredicatereturnsTRUEthe inner sub-array'double[]'will be included in the output-String. When this lamda returnsFALSE, the entire sub-array will be eliminated from the output-String.Again: When this lamda-Predicatereceives null, it is ignored, meaning all sub-arrays are printed to the output-String- or at least untilmaxLengthInneris 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, alldouble[]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 typeInteger. This means, you may pass'80'here, rather than worrying about passingInteger.valueOf(80). Again, you may also pass'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.
When this parameter receives a non-nullint, its intention is to specify an outputString's'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximumStringlength' 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 parametermaxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the outputString- not the number array-element double's.
Finally: Because the output-Stringsub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than'7'. If it is not, anIllegalArgumentExceptionis 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 tomaxLengthOter, 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. aString-length).
Remember that printing a large-two dimensional array will will result in a very longString. In conjunction with the'separateLines'paramater and/or empty-Stringreturn-values from the'toString'lambda, the length of the output-Stringcan 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:
return Double2D.toCSV (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
-
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 dimensionalchar-array to aString.- Parameters:
arr- This may be any Java Two-Dimensionalchar-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 thecharat that Array location. ThetoString.apply(int, int, char)method inside this lambda should return any JavaStringto be printed to the output, for the given array-location and value.Note: This lambda may return a zero-lengthString, and when or if it does, that particular array-location will be 'skipped' (not printed) to the outputString.
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 outputStringinstead.
Finally: If this lambda's'apply'function ever returns null, it will result in aNullPointerExceptionkeepRow- This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicatereceives an'int'that corresponds to the first-order array index (the outer-array-index, a.k.a.'char[x][]'). When this lambda-PredicatereturnsTRUEthe inner sub-array'char[]'will be included in the output-String. When this lamda returnsFALSE, the entire sub-array will be eliminated from the output-String.Again: When this lamda-Predicatereceives null, it is ignored, meaning all sub-arrays are printed to the output-String- or at least untilmaxLengthInneris 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, allchar[]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 typeInteger. This means, you may pass'80'here, rather than worrying about passingInteger.valueOf(80). Again, you may also pass'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.
When this parameter receives a non-nullint, its intention is to specify an outputString's'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximumStringlength' 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 parametermaxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the outputString- not the number array-element char's.
Finally: Because the output-Stringsub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than'7'. If it is not, anIllegalArgumentExceptionis 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 tomaxLengthOter, 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. aString-length).
Remember that printing a large-two dimensional array will will result in a very longString. In conjunction with the'separateLines'paramater and/or empty-Stringreturn-values from the'toString'lambda, the length of the output-Stringcan 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:
return Char2D.toCSV (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
-
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 dimensionalboolean-array to aString.- Parameters:
arr- This may be any Java Two-Dimensionalboolean-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 thebooleanat that Array location. ThetoString.apply(int, int, boolean)method inside this lambda should return any JavaStringto be printed to the output, for the given array-location and value.Note: This lambda may return a zero-lengthString, and when or if it does, that particular array-location will be 'skipped' (not printed) to the outputString.
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 outputStringinstead.
Finally: If this lambda's'apply'function ever returns null, it will result in aNullPointerExceptionkeepRow- This parameter may also be passed null, and if it is, it's also ignored. This integer-Predicatereceives an'int'that corresponds to the first-order array index (the outer-array-index, a.k.a.'boolean[x][]'). When this lambda-PredicatereturnsTRUEthe inner sub-array'boolean[]'will be included in the output-String. When this lamda returnsFALSE, the entire sub-array will be eliminated from the output-String.Again: When this lamda-Predicatereceives null, it is ignored, meaning all sub-arrays are printed to the output-String- or at least untilmaxLengthInneris 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, allboolean[]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 typeInteger. This means, you may pass'80'here, rather than worrying about passingInteger.valueOf(80). Again, you may also pass'null', effectively making thie somewhat similar to a JavaScript "Optional" parameter.
When this parameter receives a non-nullint, its intention is to specify an outputString's'maximum-length' - for the 'Inner' Arrays (sub-Arrays). When this 'maximumStringlength' 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 parametermaxLengthOuter, this parameter is specifying the maximum number of characters that the user wants printed to the outputString- not the number array-element boolean's.
Finally: Because the output-Stringsub-arrays contain spaces, commas, and brackets, when a positive integer is passed here, that integer must be greater than'7'. If it is not, anIllegalArgumentExceptionis 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 tomaxLengthOter, 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. aString-length).
Remember that printing a large-two dimensional array will will result in a very longString. In conjunction with the'separateLines'paramater and/or empty-Stringreturn-values from the'toString'lambda, the length of the output-Stringcan 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:
return Boolean2D.toCSV (arr, toString, keepRow, separateLines, maxLengthInner, maxLengthOuter);
-
-