CommonWriterSettings, and delegates the writing algorithm implementation to its subclasses through the abstract
method AbstractWriter#processRow(Object[])
The following (absolutely required) attributes are exposed to subclasses:
WriterCharAppender): the character writer that appends characters from a given input into an internal buffercom.univocity.parsers.csv.CsvWriter , com.univocity.parsers.csv.CsvWriterSettings , com.univocity.parsers.fixed.FixedWidthWriter , com.univocity.parsers.fixed.FixedWidthWriterSettings , com.univocity.parsers.tsv.TsvWriter , com.univocity.parsers.tsv.TsvWriterSettings , com.univocity.parsers.common.input.WriterCharAppender , com.univocity.parsers.common.processor.RowWriterProcessor
| Modifier and Type | Field and Description |
|---|---|
| protected final WriterCharAppender | |
| private final boolean | |
| protected final char | |
| private NormalizedString[] | |
| protected final String | |
| private boolean | |
| private final int | |
| protected boolean | |
| private Map | |
| protected NormalizedString[] | |
| protected boolean[] | |
| protected boolean | |
| protected boolean | |
| private int[] | |
| private final CommonSettings | |
| private final boolean | |
| private int | |
| private final char[] | |
| protected final String | |
| private Object[] | |
| private final Object[] | |
| private int | |
| protected long | |
| private final WriterCharAppender | |
| private final boolean | |
| protected boolean | |
| private boolean | |
| protected final int | |
| private Writer | |
| private final RowWriterProcessor | |
| protected boolean |
| Access | Constructor and Description |
|---|---|
| public | AbstractWriter(S
the writer configuration settings)All writers must support, at the very least, the settings provided by |
| public | AbstractWriter(File
the output file that will be written with the format-specific records as defined by subclasses of file, S AbstractWriter.the writer configuration settings)All writers must support, at the very least, the settings provided by |
| public | AbstractWriter(File
the output file that will be written with the format-specific records as defined by subclasses of file, String AbstractWriter.the encoding of the file encoding, S the writer configuration settings)All writers must support, at the very least, the settings provided by |
| public | AbstractWriter(File
the output file that will be written with the format-specific records as defined by subclasses of file, Charset AbstractWriter.the encoding of the file encoding, S the writer configuration settings)All writers must support, at the very least, the settings provided by |
| public | AbstractWriter(OutputStream
the output stream that will be written with the format-specific records as defined by subclasses of output, S AbstractWriter.the writer configuration settings)All writers must support, at the very least, the settings provided by |
| public | AbstractWriter(OutputStream
the output stream that will be written with the format-specific records as defined by subclasses of output, String AbstractWriter.the encoding of the stream encoding, S the writer configuration settings)All writers must support, at the very least, the settings provided by |
| public | AbstractWriter(OutputStream
the output stream that will be written with the format-specific records as defined by subclasses of output, Charset AbstractWriter.the encoding of the stream encoding, S the writer configuration settings)All writers must support, at the very least, the settings provided by |
| public | AbstractWriter(Writer
the output resource that will receive the format-specific records as defined by subclasses of writer, S AbstractWriter.the writer configuration settings)All writers must support, at the very least, the settings provided by |
| Modifier and Type | Method and Description |
|---|---|
| public final void | addStringValues(Collection<String>
the values to be written values)Writes a sequence of Strings to a row in memory. |
| public final void | |
| public final void | |
| public final void | |
| private final void | addValue(NormalizedString[] headersInContext, NormalizedString headerName, boolean ignoreOnMismatch, Object value)
|
| public final void | |
| public final void | addValues(Collection<?>
the values to be written values)Writes a sequence of values to a row in memory. |
| private Object[] | |
| protected final boolean | 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.index of the field to be written. fieldIndex)Checks whether the writer can remove trailing/leading whitespaces from a value being written. |
| protected final void | appendToRow(char
the character to append to the output row ch)Appends the given character to the output row. |
| protected final void | appendToRow(char[]
the sequence of characters to append to the output row chars)Appends the given character sequence to the output row |
| protected final void | appendValueToRow()
Appends the processed sequence of characters in |
| public final void | |
| public final void | commentRow(String
the contents to be written as a comment to the output comment)Writes a comment row to the output. |
| public final String | Returns: a formattedString containing the comment.the contents to be written as a comment to a comment)String.Writes a comment row to a |
| public final void | |
| protected void | |
| protected Object[] | |
| private <T> void | fillOutputRow(T[]
user-provided data which has to be rearranged to the expected record sequence before writing to the output. row)Used when fields were selected and the input rows have a different order than the output. |
| private void | |
| public final void | |
| private Object[] | |
| private String | |
| private int | Returns: the position of the given header, or -1 if it's not found when ignoreOnMismatch is set totrueheaders currently in use (they might change). headersInContext, NormalizedString the name of the header whose position will be identified headerName, boolean flag indicating that if the header is not found, no exception is to be thrown, and -1 should be returned instead. ignoreOnMismatch)Calculates the index of a header name in relation to the original |
| public final long | Returns: the number of records written to the output so farReturns the number of records written to the output so far |
| private NormalizedString[] | |
| protected String | Returns: the String representation of the given objectthe object to be converted into a String. element)Converts a given object to its String representation for writing to a
|
| protected abstract void | initialize(S
the settings object specific to the format being written. settings)Initializes the concrete implementation of this class with format-specific settings. |
| private void | internalWriteRow()
Writes the accumulated value of a record to the output, followed by a newline, and increases the record count. |
| private String | Returns: a formattedString containing the comment.Writes the accumulated value of a record to the output, followed by a newline, and increases the record count. |
| public final < the key type K> void | processObjectRecords(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, Object[]> the map whose values will be used to generate a number of output records rowData)Processes the data in all values of a map using the |
| public final < the key type K> void | processObjectRecordsAndClose(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, Object[]> the map whose values will be used to generate a number of output records rowData)Processes the data in all values of a map using the |
| public final < the key type K> void | processObjectRecordsAndClose(Map<K, Object[]>
the map whose values will be used to generate a number of output records rowData)Processes the data in all values of a map using the |
| public final < the key type K> List | Returns: aList of formatted String, each String representing one successful iteration over at least one
element of the iterators in the map.the map whose values will be used to generate a rowData)List of String.Processes the data in all values of a map using the |
| public final < the key type K> List | Returns: aList of formatted String, each String representing one successful iteration over at least one
element of the iterators in the map.a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, Object[]> the map whose values will be used to generate a rowData)List of String.Processes the data in all values of a map using the |
| public final void | processRecord(Object...
the information of a single record to be transformed by a record)RowWriterProcessor and then written to the outputProcesses the data given for an individual record with the |
| public final <T extends Record> void | |
| public final void | processRecord(Object
the information of a single record to be transformed by a record)RowWriterProcessor and then written to the outputProcesses the data given for an individual record with the |
| public final void | processRecord(Map<?, ?>
the map whose values will be used to generate a rowData)List of String.Processes the values of a map using the |
| public final < the key type K> void | processRecord(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, ?> the map whose values will be used to generate a rowData)List of String.Processes the values of a map using the |
| public final void | processRecords(Iterable<?>
the records to be transformed by a records)RowWriterProcessor and then written to the outputIterates over all records, processes each one with the |
| public final void | processRecords(Object[]
the records to transformed by a records)RowWriterProcessor and then written to the outputIterates over all records, processes each one with the |
| public final < the concrete Record type T extends Record> void | processRecords(T[]
the records to transformed by a records)RowWriterProcessor and then written to the outputIterates over all records, processes each one with the |
| public final < the key type K, the iterable type I extends Iterable | processRecords(Map<K, I>
the map whose values will be used to generate a number of output records rowData)Processes the data in all values of a map using the |
| public final < the key type K, the iterable type I extends Iterable | processRecords(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, I> the map whose values will be used to generate a number of output records rowData)Processes the data in all values of a map using the |
| public final void | processRecordsAndClose(Iterable<?>
the records to be transformed by a allRecords)RowWriterProcessor and then written to the outputIterates over all records, processes each one with the |
| public final void | processRecordsAndClose(Object[]
the records to be transformed by a allRecords)RowWriterProcessor and then written to the outputIterates over all records, processes each one with the |
| public final < the key type K, the iterable type I extends Iterable | processRecordsAndClose(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, I> the map whose values will be used to generate a number of output records rowData)Processes the data in all values of a map using the |
| public final < the key type K, the iterable type I extends Iterable | processRecordsAndClose(Map<K, I>
the map whose values will be used to generate a number of output records rowData)Processes the data in all values of a map using the |
| public final List | Returns: aList containing the information transformed from the given records as formatted StringsIterates over all records, processes each one with the |
| public final List | Returns: aList containing the information transformed from the given records as formatted Stringsthe records to transformed by a records)RowWriterProcessor and then written a String.Iterates over all records, processes each one with the |
| public final < the key type K, the iterable type I extends Iterable | Returns: aList of formatted String, each String representing one successful iteration over at least one
element of the iterators in the map.the map whose values will be used to generate a rowData)List of String.Processes the data in all values of a map using the |
| public final < the key type K, the iterable type I extends Iterable | Returns: aList of formatted String, each String representing one successful iteration over at least one
element of the iterators in the map.a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, I> the map whose values will be used to generate a rowData)List of String.Processes the data in all values of a map using the |
| public final String | Returns: a formattedString containing the information transformed from the given recordthe information of a single record to be transformed by a record)RowWriterProcessor and then written to a String.Processes the data given for an individual record with the |
| public final < the concrete Record type T extends Record> String | Returns: a formattedString containing the information transformed from the given recordthe information of a single record to be transformed by a record)RowWriterProcessor and then written to a String.Processes the data given for an individual record with the |
| public final String | Returns: a formattedString containing the information transformed from the given recordthe information of a single record to be transformed by a record)RowWriterProcessor and then written to a String.Processes the data given for an individual record with the |
| public final String | Returns: aString containing the given data as a formatted Stringthe map whose values will be used to generate a rowData)List of String.Processes the values of a map using the |
| public final < the key type K> String | Returns: aString containing the given data as a formatted Stringa mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, ?> the map whose values will be used to generate a rowData)List of String.Processes the values of a map using the |
| protected abstract void | processRow(Object[]
the data to be written to the output in the expected format. row)Format-specific implementation for writing a single record into the output. |
| public final void | processValuesToRow()
Writes the contents accumulated in an internal in-memory row (using |
| public final String | Returns: a formattedString containing the result produced by the RowWriterProcessor using the values accumulated in internal in-memory row.Writes the contents accumulated in an internal in-memory row (using |
| private void | setHeadersFromMap(Map<?, ?>
the input map whose keys will be used to generate headers for the output. map, boolean indicates whether to take the map keys or values to build the header rows. keys)Iterates over the keys of a map and builds an internal header row. |
| protected static int | Returns: the index of the first non-whitespace character in the given element.starting range after which characters will be considered whitespace whitespaceRangeStart, String the String to be scanned for leading whitespaces. 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 |
| private void | |
| private TextWritingException | throwExceptionAndClose(String
Description of the error message)In case of any exceptions, a |
| private TextWritingException | throwExceptionAndClose(String
Description of the error message, Throwable the exception to be wrapped by a cause)TextWritingExceptionIn case of any exceptions, a |
| private TextWritingException | throwExceptionAndClose(String
Description of the error message, String characters used to write to the output at the time the exception happened recordCharacters, Throwable the exception to be wrapped by a cause)TextWritingExceptionIn case of any exceptions, a |
| private TextWritingException | throwExceptionAndClose(String
Description of the error message, Object[] values used to write to the output at the time the exception happened recordValues, Throwable the exception to be wrapped by a cause)TextWritingExceptionIn case of any exceptions, a |
| public void | updateFieldExclusion(String...
the selection of fields to exclude from the output. fieldsToExclude)Updates the selection of fields to exclude when writing. |
| public void | updateFieldExclusion(Integer...
the selection of fields to exclude from the output. fieldIndexesToExclude)Updates the selection of fields to exclude when writing. |
| public void | updateFieldSelection(String...
the new selection of fields to write. newFieldSelection)Updates the selection of fields to write. |
| public void | updateFieldSelection(Integer...
the new selection of fields to write. newFieldSelectionByIndex)Updates the selection of fields to write. |
| private void | updateIndexesToWrite(CommonSettings<?> settings)
Update indexes to write based on the field selection provided by the user. |
| private <K> Map | |
| private <K> Map | |
| private <K> Map | |
| public final void | writeEmptyRow()
Writes an empty line to the output, unless this is a |
| public final void | writeHeaders()
Writes the headers defined in |
| public final void | writeHeaders(Collection<?>
the headers to write to the output. headers)Writes the given collection of headers to the output. |
| public final void | writeHeaders(String...
the headers to write to the output. headers)Writes the given collection of headers to the output. |
| public final String | |
| public final String | Returns: a formattedString containing the given headersthe headers to write to a headers)StringWrites the given collection of headers to a |
| public final String | Returns: a formattedString containing the given headersthe headers to write to a headers)StringWrites the given collection of headers to a |
| public final < the key type K> void | writeObjectRows(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, Object[]> the map whose values will be used to generate a number of output records 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. |
| public final < the key type K> void | writeObjectRowsAndClose(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, Object[]> the map whose values will be used to generate a number of output records rowData)Writes the values of a given map to multiple output records and closes the output when finished. |
| public final < the key type K> void | writeObjectRowsAndClose(Map<K, Object[]>
the map whose values will be used to generate a number of output records rowData)Writes the values of a given map to multiple output records and closes the output when finished. |
| public final < the key type K> List | Returns: aList of formatted String, each String representing one successful iteration over at least one
element of the iterators in the map.a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, Object[]> the map whose values will be used to generate a rowData)List of String.Writes the values of a given map to a |
| public final < the concrete Record type T extends Record> void | writeRecord(T
the information of a single record to be written to the output row)Writes the data given for an individual record. |
| public final void | writeRecords(Collection<? extends Record>
the rows to be written to the output rows)Iterates over all records and writes them to the output. |
| public final < the key type K> void | writeRecords(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, ? extends Record> the map whose values will be used to generate a number of output records 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. |
| public final void | writeRecordsAndClose(Collection<? extends Record>
the rows to be written to the output allRows)Iterates over all records, writes them and closes the output Note this method will not use the |
| public final < the key type K> void | writeRecordsAndClose(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, ? extends Record> the map whose values will be used to generate a number of output records rowData)Writes the values of a given map to multiple output records and closes the output when finished. |
| public final < the key type K> void | writeRecordsAndClose(Map<K, ? extends Record>
the map whose values will be used to generate a number of output records rowData)Writes the values of a given map to multiple output records and closes the output when finished. |
| public final List | Returns: aList containing the given rows as formatted Stringsthe rows to be written to a rows)List of String.Iterates over all records and writes them to a Note this method will not use the |
| public final < the key type K> List | Returns: aList of formatted String, each String representing one successful iteration over at least one
element of the iterators in the map.a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, ? extends Record> the map whose values will be used to generate a rowData)List of String.Writes the values of a given map to a |
| public final <T extends Record> String | Returns: a formattedString containing the information of the given recordthe information of a single record to be written to a row)String.Writes the data given for an individual record to a |
| public final void | writeRow(Collection<?>
the information of a single record to be written to the output row)Writes the data given for an individual record. |
| public final void | |
| public final void | |
| public final void | |
| public final void | writeRow(Map<?, ?>
the map whose values will be used to generate a new record rowData)Writes the values of a given map into new output record Note this method will not use the |
| public final < the key type K> void | writeRow(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, ?> the map whose values will be used to generate a new record rowData)Writes the values of a given map into new output record Note this method will not use the |
| public final void | |
| public final < Collection of objects containing values of a row C extends Collection | |
| public final void | writeRows(Collection<Object[]>
the rows to be written to the output rows)Iterates over all records and writes them to the output. |
| public final < the key type K, the iterable type I extends Iterable | |
| public final < the key type K, the iterable type I extends Iterable | writeRows(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, I> the map whose values will be used to generate a number of output records 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. |
| private < the key type K, the iterable type I extends Iterable | writeRows(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, I> the map whose values will be used to generate a rowData, List<String> List of String.an output outputList, boolean useRowProcessor)List to fill with formatted Strings, each String representing
one successful iteration over at least one
element of the iterators in the map.Writes the values of a given map to a |
| public final < Collection of objects containing values of a row C extends Collection | writeRowsAndClose(Iterable<C>
the rows to be written to the output allRows)Iterates over all records, writes them and closes the output Note this method will not use the |
| public final void | writeRowsAndClose(Collection<Object[]>
the rows to be written to the output allRows)Iterates over all records, writes them and closes the output Note this method will not use the |
| public final void | writeRowsAndClose(Object[][]
the rows to be written to the output allRows)Iterates over all records, writes them and closes the output Note this method will not use the |
| public final < the key type K, the iterable type I extends Iterable | writeRowsAndClose(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, I> the map whose values will be used to generate a number of output records rowData)Writes the values of a given map to multiple output records and closes the output when finished. |
| public final < the key type K, the iterable type I extends Iterable | writeRowsAndClose(Map<K, I>
the map whose values will be used to generate a number of output records rowData)Writes the values of a given map to multiple output records and closes the output when finished. |
| public final List | Returns: aList containing the given rows as formatted Stringsthe rows to be written to a rows)List of String.Iterates over all records and writes them to a Note this method will not use the |
| public final < Collection of objects containing values of a row C extends Collection | Returns: aList containing the given rows as formatted Stringsthe rows to be written to a rows)List of String.Iterates over all records and writes them to a Note this method will not use the |
| public final List | Returns: aList containing the given rows as formatted Stringsthe rows to be written to a rows)List of String.Iterates over all records and writes them to a Note this method will not use the |
| public final < the key type K, the iterable type I extends Iterable | Returns: aList of formatted String, each String representing one successful iteration over at least one
element of the iterators in the map.the map whose values will be used to generate a rowData)List of String.Writes the values of a given map to a |
| public final < the key type K, the iterable type I extends Iterable | Returns: aList of formatted String, each String representing one successful iteration over at least one
element of the iterators in the map.a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, I> the map whose values will be used to generate a rowData)List of String.Writes the values of a given map to a |
| public final String | Returns: a formattedString containing the information of the given recordthe information of a single record to be written to a row)StringWrites the data given for an individual record to a Note this method will not use the |
| public final String | Returns: a formattedString containing the information of the given recordthe information of a single record to be written to a row)String.Writes the data given for an individual record to a |
| public final String | Returns: a formattedString containing the information of the given recordthe information of a single record to be written to a row)String.Writes the data given for an individual record to a |
| public final String | Returns: aString containing the given data as a formatted Stringthe map whose values will be used to generate a rowData)String.Writes the values of a given map to a Note this method will not use the |
| public final < the key type K> String | Returns: aString containing the given data as a formatted Stringa mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, ?> the map whose values will be used to generate a rowData)String.Writes the values of a given map to a Note this method will not use the |
| public final void | writeStringRows(Collection<String[]>
the rows to be written to the output rows)Iterates over all records and writes them to the output. |
| public final < Collection of objects containing values of a row C extends Collection | writeStringRows(Iterable<C>
the rows to be written to the output rows)Iterates over all records and writes them to the output. |
| public final < the key type K> void | writeStringRows(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, String[]> the map whose values will be used to generate a number of output records 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. |
| public final void | writeStringRowsAndClose(Collection<String[]>
the rows to be written to the output allRows)Iterates over all records, writes them and closes the output Note this method will not use the |
| public final < the key type K> void | writeStringRowsAndClose(Map<K, String>
a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, String[]> the map whose values will be used to generate a number of output records rowData)Writes the values of a given map to multiple output records and closes the output when finished. |
| public final < the key type K> void | writeStringRowsAndClose(Map<K, String[]>
the map whose values will be used to generate a number of output records rowData)Writes the values of a given map to multiple output records and closes the output when finished. |
| public final < Collection of objects containing values of a row C extends Collection | Returns: aList containing the given rows as formatted Stringsthe rows to be written to a rows)List of String.Iterates over all records and writes them to a Note this method will not use the |
| public final List | Returns: aList containing the given rows as formatted Stringsthe rows to be written to a rows)List of String.Iterates over all records and writes them to a Note this method will not use the |
| public final < the key type K> List | Returns: aList of formatted String, each String representing one successful iteration over at least one
element of the iterators in the map.a mapping associating the keys of the input map to their corresponding header names. headerMapping, Map<K, String[]> the map whose values will be used to generate a rowData)List of String.Writes the values of a given map to a |
| private < type of the key in both rowData and headerMapping maps. K> void | writeValuesFromMap(Map<K, String>
an optional map associating keys of the rowData map with expected header names headerMapping, Map<K, ?> the data to be written. Its keys will be used to form a header row in case no headers are available. rowData)Writes values from an implementation of |
| public final void | writeValuesToRow()
Writes the contents accumulated in an internal in-memory row (using |
| public final String | Returns: a formattedString containing the information accumulated in the internal in-memory row.Writes the contents accumulated in an internal in-memory row (using |