Package com.illumon.iris.utils
Class ArrayParser
java.lang.Object
com.illumon.iris.utils.ArrayParser
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 TypeMethodDescriptionencodeArray(double[] array) Convert the given array to a String.encodeArray(long[] array) Convert the given array to a String.<T> TCreate 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 ArrayParsergetInstance(String delimiter) Returns the appropriate cached ArrayParser instance, if one doesn't exist a new one is created cached and returnedlong[]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
Returns the appropriate cached ArrayParser instance, if one doesn't exist a new one is created cached and returned- Parameters:
delimiter- The delimiter to use when splitting the string to extract appropriate individual array values- Returns:
- The ArrayParser Instance to use for the given delimiter
-
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
-