public class FixedWidthWriter extends AbstractWriter<FixedWidthWriterSettings>
Modifier and Type | Field and Description |
---|---|
private FieldAlignment |
alignment |
private FieldAlignment |
defaultHeaderAlignment |
private boolean |
defaultHeaderPadding |
private char |
defaultPadding |
private FieldAlignment[] |
fieldAlignments |
private int[] |
fieldLengths |
private char[] |
fieldPaddings |
private boolean[] |
ignore |
private int |
ignoreCount |
private int |
length |
private Lookup[] |
lookaheadFormats |
private Lookup |
lookbehindFormat |
private Lookup[] |
lookbehindFormats |
private char[] |
lookupChars |
private char |
padding |
private FieldAlignment[] |
rootAlignments |
private boolean[] |
rootIgnore |
private int[] |
rootLengths |
private char[] |
rootPaddings |
appender, emptyValue, expandRows, headers, headerTrimFlags, ignoreLeading, ignoreTrailing, nullValue, recordCount, usingNullOrEmptyValue, whitespaceRangeStart, writingHeaders
Constructor and Description |
---|
FixedWidthWriter(java.io.File file,
java.nio.charset.Charset encoding,
FixedWidthWriterSettings settings)
The FixedWidthWriter supports all settings provided by
FixedWidthWriterSettings , and requires this configuration to be properly initialized. |
FixedWidthWriter(java.io.File file,
FixedWidthWriterSettings settings)
The FixedWidthWriter supports all settings provided by
FixedWidthWriterSettings , and requires this configuration to be properly initialized. |
FixedWidthWriter(java.io.File file,
java.lang.String encoding,
FixedWidthWriterSettings settings)
The FixedWidthWriter supports all settings provided by
FixedWidthWriterSettings , and requires this configuration to be properly initialized. |
FixedWidthWriter(FixedWidthWriterSettings settings)
The FixedWidthWriter supports all settings provided by
FixedWidthWriterSettings , and requires this configuration to be properly initialized. |
FixedWidthWriter(java.io.OutputStream output,
java.nio.charset.Charset encoding,
FixedWidthWriterSettings settings)
The FixedWidthWriter supports all settings provided by
FixedWidthWriterSettings , and requires this configuration to be properly initialized. |
FixedWidthWriter(java.io.OutputStream output,
FixedWidthWriterSettings settings)
The FixedWidthWriter supports all settings provided by
FixedWidthWriterSettings , and requires this configuration to be properly initialized. |
FixedWidthWriter(java.io.OutputStream output,
java.lang.String encoding,
FixedWidthWriterSettings settings)
The FixedWidthWriter supports all settings provided by
FixedWidthWriterSettings , and requires this configuration to be properly initialized. |
FixedWidthWriter(java.io.Writer writer,
FixedWidthWriterSettings settings)
The FixedWidthWriter supports all settings provided by
FixedWidthWriterSettings , and requires this configuration to be properly initialized. |
Modifier and Type | Method and Description |
---|---|
private void |
append(java.lang.String element,
boolean allowTrim) |
protected void |
initialize(FixedWidthWriterSettings settings)
Initializes the Fixed-Width writer with CSV-specific configuration
|
private void |
processElement(java.lang.String element,
boolean allowTrim) |
protected void |
processRow(java.lang.Object[] row)
Format-specific implementation for writing a single record into the output.
|
addStringValues, addValue, addValue, addValue, addValues, addValues, allowTrim, appendToRow, appendToRow, appendValueToRow, close, commentRow, commentRowToString, discardValues, enableNewlineAfterRecord, expand, flush, getRecordCount, getStringValue, processObjectRecords, processObjectRecordsAndClose, processObjectRecordsAndClose, processObjectRecordsToString, processObjectRecordsToString, processRecord, processRecord, processRecord, processRecord, processRecord, processRecords, processRecords, processRecords, processRecords, processRecords, processRecordsAndClose, processRecordsAndClose, processRecordsAndClose, processRecordsAndClose, processRecordsToString, processRecordsToString, processRecordsToString, processRecordsToString, processRecordToString, processRecordToString, processRecordToString, processRecordToString, processRecordToString, processValuesToRow, processValuesToString, skipLeadingWhitespace, updateFieldExclusion, updateFieldExclusion, updateFieldSelection, updateFieldSelection, writeEmptyRow, writeHeaders, writeHeaders, writeHeaders, writeHeadersToString, writeHeadersToString, writeHeadersToString, writeObjectRows, writeObjectRowsAndClose, writeObjectRowsAndClose, writeObjectRowsToString, writeRecord, writeRecords, writeRecords, writeRecordsAndClose, writeRecordsAndClose, writeRecordsAndClose, writeRecordsToString, writeRecordsToString, writeRecordToString, writeRow, writeRow, writeRow, writeRow, writeRow, writeRow, writeRows, writeRows, writeRows, writeRows, writeRows, writeRowsAndClose, writeRowsAndClose, writeRowsAndClose, writeRowsAndClose, writeRowsAndClose, writeRowsToString, writeRowsToString, writeRowsToString, writeRowsToString, writeRowsToString, writeRowToString, writeRowToString, writeRowToString, writeRowToString, writeRowToString, writeStringRows, writeStringRows, writeStringRows, writeStringRowsAndClose, writeStringRowsAndClose, writeStringRowsAndClose, writeStringRowsToString, writeStringRowsToString, writeStringRowsToString, writeValuesToRow, writeValuesToString
private int[] fieldLengths
private FieldAlignment[] fieldAlignments
private char[] fieldPaddings
private char padding
private char defaultPadding
private int length
private FieldAlignment alignment
private Lookup[] lookaheadFormats
private Lookup[] lookbehindFormats
private char[] lookupChars
private Lookup lookbehindFormat
private int[] rootLengths
private FieldAlignment[] rootAlignments
private boolean[] ignore
private boolean[] rootIgnore
private int ignoreCount
private char[] rootPaddings
private boolean defaultHeaderPadding
private FieldAlignment defaultHeaderAlignment
public FixedWidthWriter(FixedWidthWriterSettings settings)
FixedWidthWriterSettings
, and requires this 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.
settings
- the fixed-width writer configurationpublic FixedWidthWriter(java.io.Writer writer, FixedWidthWriterSettings settings)
FixedWidthWriterSettings
, and requires this configuration to be properly initialized.writer
- the output resource that will receive fixed-width records produced by this class.settings
- the fixed-width writer configurationpublic FixedWidthWriter(java.io.File file, FixedWidthWriterSettings settings)
FixedWidthWriterSettings
, and requires this configuration to be properly initialized.file
- the output file that will receive fixed-width records produced by this class.settings
- the fixed-width writer configurationpublic FixedWidthWriter(java.io.File file, java.lang.String encoding, FixedWidthWriterSettings settings)
FixedWidthWriterSettings
, and requires this configuration to be properly initialized.file
- the output file that will receive fixed-width records produced by this class.encoding
- the encoding of the filesettings
- the fixed-width writer configurationpublic FixedWidthWriter(java.io.File file, java.nio.charset.Charset encoding, FixedWidthWriterSettings settings)
FixedWidthWriterSettings
, and requires this configuration to be properly initialized.file
- the output file that will receive fixed-width records produced by this class.encoding
- the encoding of the filesettings
- the fixed-width writer configurationpublic FixedWidthWriter(java.io.OutputStream output, FixedWidthWriterSettings settings)
FixedWidthWriterSettings
, and requires this configuration to be properly initialized.output
- the output stream that will be written with the fixed-width records produced by this class.settings
- the fixed-width writer configurationpublic FixedWidthWriter(java.io.OutputStream output, java.lang.String encoding, FixedWidthWriterSettings settings)
FixedWidthWriterSettings
, and requires this configuration to be properly initialized.output
- the output stream that will be written with the fixed-width records produced by this class.encoding
- the encoding of the streamsettings
- the fixed-width writer configurationpublic FixedWidthWriter(java.io.OutputStream output, java.nio.charset.Charset encoding, FixedWidthWriterSettings settings)
FixedWidthWriterSettings
, and requires this configuration to be properly initialized.output
- the output stream that will be written with the fixed-width records produced by this class.encoding
- the encoding of the streamsettings
- the fixed-width writer configurationprotected final void initialize(FixedWidthWriterSettings settings)
initialize
in class AbstractWriter<FixedWidthWriterSettings>
settings
- the Fixed-Width writer configurationprotected void processRow(java.lang.Object[] row)
AbstractWriter
RowWriterProcessor
).
It then delegates the record to the writer-specific implementation defined by AbstractWriter.processRow(Object[])
. In general, an implementation of AbstractWriter.processRow(Object[])
will perform the following steps:
AbstractWriter.appender
object. The an individual value is processed, the AbstractWriter.appendValueToRow()
method must be called.
This will clear the accumulated value in AbstractWriter.appender
and add it to the output row.AbstractWriter.appendToRow(char)
AbstractWriter.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.processRow
in class AbstractWriter<FixedWidthWriterSettings>
row
- the data to be written to the output in the expected format.CharAppender
,
CommonWriterSettings
private void append(java.lang.String element, boolean allowTrim)
private void processElement(java.lang.String element, boolean allowTrim)