Class CsvFieldWriter

Direct Known Subclasses:
CsvFieldWriter.EndOfRecordWriter, CsvFieldWriter.RowFlagsWriter, PartitionDateFileTimeFieldWriter

public abstract class CsvFieldWriter extends BaseCsvFieldWriter
Abstract class providing methods used when reading data from CSV files to be written to Deephaven columns.
  • Constructor Details

    • CsvFieldWriter

      public CsvFieldWriter(com.fishlib.io.logger.Logger log, String dbColumnName, String delimiter)
  • Method Details

    • getSourceValue

      public String getSourceValue(org.apache.commons.csv.CSVRecord record)
    • processField

      public void processField(org.apache.commons.csv.CSVRecord record) throws IOException
      Throws:
      IOException
    • processValues

      public List<CustomSetterValue<?>> processValues(@NotNull Map<String,Object[]> columnNameToValueMap, int size, long destEnd) throws RowProcessingException
      The method is invoked by the CustomSetter Column Parser by incorporating the values from all dependent columns If dependent columns are not provided then the map would contain values from all the columns Note no change for Constant Column values they need to be retrieved using ImportFieldWriter.getConstantColumnValue(String)
      Overrides:
      processValues in class BaseCsvFieldWriter
      Parameters:
      columnNameToValueMap - The column name to corresponding CustomValue array map
      size - The size of the chunk, which is the same as the size of CustomSetterValue array in the map
      destEnd - The exclusive end index of the destination range.
      Returns:
      The processed custom setter column values for each row
      Throws:
      RowProcessingException - Thrown if processing errors occur when parsing to create Csv records
    • asString

      public String asString(Object value)
      Checks if value is an array and returns a string representation of the array appropriately. For all other values the toString() is returned.
      Parameters:
      value - The object value that should be converted to string
      Returns:
      the appropriate value as String
    • getShort

      @DynamicUse public static short getShort(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, short onEmpty)
      Reads a short value from a CSVRecord
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getInt

      @DynamicUse public static int getInt(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, int onEmpty)
      Reads an int value from a CSVRecord
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getLong

      @DynamicUse public static long getLong(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, long onEmpty)
      Reads a long value from a CSVRecord
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getISONanos

      @DynamicUse public static long getISONanos(@Nullable String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, long onEmpty)
      Reads a ISO formatted date value from a CSVRecord and converts it to nanoseconds since the epoch. This parser is a little less strict than ISO, in that it will accept time zone offsets without colons.
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getDouble

      @DynamicUse public static double getDouble(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, double onEmpty)
      Reads a double value from a CSVRecord
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getBigDecimal

      @DynamicUse public static BigDecimal getBigDecimal(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, @Nullable BigDecimal onEmpty)
      Reads a BigDecimal value from a CSVRecord
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getLocalDate

      @DynamicUse public static LocalDate getLocalDate(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, @Nullable LocalDate onEmpty)
      Read a LocalDate value from a CSVRecord.
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getLocalTime

      @DynamicUse public static LocalTime getLocalTime(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, @Nullable LocalTime onEmpty)
      Read a LocalTime value from a CSVRecord.
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getFloat

      @DynamicUse public static float getFloat(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, float onEmpty)
      Reads a float value from a CSVRecord
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getChar

      @DynamicUse public static char getChar(@Nullable String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, char onEmpty)
      Reads a char value from a CSVRecord
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getByte

      @DynamicUse public static byte getByte(@Nullable String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, byte onEmpty)
      Reads a byte value from a CSVRecord
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
    • getTrimmedStringNull

      @DynamicUse public static String getTrimmedStringNull(@Nullable String value, @Nullable String columnName)
      Reads a String value from a CSVRecord. Trims white space, and handles the special case of the word null being returned as a null String.
      Returns:
      the read value, or a null String if the field contains the keyword "null"
    • getBoolean

      @DynamicUse public static Boolean getBoolean(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, Boolean onEmpty)
      Reads a Boolean value from a CSVRecord. parseBoolean handles interpretation of various text boolean expressions (true, false, 1, 0, T, F, etc).
      Parameters:
      value - The value of the named column in the current row in the import file
      columnName - The column name from which the value should be read
      log - The passed-down logger
      strict - Whether strict (true) or permissive (false) import rules are being used
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      onEmpty - A default value that may be used if the source is empty or parsing fails
      Returns:
      the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself