public class FixedWidthWriterSettings extends CommonWriterSettings<FixedWidthFormat>
FixedWidthWriter
)
The FixedWidthWriterSettings provides all configuration options in CommonWriterSettings
and currently does not require any additional setting.
The FixedWidthParserSettings requires a definition of the field lengths of each record in the input. This must provided using an instance of FixedWidthFields
.
FixedWidthWriter
,
FixedWidthFormat
,
FixedWidthFields
,
CommonWriterSettings
Constructor and Description |
---|
FixedWidthWriterSettings()
Creates a basic configuration object for the Fixed-Width writer with no field length configuration.
|
FixedWidthWriterSettings(FixedWidthFields fieldLengths)
You can only create an instance of this class by providing a definition of the field lengths of each record in the input.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addConfiguration(Map<String,Object> out) |
void |
addFormatForLookahead(String lookahead,
FixedWidthFields lengths)
Defines the format of records identified by a lookahead symbol.
|
void |
addFormatForLookbehind(String lookbehind,
FixedWidthFields lengths)
Defines the format of records identified by a lookbehind symbol.
|
FixedWidthWriterSettings |
clone()
Clones this configuration object to reuse all user-provided settings, including the fixed-width field configuration.
|
protected FixedWidthWriterSettings |
clone(boolean clearInputSpecificSettings)
Deprecated.
doesn't really make sense for fixed-width. . Use alternative method
clone(FixedWidthFields) . |
FixedWidthWriterSettings |
clone(FixedWidthFields fields)
Clones this configuration object to reuse most user-provided settings.
|
protected void |
configureFromAnnotations(Class<?> beanClass)
Configures the writer based on the annotations provided in a given class
|
protected FixedWidthFormat |
createDefaultFormat()
Returns the default FixedWidthFormat configured to handle Fixed-Width outputs
|
FieldAlignment |
getDefaultAlignmentForHeaders()
Returns the default alignment to use when writing headers.
|
int |
getMaxColumns()
Returns the hard limit of how many columns a record can have (defaults to 512).
|
boolean |
getUseDefaultPaddingForHeaders()
Indicates whether headers should be written using the default padding specified in
FixedWidthFormat.getPadding()
instead of any custom padding associated with a given field (in FixedWidthFields.setPadding(char, int...) )
Defaults to true |
boolean |
getWriteLineSeparatorAfterRecord()
Returns a flag indicating whether each record, when written, should be followed by a line separator (as specified in
Format.getLineSeparator() . |
void |
setDefaultAlignmentForHeaders(FieldAlignment defaultAlignmentForHeaders)
Defines the default alignment to use when writing headers.
|
void |
setUseDefaultPaddingForHeaders(boolean useDefaultPaddingForHeaders)
Defines whether headers should be written using the default padding specified in
FixedWidthFormat.getPadding()
instead of any custom padding associated with a given field (in FixedWidthFields.setPadding(char, int...) ) |
void |
setWriteLineSeparatorAfterRecord(boolean writeLineSeparatorAfterRecord)
Defines whether each record, when written, should be followed by a line separator (as specified in
Format.getLineSeparator() . |
clearInputSpecificSettings, getEmptyValue, getExpandIncompleteRows, getRowWriterProcessor, isColumnReorderingEnabled, isHeaderWritingEnabled, setColumnReorderingEnabled, setEmptyValue, setExpandIncompleteRows, setHeaderWritingEnabled, setRowWriterProcessor
excludeFields, excludeFields, excludeIndexes, getErrorContentLength, getFormat, getHeaders, getIgnoreLeadingWhitespaces, getIgnoreTrailingWhitespaces, getMaxCharsPerColumn, getNullValue, getProcessorErrorHandler, getRowProcessorErrorHandler, getSkipBitsAsWhitespace, getSkipEmptyLines, getWhitespaceRangeStart, isAutoConfigurationEnabled, isProcessorErrorHandlerDefined, selectFields, selectFields, selectIndexes, setAutoConfigurationEnabled, setErrorContentLength, setFormat, setHeaders, setIgnoreLeadingWhitespaces, setIgnoreTrailingWhitespaces, setMaxCharsPerColumn, setMaxColumns, setNullValue, setProcessorErrorHandler, setRowProcessorErrorHandler, setSkipBitsAsWhitespace, setSkipEmptyLines, toString, trimValues
public FixedWidthWriterSettings(FixedWidthFields fieldLengths)
This must provided using an instance of FixedWidthFields
.
fieldLengths
- the instance of FixedWidthFields
which provides the lengths of each field in the fixed-width records to be parsedFixedWidthFields
public FixedWidthWriterSettings()
addFormatForLookahead(String, FixedWidthFields)
, addFormatForLookbehind(String, FixedWidthFields)
protected FixedWidthFormat createDefaultFormat()
createDefaultFormat
in class CommonSettings<FixedWidthFormat>
public int getMaxColumns()
CommonSettings
getMaxColumns
in class CommonSettings<FixedWidthFormat>
public void addFormatForLookahead(String lookahead, FixedWidthFields lengths)
lookahead
- the lookahead value that when found in the output row,
will notify the writer to switch to a new record format, with different field lengthslengths
- the field lengths of the record format identified by the given lookahead symbol.public void addFormatForLookbehind(String lookbehind, FixedWidthFields lengths)
lookbehind
- the lookbehind value that when present in the previous output row,
will notify the writer to switch to a new record format, with different field lengthslengths
- the field lengths of the record format identified by the given lookbehind symbol.public boolean getUseDefaultPaddingForHeaders()
FixedWidthFormat.getPadding()
instead of any custom padding associated with a given field (in FixedWidthFields.setPadding(char, int...)
)
Defaults to true
true
if the default padding is to be used when writing headers, otherwise false
public void setUseDefaultPaddingForHeaders(boolean useDefaultPaddingForHeaders)
FixedWidthFormat.getPadding()
instead of any custom padding associated with a given field (in FixedWidthFields.setPadding(char, int...)
)useDefaultPaddingForHeaders
- flag indicating whether the default padding is to be used when writing headerspublic FieldAlignment getDefaultAlignmentForHeaders()
null
), the headers will be aligned
according to the corresponding field alignment in FixedWidthFields.getAlignment(String)
.
Defaults to null
.null
if the headers should be aligned according to the column alignment.public void setDefaultAlignmentForHeaders(FieldAlignment defaultAlignmentForHeaders)
null
), the headers will be aligned
according to the corresponding field alignment in FixedWidthFields.getAlignment(String)
.
Defaults to null
.defaultAlignmentForHeaders
- the alignment to use when writing headers. null
indicates that headers
should be aligned according to the column alignment.public boolean getWriteLineSeparatorAfterRecord()
Format.getLineSeparator()
.
Consider the records [a,b]
and [c,d]
, with field lengths [2, 2]
, and line separator = \n
:
getWriteLineSeparatorAfterRecord()
is enabled, the output will be written as: a b \nc d \n
getWriteLineSeparatorAfterRecord()
is disabled, the output will be written as: a b c d
true
.public void setWriteLineSeparatorAfterRecord(boolean writeLineSeparatorAfterRecord)
Format.getLineSeparator()
.
Consider the records [a,b]
and [c,d]
, with field lengths [2, 2]
, and line separator = \n
:
getWriteLineSeparatorAfterRecord()
is enabled, the output will be written as: a b \nc d \n
getWriteLineSeparatorAfterRecord()
is disabled, the output will be written as: a b c d
true
.writeLineSeparatorAfterRecord
- flag indicating whether the writer should add a line separator after a record is written to the output.protected void configureFromAnnotations(Class<?> beanClass)
CommonWriterSettings
configureFromAnnotations
in class CommonWriterSettings<FixedWidthFormat>
beanClass
- the classes whose annotations will be processed to derive configurations for writing.protected void addConfiguration(Map<String,Object> out)
addConfiguration
in class CommonWriterSettings<FixedWidthFormat>
public final FixedWidthWriterSettings clone()
clone
in class CommonWriterSettings<FixedWidthFormat>
@Deprecated protected final FixedWidthWriterSettings clone(boolean clearInputSpecificSettings)
clone(FixedWidthFields)
.clone
in class CommonWriterSettings<FixedWidthFormat>
clearInputSpecificSettings
- flag indicating whether to clear settings that are likely to be associated with a given input.public final FixedWidthWriterSettings clone(FixedWidthFields fields)
clone()
.fields
- the fixed-width field configuration to be used by the cloned settings object.Copyright © 2020 uniVocity Software Pty Ltd. All rights reserved.