Class AbstractWriter<S extends CommonWriterSettings<?>>

java.lang.Object
com.univocity.parsers.common.AbstractWriter<S>
Type Parameters:
S - The specific writer settings configuration class, which can potentially provide additional configuration options supported by the writer implementation.
Direct Known Subclasses:
CsvWriter, FixedWidthWriter, TsvWriter

public abstract class AbstractWriter<S extends CommonWriterSettings<?>> extends Object
The AbstractWriter class provides a common ground for all writers in univocity-parsers. It handles all settings defined by CommonWriterSettings, and delegates the writing algorithm implementation to its subclasses through the abstract method processRow(Object[]) The following (absolutely required) attributes are exposed to subclasses:
  • appender (WriterCharAppender): the character writer that appends characters from a given input into an internal buffer
See Also:
  • Field Details

    • writerProcessor

      private final RowWriterProcessor writerProcessor
    • writer

      private Writer writer
    • skipEmptyLines

      private final boolean skipEmptyLines
    • comment

      protected final char comment
    • rowAppender

      private final WriterCharAppender rowAppender
    • isHeaderWritingEnabled

      private final boolean isHeaderWritingEnabled
    • outputRow

      private Object[] outputRow
    • indexesToWrite

      private int[] indexesToWrite
    • lineSeparator

      private final char[] lineSeparator
    • headers

      protected NormalizedString[] headers
    • recordCount

      protected long recordCount
    • nullValue

      protected final String nullValue
    • emptyValue

      protected final String emptyValue
    • appender

      protected final WriterCharAppender appender
    • partialLine

      private final Object[] partialLine
    • partialLineIndex

      private int partialLineIndex
    • headerIndexes

      private Map<NormalizedString[],Map<NormalizedString,Integer>> headerIndexes
    • largestRowLength

      private int largestRowLength
    • writingHeaders

      protected boolean writingHeaders
    • headerTrimFlags

      protected boolean[] headerTrimFlags
    • dummyHeaderRow

      private NormalizedString[] dummyHeaderRow
    • expandRows

      protected boolean expandRows
    • usingSwitch

      private boolean usingSwitch
    • enableNewlineAfterRecord

      private boolean enableNewlineAfterRecord
    • usingNullOrEmptyValue

      protected boolean usingNullOrEmptyValue
    • whitespaceRangeStart

      protected final int whitespaceRangeStart
    • columnReorderingEnabled

      private final boolean columnReorderingEnabled
    • ignoreLeading

      protected boolean ignoreLeading
    • ignoreTrailing

      protected boolean ignoreTrailing
    • internalSettings

      private final CommonSettings<DummyFormat> internalSettings
    • errorContentLength

      private final int errorContentLength
  • Constructor Details

    • AbstractWriter

      public AbstractWriter(S settings)
      All writers must support, at the very least, the settings provided by CommonWriterSettings. The AbstractWriter requires its configuration to be properly initialized. Important: by not providing an instance of Writer to this constructor, only the operations that write to Strings are available.
      Parameters:
      settings - the writer configuration
    • AbstractWriter

      public AbstractWriter(File file, S settings)
      All writers must support, at the very least, the settings provided by CommonWriterSettings. The AbstractWriter requires its configuration to be properly initialized.
      Parameters:
      file - the output file that will be written with the format-specific records as defined by subclasses of AbstractWriter.
      settings - the writer configuration
    • AbstractWriter

      public AbstractWriter(File file, String encoding, S settings)
      All writers must support, at the very least, the settings provided by CommonWriterSettings. The AbstractWriter requires its configuration to be properly initialized.
      Parameters:
      file - the output file that will be written with the format-specific records as defined by subclasses of AbstractWriter.
      encoding - the encoding of the file
      settings - the writer configuration
    • AbstractWriter

      public AbstractWriter(File file, Charset encoding, S settings)
      All writers must support, at the very least, the settings provided by CommonWriterSettings. The AbstractWriter requires its configuration to be properly initialized.
      Parameters:
      file - the output file that will be written with the format-specific records as defined by subclasses of AbstractWriter.
      encoding - the encoding of the file
      settings - the writer configuration
    • AbstractWriter

      public AbstractWriter(OutputStream output, S settings)
      All writers must support, at the very least, the settings provided by CommonWriterSettings. The AbstractWriter requires its configuration to be properly initialized.
      Parameters:
      output - the output stream that will be written with the format-specific records as defined by subclasses of AbstractWriter.
      settings - the writer configuration
    • AbstractWriter

      public AbstractWriter(OutputStream output, String encoding, S settings)
      All writers must support, at the very least, the settings provided by CommonWriterSettings. The AbstractWriter requires its configuration to be properly initialized.
      Parameters:
      output - the output stream that will be written with the format-specific records as defined by subclasses of AbstractWriter.
      encoding - the encoding of the stream
      settings - the writer configuration
    • AbstractWriter

      public AbstractWriter(OutputStream output, Charset encoding, S settings)
      All writers must support, at the very least, the settings provided by CommonWriterSettings. The AbstractWriter requires its configuration to be properly initialized.
      Parameters:
      output - the output stream that will be written with the format-specific records as defined by subclasses of AbstractWriter.
      encoding - the encoding of the stream
      settings - the writer configuration
    • AbstractWriter

      public AbstractWriter(Writer writer, S settings)
      All writers must support, at the very least, the settings provided by CommonWriterSettings. The AbstractWriter requires its configuration to be properly initialized.
      Parameters:
      writer - the output resource that will receive the format-specific records as defined by subclasses of AbstractWriter.
      settings - the writer configuration
  • Method Details

    • enableNewlineAfterRecord

      protected void enableNewlineAfterRecord(boolean enableNewlineAfterRecord)
    • initialize

      protected abstract void initialize(S settings)
      Initializes the concrete implementation of this class with format-specific settings.
      Parameters:
      settings - the settings object specific to the format being written.
    • updateIndexesToWrite

      private void updateIndexesToWrite(CommonSettings<?> settings)
      Update indexes to write based on the field selection provided by the user.
    • updateFieldSelection

      public void updateFieldSelection(String... newFieldSelection)
      Updates the selection of fields to write. This is useful if the input rows change during the writing process and their values need be allocated to specific columns.
      Parameters:
      newFieldSelection - the new selection of fields to write.
    • updateFieldSelection

      public void updateFieldSelection(Integer... newFieldSelectionByIndex)
      Updates the selection of fields to write. This is useful if the input rows change during the writing process and their values need be allocated to specific columns.
      Parameters:
      newFieldSelectionByIndex - the new selection of fields to write.
    • updateFieldExclusion

      public void updateFieldExclusion(String... fieldsToExclude)
      Updates the selection of fields to exclude when writing. This is useful if the input rows change during the writing process and their values need be allocated to specific columns.
      Parameters:
      fieldsToExclude - the selection of fields to exclude from the output.
    • updateFieldExclusion

      public void updateFieldExclusion(Integer... fieldIndexesToExclude)
      Updates the selection of fields to exclude when writing. This is useful if the input rows change during the writing process and their values need be allocated to specific columns.
      Parameters:
      fieldIndexesToExclude - the selection of fields to exclude from the output.
    • submitRow

      private void submitRow(Object[] row)
      Submits a row for processing by the format-specific implementation.
      Parameters:
      row - the data to be written for a single record in the output.
    • processRow

      protected abstract void processRow(Object[] row)
      Format-specific implementation for writing a single record into the output. The AbstractWriter handles the initialization and processing of the output until it is ready to be written (generally, reorganizing it and passing it on to a RowWriterProcessor). It then delegates the record to the writer-specific implementation defined by processRow(Object[]). In general, an implementation of processRow(Object[]) will perform the following steps:
      • Iterate over each object in the given input and convert it to the expected String representation.
      • The conversion must happen using the provided appender object. The an individual value is processed, the appendValueToRow() method must be called. This will clear the accumulated value in appender and add it to the output row.
      • Format specific separators and other characters must be introduced to the output row using appendToRow(char)
      Once the processRow(Object[]) method returns, a row will be written to the output with the processed information, and a newline will be automatically written after the given contents, unless this is a FixedWidthWriter whose FixedWidthWriterSettings.getWriteLineSeparatorAfterRecord() evaluates to false. The newline character sequence will conform to what is specified in Format.getLineSeparator() This cycle repeats until the writing process is stopped by the user or an error happens. In case of errors, the unchecked exception TextWritingException will be thrown and all resources in use will be closed automatically. The exception should contain the cause and more information about the output state when the error happened.
      Parameters:
      row - the data to be written to the output in the expected format.
      See Also:
    • appendValueToRow

      protected final void appendValueToRow()
      Appends the processed sequence of characters in appender to the output row.
    • appendToRow

      protected final void appendToRow(char ch)
      Appends the given character to the output row.
      Parameters:
      ch - the character to append to the output row
    • appendToRow

      protected final void appendToRow(char[] chars)
      Appends the given character sequence to the output row
      Parameters:
      chars - the sequence of characters to append to the output row
    • writeHeaders

      public final void writeHeaders()
      Writes the headers defined in CommonSettings.getHeaders() A TextWritingException will be thrown if no headers were defined or if records were already written to the output.
    • writeHeaders

      public final void writeHeaders(Collection<?> headers)
      Writes the given collection of headers to the output. A TextWritingException will be thrown if no headers were defined or if records were already written to the output.
      Parameters:
      headers - the headers to write to the output.
    • writeHeaders

      public final void writeHeaders(String... headers)
      Writes the given collection of headers to the output. A TextWritingException will be thrown if no headers were defined or if records were already written to the output.
      Parameters:
      headers - the headers to write to the output.
    • processRecordsAndClose

      public final void processRecordsAndClose(Iterable<?> allRecords)
      Iterates over all records, processes each one with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), and writes them, then finally and closes the output A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      allRecords - the records to be transformed by a RowWriterProcessor and then written to the output
    • processRecordsAndClose

      public final void processRecordsAndClose(Object[] allRecords)
      Iterates over all records, processes each one with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), and writes them, then finally and closes the output A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      allRecords - the records to be transformed by a RowWriterProcessor and then written to the output
    • processRecords

      public final void processRecords(Iterable<?> records)
      Iterates over all records, processes each one with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), and writes them. The output will remain open for further writing. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      records - the records to be transformed by a RowWriterProcessor and then written to the output
    • processRecords

      public final void processRecords(Object[] records)
      Iterates over all records, processes each one with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), and writes them. The output will remain open for further writing. * A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      records - the records to transformed by a RowWriterProcessor and then written to the output
    • processRecords

      public final <T extends Record> void processRecords(T[] records)
      Iterates over all records, processes each one with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), and writes them. The output will remain open for further writing. * A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      T - the concrete Record type
      Parameters:
      records - the records to transformed by a RowWriterProcessor and then written to the output
    • processRecord

      public final void processRecord(Object... record)
      Processes the data given for an individual record with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes it. The output will remain open for further writing. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      record - the information of a single record to be transformed by a RowWriterProcessor and then written to the output
    • processRecord

      public final <T extends Record> void processRecord(T record)
    • processRecord

      public final void processRecord(Object record)
      Processes the data given for an individual record with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes it. The output will remain open for further writing. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      record - the information of a single record to be transformed by a RowWriterProcessor and then written to the output
    • getRowProcessorHeaders

      private NormalizedString[] getRowProcessorHeaders()
    • writeRowsAndClose

      public final <C extends Collection<?>> void writeRowsAndClose(Iterable<C> allRows)
      Iterates over all records, writes them and closes the output. Note this method will not use the RowWriterProcessor. Use processRecordsAndClose(Iterable) for that.
      Type Parameters:
      C - Collection of objects containing values of a row
      Parameters:
      allRows - the rows to be written to the output
    • writeRowsAndClose

      public final void writeRowsAndClose(Collection<Object[]> allRows)
      Iterates over all records, writes them and closes the output. Note this method will not use the RowWriterProcessor. Use processRecordsAndClose(Object[]) for that.
      Parameters:
      allRows - the rows to be written to the output
    • writeStringRowsAndClose

      public final void writeStringRowsAndClose(Collection<String[]> allRows)
      Iterates over all records, writes them and closes the output. Note this method will not use the RowWriterProcessor. Use processRecordsAndClose(Iterable) for that.
      Parameters:
      allRows - the rows to be written to the output
    • writeRecordsAndClose

      public final void writeRecordsAndClose(Collection<? extends Record> allRows)
      Iterates over all records, writes them and closes the output. Note this method will not use the RowWriterProcessor. Use processRecordsAndClose(Iterable) for that.
      Parameters:
      allRows - the rows to be written to the output
    • writeRowsAndClose

      public final void writeRowsAndClose(Object[][] allRows)
      Iterates over all records, writes them and closes the output. Note this method will not use the RowWriterProcessor. Use processRecordsAndClose(Object[]) for that.
      Parameters:
      allRows - the rows to be written to the output
    • writeRows

      public final void writeRows(Object[][] rows)
      Iterates over all records and writes them to the output. The output will remain open for further writing. Note this method will not use the RowWriterProcessor. Use processRecords(Object[]) for that.
      Parameters:
      rows - the rows to be written to the output
    • writeRows

      public final <C extends Collection<?>> void writeRows(Iterable<C> rows)
      Iterates over all records and writes them to the output. The output will remain open for further writing. Note this method will not use the RowWriterProcessor. Use processRecords(Iterable) for that.
      Type Parameters:
      C - Collection of objects containing values of a row
      Parameters:
      rows - the rows to be written to the output
    • writeStringRows

      public final void writeStringRows(Collection<String[]> rows)
      Iterates over all records and writes them to the output. The output will remain open for further writing. Note this method will not use the RowWriterProcessor. Use processRecords(Iterable) for that.
      Parameters:
      rows - the rows to be written to the output
    • writeRecords

      public final void writeRecords(Collection<? extends Record> rows)
      Iterates over all records and writes them to the output. The output will remain open for further writing. Note this method will not use the RowWriterProcessor. Use processRecords(Iterable) for that.
      Parameters:
      rows - the rows to be written to the output
    • writeStringRows

      public final <C extends Collection<?>> void writeStringRows(Iterable<C> rows)
      Iterates over all records and writes them to the output. The output will remain open for further writing. Note this method will not use the RowWriterProcessor. Use processRecords(Iterable) for that.
      Type Parameters:
      C - Collection of objects containing values of a row
      Parameters:
      rows - the rows to be written to the output
    • writeRows

      public final void writeRows(Collection<Object[]> rows)
      Iterates over all records and writes them to the output. The output will remain open for further writing. Note this method will not use the RowWriterProcessor. Use processRecords(Iterable) for that.
      Parameters:
      rows - the rows to be written to the output
    • writeRow

      public final void writeRow(Collection<?> row)
      Writes the data given for an individual record. The output will remain open for further writing. Note this method will not use the RowWriterProcessor. Use processRecord(Object) for that.
      Parameters:
      row - the information of a single record to be written to the output
    • writeRow

      public final void writeRow(String[] row)
      Writes the data given for an individual record. The output will remain open for further writing. If the given data is null or empty, and CommonSettings.getSkipEmptyLines() is true, the input will be just ignored. If CommonSettings.getSkipEmptyLines() is false, then an empty row will be written to the output (as specified by writeEmptyRow()). In case of any errors, a TextWritingException will be thrown and the Writer given in the constructor will be closed. Note this method will not use the RowWriterProcessor. Use processRecord(Object) for that.
      Parameters:
      row - the information of a single record to be written to the output
    • writeRecord

      public final <T extends Record> void writeRecord(T row)
      Writes the data given for an individual record. The output will remain open for further writing. If the given data is null or empty, and CommonSettings.getSkipEmptyLines() is true, the input will be just ignored. If CommonSettings.getSkipEmptyLines() is false, then an empty row will be written to the output (as specified by writeEmptyRow()). In case of any errors, a TextWritingException will be thrown and the Writer given in the constructor will be closed. Note this method will not use the RowWriterProcessor. Use processRecord(Object) for that.
      Type Parameters:
      T - the concrete Record type
      Parameters:
      row - the information of a single record to be written to the output
    • writeRow

      public final void writeRow(Object... row)
      Writes the data given for an individual record. The output will remain open for further writing. If the given data is null or empty, and CommonSettings.getSkipEmptyLines() is true, the input will be just ignored. If CommonSettings.getSkipEmptyLines() is false, then an empty row will be written to the output (as specified by writeEmptyRow()). In case of any errors, a TextWritingException will be thrown and the Writer given in the constructor will be closed. Note this method will not use the RowWriterProcessor. Use processRecord(Object) for that.
      Parameters:
      row - the information of a single record to be written to the output
    • expand

      protected Object[] expand(Object[] row, int length, Integer h2)
    • writeRow

      public final void writeRow(String row)
      Writes a plain (potentially free-text) String as a line to the output. A newline will automatically written after the given contents, unless this is a FixedWidthWriter whose FixedWidthWriterSettings.getWriteLineSeparatorAfterRecord() evaluates to false. The newline character sequence will conform to what is specified in Format.getLineSeparator() The writer implementation has no control over the format of this content. The output will remain open for further writing.
      Parameters:
      row - the line to be written to the output
    • writeEmptyRow

      public final void writeEmptyRow()
      Writes an empty line to the output, unless this is a FixedWidthWriter whose FixedWidthWriterSettings.getWriteLineSeparatorAfterRecord() evaluates to false. The newline character sequence will conform to what is specified in Format.getLineSeparator() The output will remain open for further writing.
    • commentRow

      public final void commentRow(String comment)
      Writes a comment row to the output. A newline will automatically written after the given contents, unless this is a FixedWidthWriter whose FixedWidthWriterSettings.getWriteLineSeparatorAfterRecord() evaluates to false. The newline character sequence will conform to what is specified in Format.getLineSeparator() The output will remain open for further writing.
      Parameters:
      comment - the contents to be written as a comment to the output
    • fillOutputRow

      private <T> void fillOutputRow(T[] row)
      Used when fields were selected and the input rows have a different order than the output. This method fills the internal #outputRow array with the values provided by the user in the correct order.
      Parameters:
      row - user-provided data which has to be rearranged to the expected record sequence before writing to the output.
    • internalWriteRow

      private void internalWriteRow()
      Writes the accumulated value of a record to the output, followed by a newline, and increases the record count. The newline character sequence will conform to what is specified in Format.getLineSeparator() The contents of rowAppender depend on the concrete implementation of processRow(Object[])
    • skipLeadingWhitespace

      protected static int skipLeadingWhitespace(int whitespaceRangeStart, String element)
      Identifies the starting character index of a value being written if leading whitespaces are to be discarded. Implementation note whitespaces are considered all characters where ch <= ' ' evaluates to true
      Parameters:
      whitespaceRangeStart - starting range after which characters will be considered whitespace
      element - the String to be scanned for leading whitespaces.
      Returns:
      the index of the first non-whitespace character in the given element.
    • flush

      public final void flush()
      Flushes the Writer given in this class constructor. An IllegalStateException will be thrown in case of any errors, and the writer will be closed.
    • close

      public final void close()
      Closes the Writer given in this class constructor. An IllegalStateException will be thrown in case of any errors.
    • throwExceptionAndClose

      private TextWritingException throwExceptionAndClose(String message)
      In case of any exceptions, a TextWritingException is thrown, and the output Writer is closed.
      Parameters:
      message - Description of the error
    • throwExceptionAndClose

      private TextWritingException throwExceptionAndClose(String message, Throwable cause)
      In case of any exceptions, a TextWritingException is thrown, and the output Writer is closed.
      Parameters:
      message - Description of the error
      cause - the exception to be wrapped by a TextWritingException
    • throwExceptionAndClose

      private TextWritingException throwExceptionAndClose(String message, String recordCharacters, Throwable cause)
      In case of any exceptions, a TextWritingException is thrown, and the output Writer is closed.
      Parameters:
      message - Description of the error
      recordCharacters - characters used to write to the output at the time the exception happened
      cause - the exception to be wrapped by a TextWritingException
    • throwExceptionAndClose

      private TextWritingException throwExceptionAndClose(String message, Object[] recordValues, Throwable cause)
      In case of any exceptions, a TextWritingException is thrown, and the output Writer is closed.
      Parameters:
      message - Description of the error
      recordValues - values used to write to the output at the time the exception happened
      cause - the exception to be wrapped by a TextWritingException
    • getStringValue

      protected String getStringValue(Object element)
      Converts a given object to its String representation for writing to a String
      • If the object is null, then nullValue is returned.
      • If the String representation of this object is an empty String, then emptyValue is returned
      Parameters:
      element - the object to be converted into a String.
      Returns:
      the String representation of the given object
    • addValues

      public final void addValues(Object... values)
      Writes a sequence of values to a row in memory. Subsequent calls to this method will add the given values in a new column of the same row, until writeValuesToRow() is called to flush all values accumulated and effectively write a new record to the output
      Parameters:
      values - the values to be written
    • addStringValues

      public final void addStringValues(Collection<String> values)
      Writes a sequence of Strings to a row in memory. Subsequent calls to this method will add the given values in a new column of the same row, until writeValuesToRow() is called to flush all values accumulated and effectively write a new record to the output
      Parameters:
      values - the values to be written
    • addValues

      public final void addValues(Collection<?> values)
      Writes a sequence of values to a row in memory. Subsequent calls to this method will add the given values in a new column of the same row, until writeValuesToRow() is called to flush all values accumulated and effectively write a new record to the output
      Parameters:
      values - the values to be written
    • addValue

      public final void addValue(Object value)
      Writes a value to a row in memory. Subsequent calls to this method will add the given values in a new column of the same row, until writeValuesToRow() is called to flush all values accumulated and effectively write a new record to the output
      Parameters:
      value - the value to be written
    • fillPartialLineToMatchHeaders

      private void fillPartialLineToMatchHeaders()
    • writeValuesToRow

      public final void writeValuesToRow()
      Writes the contents accumulated in an internal in-memory row (using or #writeValue() to a new record in the output.
    • addValue

      public final void addValue(int index, Object value)
      Writes a value to a row in memory. Subsequent calls to this method will add the given values in a new column of the same row, until writeValuesToRow() is called to flush all values accumulated and effectively write a new record to the output
      Parameters:
      index - the position in the row that should receive the value.
      value - the value to be written
    • addValue

      public final void addValue(String headerName, Object value)
      Writes a value to a row in memory. Subsequent calls to this method will add the given values in a new column of the same row, until writeValuesToRow() is called to flush all values accumulated and effectively write a new record to the output
      Parameters:
      headerName - the name of the column of the new row that should receive the value.
      value - the value to be written
    • addValue

      private final void addValue(NormalizedString[] headersInContext, NormalizedString headerName, boolean ignoreOnMismatch, Object value)
    • getFieldIndex

      private int getFieldIndex(NormalizedString[] headersInContext, NormalizedString headerName, boolean ignoreOnMismatch)
      Calculates the index of a header name in relation to the original headers array defined in this writer
      Parameters:
      headersInContext - headers currently in use (they might change).
      headerName - the name of the header whose position will be identified
      ignoreOnMismatch - flag indicating that if the header is not found, no exception is to be thrown, and -1 should be returned instead.
      Returns:
      the position of the given header, or -1 if it's not found when ignoreOnMismatch is set to true
    • discardValues

      public final void discardValues()
      Discards the contents written to the internal in-memory row (using or #writeValue().
    • writeHeadersToString

      public final String writeHeadersToString()
      Writes the headers defined in CommonSettings.getHeaders() to a String
      Returns:
      a formatted String containing the headers defined in CommonSettings.getHeaders()
    • writeHeadersToString

      public final String writeHeadersToString(Collection<?> headers)
      Writes the given collection of headers to a String A TextWritingException will be thrown if no headers were defined.
      Parameters:
      headers - the headers to write to a String
      Returns:
      a formatted String containing the given headers
    • writeHeadersToString

      public final String writeHeadersToString(String... headers)
      Writes the given collection of headers to a String A TextWritingException will be thrown if no headers were defined or if records were already written to a String
      Parameters:
      headers - the headers to write to a String
      Returns:
      a formatted String containing the given headers
    • processRecordsToString

      public final List<String> processRecordsToString(Iterable<?> records)
      Iterates over all records, processes each one with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), and writes them to a List of String. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      records - the records to be transformed by a RowWriterProcessor and then written to a List of String.
      Returns:
      a List containing the information transformed from the given records as formatted Strings
    • processRecordsToString

      public final List<String> processRecordsToString(Object[] records)
      Iterates over all records, processes each one with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), and writes them them to a List of String. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      records - the records to transformed by a RowWriterProcessor and then written a String.
      Returns:
      a List containing the information transformed from the given records as formatted Strings
    • processRecordToString

      public final String processRecordToString(Object... record)
      Processes the data given for an individual record with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes it to a String. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      record - the information of a single record to be transformed by a RowWriterProcessor and then written to a String.
      Returns:
      a formatted String containing the information transformed from the given record
    • processRecordToString

      public final <T extends Record> String processRecordToString(T record)
      Processes the data given for an individual record with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes it to a String. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      T - the concrete Record type
      Parameters:
      record - the information of a single record to be transformed by a RowWriterProcessor and then written to a String.
      Returns:
      a formatted String containing the information transformed from the given record
    • processRecordToString

      public final String processRecordToString(Object record)
      Processes the data given for an individual record with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes it. The output will remain open for further writing. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      record - the information of a single record to be transformed by a RowWriterProcessor and then written to a String.
      Returns:
      a formatted String containing the information transformed from the given record
    • writeRowsToString

      public final List<String> writeRowsToString(Object[][] rows)
      Iterates over all records and writes them to a List of String. Note this method will not use the RowWriterProcessor. Use processRecords(Object[]) for that.
      Parameters:
      rows - the rows to be written to a List of String.
      Returns:
      a List containing the given rows as formatted Strings
    • writeRowsToString

      public final <C extends Collection<?>> List<String> writeRowsToString(Iterable<C> rows)
      Iterates over all records and writes them to a List of String. Note this method will not use the RowWriterProcessor. Use processRecords(Iterable) for that.
      Type Parameters:
      C - Collection of objects containing values of a row
      Parameters:
      rows - the rows to be written to a List of String.
      Returns:
      a List containing the given rows as formatted Strings
    • writeStringRowsToString

      public final <C extends Collection<?>> List<String> writeStringRowsToString(Iterable<C> rows)
      Iterates over all records and writes them to a List of String. Note this method will not use the RowWriterProcessor. Use processRecords(Iterable) for that.
      Type Parameters:
      C - Collection of objects containing values of a row
      Parameters:
      rows - the rows to be written to a List of String.
      Returns:
      a List containing the given rows as formatted Strings
    • writeRowsToString

      public final List<String> writeRowsToString(Collection<Object[]> rows)
      Iterates over all records and writes them to a List of String. Note this method will not use the RowWriterProcessor. Use processRecords(Iterable) for that.
      Parameters:
      rows - the rows to be written to a List of String.
      Returns:
      a List containing the given rows as formatted Strings
    • writeStringRowsToString

      public final List<String> writeStringRowsToString(Collection<String[]> rows)
      Iterates over all records and writes them to a List of String. Note this method will not use the RowWriterProcessor. Use processRecords(Iterable) for that.
      Parameters:
      rows - the rows to be written to a List of String.
      Returns:
      a List containing the given rows as formatted Strings
    • writeRecordsToString

      public final List<String> writeRecordsToString(Collection<? extends Record> rows)
      Iterates over all records and writes them to a List of String. Note this method will not use the RowWriterProcessor. Use processRecords(Iterable) for that.
      Parameters:
      rows - the rows to be written to a List of String.
      Returns:
      a List containing the given rows as formatted Strings
    • writeRowToString

      public final String writeRowToString(Collection<?> row)
      Writes the data given for an individual record to a String. Note this method will not use the RowWriterProcessor. Use processRecord(Object) for that.
      Parameters:
      row - the information of a single record to be written to a String
      Returns:
      a formatted String containing the information of the given record
    • writeRowToString

      public final String writeRowToString(String[] row)
      Writes the data given for an individual record to a String. If the given data is null or empty, and CommonSettings.getSkipEmptyLines() is true, null will be returned In case of any errors, a TextWritingException will be thrown. Note this method will not use the RowWriterProcessor. Use processRecord(Object) for that.
      Parameters:
      row - the information of a single record to be written to a String.
      Returns:
      a formatted String containing the information of the given record
    • writeRecordToString

      public final <T extends Record> String writeRecordToString(T row)
      Writes the data given for an individual record to a String. If the given data is null or empty, and CommonSettings.getSkipEmptyLines() is true, null will be returned In case of any errors, a TextWritingException will be thrown. Note this method will not use the RowWriterProcessor. Use processRecord(Object) for that.
      Parameters:
      row - the information of a single record to be written to a String.
      Returns:
      a formatted String containing the information of the given record
    • writeRowToString

      public final String writeRowToString(Object... row)
      Writes the data given for an individual record to a String. If the given data is null or empty, and CommonSettings.getSkipEmptyLines() is true, null will be returned In case of any errors, a TextWritingException will be thrown. Note this method will not use the RowWriterProcessor. Use processRecord(Object) for that.
      Parameters:
      row - the information of a single record to be written to a String.
      Returns:
      a formatted String containing the information of the given record
    • adjustRowLength

      private Object[] adjustRowLength(Object[] row)
    • commentRowToString

      public final String commentRowToString(String comment)
      Writes a comment row to a String
      Parameters:
      comment - the contents to be written as a comment to a String.
      Returns:
      a formatted String containing the comment.
    • internalWriteRowToString

      private String internalWriteRowToString()
      Writes the accumulated value of a record to the output, followed by a newline, and increases the record count. The newline character sequence will conform to what is specified in Format.getLineSeparator() The contents of rowAppender depend on the concrete implementation of processRow(Object[])
      Returns:
      a formatted String containing the comment.
    • writeValuesToString

      public final String writeValuesToString()
      Writes the contents accumulated in an internal in-memory row (using or #addValue() as a String
      Returns:
      a formatted String containing the information accumulated in the internal in-memory row.
    • processValuesToRow

      public final void processValuesToRow()
      Writes the contents accumulated in an internal in-memory row (using or #addValue() to a new record in the output. The objects added to this row will be processed with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(). The output will remain open for further writing. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
    • processValuesToString

      public final String processValuesToString()
      Writes the contents accumulated in an internal in-memory row (using or #addValue() to a String The objects added to this row will be processed with the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(). The output will remain open for further writing. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Returns:
      a formatted String containing the result produced by the RowWriterProcessor using the values accumulated in internal in-memory row.
    • getRecordCount

      public final long getRecordCount()
      Returns the number of records written to the output so far
      Returns:
      the number of records written to the output so far
    • writeValuesFromMap

      private <K> void writeValuesFromMap(Map<K,String> headerMapping, Map<K,?> rowData)
      Writes values from an implementation of Map to a partial output record, ready to be written to the output. Values will be stored under a column identified by the headers. If no headers are defined, the keys of the map will be used to initialize an internal header row. A map of headers can be optionally provided to assign a name to the keys of the input map. This is useful when the input map has keys will generate unwanted header names.
      Type Parameters:
      K - type of the key in both rowData and headerMapping maps.
      Parameters:
      headerMapping - an optional map associating keys of the rowData map with expected header names
      rowData - the data to be written. Its keys will be used to form a header row in case no headers are available.
    • setHeadersFromMap

      private void setHeadersFromMap(Map<?,?> map, boolean keys)
      Iterates over the keys of a map and builds an internal header row.
      Parameters:
      map - the input map whose keys will be used to generate headers for the output.
      keys - indicates whether to take the map keys or values to build the header rows.
    • writeRowToString

      public final String writeRowToString(Map<?,?> rowData)
      Writes the values of a given map to a String formatted to according to the specified output format. Note this method will not use the RowWriterProcessor.
      Parameters:
      rowData - the map whose values will be used to generate a String.
      Returns:
      a String containing the given data as a formatted String
    • writeRow

      public final void writeRow(Map<?,?> rowData)
      Writes the values of a given map into new output record Note this method will not use the RowWriterProcessor.
      Parameters:
      rowData - the map whose values will be used to generate a new record
    • writeRowToString

      public final <K> String writeRowToString(Map<K,String> headerMapping, Map<K,?> rowData)
      Writes the values of a given map to a String formatted to according to the specified output format. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a String.
      Returns:
      a String containing the given data as a formatted String
    • writeRow

      public final <K> void writeRow(Map<K,String> headerMapping, Map<K,?> rowData)
      Writes the values of a given map into new output record Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a new record
    • writeRowsToString

      public final <K, I extends Iterable<?>> List<String> writeRowsToString(Map<K,I> rowData)
      Writes the values of a given map to a List of String formatted to according to the specified output format. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a List of formatted String, each String representing one successful iteration over at least one element of the iterators in the map.
    • writeRows

      public final <K, I extends Iterable<?>> void writeRows(Map<K,I> rowData)
      Writes the values of a given map to multiple output records Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      rowData - the map whose values will be used to generate a number of output records
    • writeRowsToString

      public final <K, I extends Iterable<?>> List<String> writeRowsToString(Map<K,String> headerMapping, Map<K,I> rowData)
      Writes the values of a given map to a List of String formatted to according to the specified output format. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a List of formatted String, each String representing one successful iteration over at least one element of the iterators in the map.
    • writeRows

      public final <K, I extends Iterable<?>> void writeRows(Map<K,String> headerMapping, Map<K,I> rowData)
      Writes the values of a given map to multiple output records Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • writeRows

      private <K, I extends Iterable<?>> void writeRows(Map<K,String> headerMapping, Map<K,I> rowData, List<String> outputList, boolean useRowProcessor)
      Writes the values of a given map to a List of String formatted to according to the specified output format. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a List of String.
      outputList - an output List to fill with formatted Strings, each String representing one successful iteration over at least one element of the iterators in the map.
    • writeStringRowsToString

      public final <K> List<String> writeStringRowsToString(Map<K,String> headerMapping, Map<K,String[]> rowData)
      Writes the values of a given map to a List of String formatted to according to the specified output format. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a List of formatted String, each String representing one successful iteration over at least one element of the iterators in the map.
    • writeRecordsToString

      public final <K> List<String> writeRecordsToString(Map<K,String> headerMapping, Map<K,? extends Record> rowData)
      Writes the values of a given map to a List of String formatted to according to the specified output format. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a List of formatted String, each String representing one successful iteration over at least one element of the iterators in the map.
    • writeStringRows

      public final <K> void writeStringRows(Map<K,String> headerMapping, Map<K,String[]> rowData)
      Writes the values of a given map to multiple output records Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • writeRecords

      public final <K> void writeRecords(Map<K,String> headerMapping, Map<K,? extends Record> rowData)
      Writes the values of a given map to multiple output records Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • writeObjectRowsToString

      public final <K> List<String> writeObjectRowsToString(Map<K,String> headerMapping, Map<K,Object[]> rowData)
      Writes the values of a given map to a List of String formatted to according to the specified output format. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a List of formatted String, each String representing one successful iteration over at least one element of the iterators in the map.
    • writeObjectRows

      public final <K> void writeObjectRows(Map<K,String> headerMapping, Map<K,Object[]> rowData)
      Writes the values of a given map to multiple output records Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • wrapObjectArray

      private <K> Map<K,Iterable<Object>> wrapObjectArray(Map<K,Object[]> rowData)
    • wrapStringArray

      private <K> Map<K,Iterable<String>> wrapStringArray(Map<K,String[]> rowData)
    • wrapRecordValues

      private <K> Map<K,Iterable<String>> wrapRecordValues(Map<K,? extends Record> rowData)
    • writeObjectRowsAndClose

      public final <K> void writeObjectRowsAndClose(Map<K,String> headerMapping, Map<K,Object[]> rowData)
      Writes the values of a given map to multiple output records and closes the output when finished. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • writeStringRowsAndClose

      public final <K> void writeStringRowsAndClose(Map<K,String> headerMapping, Map<K,String[]> rowData)
      Writes the values of a given map to multiple output records and closes the output when finished. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • writeRecordsAndClose

      public final <K> void writeRecordsAndClose(Map<K,String> headerMapping, Map<K,? extends Record> rowData)
      Writes the values of a given map to multiple output records and closes the output when finished. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • writeObjectRowsAndClose

      public final <K> void writeObjectRowsAndClose(Map<K,Object[]> rowData)
      Writes the values of a given map to multiple output records and closes the output when finished. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      rowData - the map whose values will be used to generate a number of output records
    • writeStringRowsAndClose

      public final <K> void writeStringRowsAndClose(Map<K,String[]> rowData)
      Writes the values of a given map to multiple output records and closes the output when finished. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      rowData - the map whose values will be used to generate a number of output records
    • writeRecordsAndClose

      public final <K> void writeRecordsAndClose(Map<K,? extends Record> rowData)
      Writes the values of a given map to multiple output records and closes the output when finished. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      Parameters:
      rowData - the map whose values will be used to generate a number of output records
    • writeRowsAndClose

      public final <K, I extends Iterable<?>> void writeRowsAndClose(Map<K,String> headerMapping, Map<K,I> rowData)
      Writes the values of a given map to multiple output records and closes the output when finished. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • writeRowsAndClose

      public final <K, I extends Iterable<?>> void writeRowsAndClose(Map<K,I> rowData)
      Writes the values of a given map to multiple output records and closes the output when finished. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. Note this method will not use the RowWriterProcessor.
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      rowData - the map whose values will be used to generate a number of output records
    • processRecordToString

      public final String processRecordToString(Map<?,?> rowData)
      Processes the values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor() and writes the result into String formatted according to the specified output format. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a String containing the given data as a formatted String
    • processRecord

      public final void processRecord(Map<?,?> rowData)
      Processes the values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor() and writes the result into a new output record A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Parameters:
      rowData - the map whose values will be used to generate a List of String.
    • processRecordToString

      public final <K> String processRecordToString(Map<K,String> headerMapping, Map<K,?> rowData)
      Processes the values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor() and writes the result into String formatted according to the specified output format. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a String containing the given data as a formatted String
    • processRecord

      public final <K> void processRecord(Map<K,String> headerMapping, Map<K,?> rowData)
      Processes the values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor() and writes the result into a new output record A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a List of String.
    • processRecordsToString

      public final <K, I extends Iterable<?>> List<String> processRecordsToString(Map<K,I> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor() and writes the result into a List of String formatted to according to the specified output format. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a List of formatted String, each String representing one successful iteration over at least one element of the iterators in the map.
    • processRecords

      public final <K, I extends Iterable<?>> void processRecords(Map<K,I> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes all values to the output . The output will remain open for further write operations. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      rowData - the map whose values will be used to generate a number of output records
    • processRecordsToString

      public final <K, I extends Iterable<?>> List<String> processRecordsToString(Map<K,String> headerMapping, Map<K,I> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor() and writes the result into a List of String formatted to according to the specified output format. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a List of formatted String, each String representing one successful iteration over at least one element of the iterators in the map.
    • processRecords

      public final <K, I extends Iterable<?>> void processRecords(Map<K,String> headerMapping, Map<K,I> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes all values to the output . The output will remain open for further write operations. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • processObjectRecordsToString

      public final <K> List<String> processObjectRecordsToString(Map<K,Object[]> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor() and writes the result into a List of String formatted to according to the specified output format. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      Parameters:
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a List of formatted String, each String representing one successful iteration over at least one element of the iterators in the map.
    • processObjectRecordsToString

      public final <K> List<String> processObjectRecordsToString(Map<K,String> headerMapping, Map<K,Object[]> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor() and writes the result into a List of String formatted to according to the specified output format. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a List of String.
      Returns:
      a List of formatted String, each String representing one successful iteration over at least one element of the iterators in the map.
    • processObjectRecords

      public final <K> void processObjectRecords(Map<K,String> headerMapping, Map<K,Object[]> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes all values to the output . The output will remain open for further write operations. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • processObjectRecordsAndClose

      public final <K> void processObjectRecordsAndClose(Map<K,String> headerMapping, Map<K,Object[]> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes all values to the output and closes the writer. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • processObjectRecordsAndClose

      public final <K> void processObjectRecordsAndClose(Map<K,Object[]> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes all values to the output and closes the writer. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      Parameters:
      rowData - the map whose values will be used to generate a number of output records
    • processRecordsAndClose

      public final <K, I extends Iterable<?>> void processRecordsAndClose(Map<K,String> headerMapping, Map<K,I> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes all values to the output and closes the writer. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      headerMapping - a mapping associating the keys of the input map to their corresponding header names.
      rowData - the map whose values will be used to generate a number of output records
    • processRecordsAndClose

      public final <K, I extends Iterable<?>> void processRecordsAndClose(Map<K,I> rowData)
      Processes the data in all values of a map using the RowWriterProcessor provided by CommonWriterSettings.getRowWriterProcessor(), then writes all values to the output and closes the writer. Each value is expected to be iterable and the result of this method will produce the number of records equal to the longest iterable. A new record will be created each time at least one Iterator.hasNext() returns true. Null will be written when a iterator has been fully read. A TextWritingException will be thrown if no RowWriterProcessor is provided by CommonWriterSettings.getRowWriterProcessor().
      Type Parameters:
      K - the key type
      I - the iterable type
      Parameters:
      rowData - the map whose values will be used to generate a number of output records
    • getContent

      private Object[] getContent(Object[] tmp)
    • getContent

      private String getContent(CharSequence tmp)
    • allowTrim

      protected final boolean allowTrim(int fieldIndex)
      Checks whether the writer can remove trailing/leading whitespaces from a value being written. Applies to headers where names can be conflicting if trimmed for example ' a ' and 'a' will become the same value if the spaces are removed)
      Parameters:
      fieldIndex - index of the field to be written.
      Returns:
      true if the value being written is not a header name, or it is a header name that won't conflict with another header if its surrounding whitespaces are trimmed.