Package com.illumon.iris.utils
Class ArrayParser
java.lang.Object
com.illumon.iris.utils.ArrayParser
public class ArrayParser extends Object
A simple wrapper for string-to-array parsing. Parsers are kept in a cache per-delimiter so that we avoid
recompiling the pattern regex.
-
Method Summary
Modifier and Type Method Description String
encodeArray(double[] array)
Convert the given array to a String.String
encodeArray(long[] array)
Convert the given array to a String.<T> T
getArray(String value, boolean strict, Function<Stream<String>,T> elementSupplier)
Create a properly typed array from the input string based upon the delimiter, given a supplier.double[]
getDoubleArray(String value, boolean strict)
Parse the given string as an array of doubles, based upon the delimiter.static ArrayParser
getInstance(String delimiter)
long[]
getLongArray(String value, boolean strict)
Parse the given string as an array of longs, based upon the delimiter.String[]
toStringArray(String value, boolean strict)
Split the input string into an array of strings based on the delimiter.
-
Method Details
-
getInstance
-
getDoubleArray
Parse the given string as an array of doubles, based upon the delimiter.- Parameters:
value
- string to parsestrict
- enforce format strictly- Returns:
- array of parsed values
-
getLongArray
Parse the given string as an array of longs, based upon the delimiter.- Parameters:
value
- string the to parsestrict
- enforce format strictly- Returns:
- array of parsed values
-
getArray
Create a properly typed array from the input string based upon the delimiter, given a supplier.- Type Parameters:
T
- the type- Parameters:
value
- The array string valuestrict
- if strict processing should be usedelementSupplier
- a supplier to convert a stream of element strings to items of the correct types- Returns:
- an array of values of the specified type
-
toStringArray
Split the input string into an array of strings based on the delimiter.- Parameters:
value
- the array as a stringstrict
- if strict processing should be used- Returns:
- an array of strings
-
encodeArray
Convert the given array to a String.- Parameters:
array
- the array- Returns:
- array encoded as string
-
encodeArray
Convert the given array to a String.- Parameters:
array
- the array- Returns:
- array encoded as string
-