Class ArrayParser

java.lang.Object
io.deephaven.jdbc.util.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 Details

    • getInstance

      public static ArrayParser getInstance(String delimiter)
    • getDoubleArray

      public double[] getDoubleArray(String value, boolean strict)
      Parse the given string as an array of doubles, based upon the delimiter.
      Parameters:
      value - string to parse
      strict - fail if the pattern does not begin / end with: [], {}, or ()
      Returns:
      array of parsed values
    • getLongArray

      public long[] getLongArray(String value, boolean strict)
      Parse the given string as an array of longs, based upon the delimiter.
      Parameters:
      value - string the to parse
      strict - fail if the pattern does not begin / end with: [], {}, or ()
      Returns:
      array of parsed values
    • getArray

      public <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.
      Type Parameters:
      T - the type
      Parameters:
      value - The array string value
      strict - fail if the pattern does not begin / end with: [], {}, or ()
      elementSupplier - a supplier to convert a stream of element strings to items of the correct types
      Returns:
      an array of values of the specified type
    • encodeArray

      public String encodeArray(double[] array)
      Convert the given array to a String.
      Parameters:
      array - the array
      Returns:
      array encoded as string
    • encodeArray

      public String encodeArray(long[] array)
      Convert the given array to a String.
      Parameters:
      array - the array
      Returns:
      array encoded as string