Top Description Fields Constructors Methods
com.univocity.parsers.common

public abstract Class CommonWriterSettings<F extends Format>

extends CommonSettings<F extends Format>
Class Inheritance
Known Direct Subclasses
com.univocity.parsers.csv.CsvWriterSettings, com.univocity.parsers.fixed.FixedWidthWriterSettings, com.univocity.parsers.tsv.TsvWriterSettings
Type Parameters
<F>
the format supported by this writer.
Imports
com.univocity.parsers.annotations.*, com.univocity.parsers.annotations.helpers.*, com.univocity.parsers.common.processor.*, java.util.*

This is the parent class for all configuration classes used by writers (AbstractWriter)

By default, all writers work with, at least, the following configuration options in addition to the ones provided by CommonSettings:

Author
Univocity Software Pty Ltd - [email protected]
See Also
com.univocity.parsers.common.processor.RowWriterProcessor, com.univocity.parsers.csv.CsvWriterSettings, com.univocity.parsers.fixed.FixedWidthWriterSettings

Field Summary

Modifier and TypeField and Description
private boolean
private String
private boolean
private Boolean
private RowWriterProcessor<?>
Inherited from com.univocity.parsers.common.CommonSettings:
headerSourceClass

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
clearInputSpecificSettings()

Overrides com.univocity.parsers.common.CommonSettings.clearInputSpecificSettings.

Clears settings that are likely to be specific to a given input.
protected CommonWriterSettings<F extends Format>
clone(boolean
flag indicating whether to clear settings that are likely to be associated with a given input.
clearInputSpecificSettings
)

Overrides com.univocity.parsers.common.CommonSettings.clone.

Clones this configuration object to reuse user-provided settings.
protected CommonWriterSettings<F extends Format>
clone()

Overrides com.univocity.parsers.common.CommonSettings.clone.

Clones this configuration object.
protected void
configureFromAnnotations(Class<?>
the classes whose annotations will be processed to derive configurations for writing.
beanClass
)

Configures the writer based on the annotations provided in a given class

public String

Returns:

the String representation of an empty value
getEmptyValue
()

Returns the String representation of an empty value (defaults to null)

When writing, if the writer has an empty String to write to the output, the emptyValue is used instead of an empty string

public final boolean

Returns:

a flag indicating whether records with less columns than the number of headers are to be expanded with nulls.
getExpandIncompleteRows
()

Indicates whether the writer should expand records with less columns than the number of headers.

public RowWriterProcessor<?>

Returns:

the implementation of the interface RowWriterProcessor which processes input objects into a manageable format for writing.
getRowWriterProcessor
()

Returns the implementation of the interface RowWriterProcessor which processes input objects into a manageable format for writing.

public boolean

Returns:

true if the selected fields should be reordered when writing with field selection enabled, false otherwise
isColumnReorderingEnabled
()

Indicates whether fields selected using the field selection methods (defined by the parent class CommonSettings) should be reordered (defaults to false).

public final boolean

Returns:

returns true if automatic header writing is enabled, otherwise false.
isHeaderWritingEnabled
()

Returns a flag indicating whether automatic writing of headers is enabled.

pack-priv final void
public void
setColumnReorderingEnabled(boolean
the flag indicating whether or not selected fields should be reordered and written by the writer
columnReorderingEnabled
)

Defines whether fields selected using the field selection methods (defined by the parent class CommonSettings) should be reordered (defaults to false).

public void
setEmptyValue(String
the String representation of an empty value
emptyValue
)

Sets the String representation of an empty value (defaults to null)

If the writer has an empty String to write to the output, the emptyValue is used instead of an empty string

public final void
setExpandIncompleteRows(boolean
a flag indicating whether records with less columns than the number of headers are to be expanded with nulls.
expandIncompleteRows
)

Defines whether the writer should expand records with less columns than the number of headers.

public final void
setHeaderWritingEnabled(boolean
a flag to enable or disable automatic header writing.
headerWritingEnabled
)

Enables automatic writing of headers when they are available.

public void
setRowWriterProcessor(RowWriterProcessor<?>
the implementation of the interface RowWriterProcessor which processes input objects into a manageable format for writing.
rowWriterProcessor
)

Defines a processor for input objects that converts them into a manageable format for writing.

Inherited from com.univocity.parsers.common.CommonSettings:
autoConfigurecreateDefaultFormatderiveHeadersFromexcludeFieldsexcludeFieldsexcludeIndexesgetErrorContentLengthgetFieldSelectorgetFieldSetgetFormatgetHeadersgetIgnoreLeadingWhitespacesgetIgnoreTrailingWhitespacesgetMaxCharsPerColumngetMaxColumnsgetNullValuegetProcessorErrorHandlergetRowProcessorErrorHandlergetSkipBitsAsWhitespacegetSkipEmptyLinesgetWhitespaceRangeStartisAutoConfigurationEnabledisProcessorErrorHandlerDefinedselectFieldsselectFieldsselectIndexessetAutoConfigurationEnabledsetErrorContentLengthsetFormatsetHeaderssetHeadersDerivedFromClasssetIgnoreLeadingWhitespacessetIgnoreTrailingWhitespacessetMaxCharsPerColumnsetMaxColumnssetNullValuesetProcessorErrorHandlersetRowProcessorErrorHandlersetSkipBitsAsWhitespacesetSkipEmptyLinestoStringtrimValues

Field Detail

columnReorderingEnabledback to summary
private boolean columnReorderingEnabled
emptyValueback to summary
private String emptyValue
expandIncompleteRowsback to summary
private boolean expandIncompleteRows
headerWritingEnabledback to summary
private Boolean headerWritingEnabled
rowWriterProcessorback to summary
private RowWriterProcessor<?> rowWriterProcessor

Constructor Detail

CommonWriterSettingsback to summary
public CommonWriterSettings()

Method Detail

addConfigurationback to summary
protected void addConfiguration(Map<String, Object> out)

Overrides com.univocity.parsers.common.CommonSettings.addConfiguration.

Annotations
@Override
clearInputSpecificSettingsback to summary
protected void clearInputSpecificSettings()

Overrides com.univocity.parsers.common.CommonSettings.clearInputSpecificSettings.

Doc from com.univocity.parsers.common.CommonSettings.clearInputSpecificSettings.

Clears settings that are likely to be specific to a given input.

Annotations
@Override
cloneback to summary
protected CommonWriterSettings<F extends Format> clone(boolean clearInputSpecificSettings)

Overrides com.univocity.parsers.common.CommonSettings.clone.

Doc from com.univocity.parsers.common.CommonSettings.clone.

Clones this configuration object to reuse user-provided settings. Properties that are specific to a given input (such as header names and selection of fields) can be reset to their defaults if the clearInputSpecificSettings flag is set to true

Parameters
clearInputSpecificSettings:boolean

flag indicating whether to clear settings that are likely to be associated with a given input.

Returns:CommonWriterSettings<F extends Format>

a copy of the configurations applied to the current instance.

Annotations
@Override
cloneback to summary
protected CommonWriterSettings<F extends Format> clone()

Overrides com.univocity.parsers.common.CommonSettings.clone.

Doc from com.univocity.parsers.common.CommonSettings.clone.

Clones this configuration object. Use alternative clone(boolean) method to reset properties that are specific to a given input, such as header names and selection of fields.

Returns:CommonWriterSettings<F extends Format>

a copy of all configurations applied to the current instance.

Annotations
@Override
configureFromAnnotationsback to summary
protected void configureFromAnnotations(Class<?> beanClass)

Configures the writer based on the annotations provided in a given class

Parameters
beanClass:Class<?>

the classes whose annotations will be processed to derive configurations for writing.

getEmptyValueback to summary
public String getEmptyValue()

Returns the String representation of an empty value (defaults to null)

When writing, if the writer has an empty String to write to the output, the emptyValue is used instead of an empty string

Returns:String

the String representation of an empty value

getExpandIncompleteRowsback to summary
public final boolean getExpandIncompleteRows()

Indicates whether the writer should expand records with less columns than the number of headers. For example, if the writer is using "A,B,C" as the headers, and the user provides a row with "V1,V2", then null will be introduced in column C, generating the output "V1,V2,null".

Defaults to false

Returns:boolean

a flag indicating whether records with less columns than the number of headers are to be expanded with nulls.

getRowWriterProcessorback to summary
public RowWriterProcessor<?> getRowWriterProcessor()

Returns the implementation of the interface RowWriterProcessor which processes input objects into a manageable format for writing.

Returns:RowWriterProcessor<?>

the implementation of the interface RowWriterProcessor which processes input objects into a manageable format for writing.

See Also
com.univocity.parsers.common.processor.ObjectRowWriterProcessor, com.univocity.parsers.common.processor.BeanWriterProcessor
isColumnReorderingEnabledback to summary
public boolean isColumnReorderingEnabled()

Indicates whether fields selected using the field selection methods (defined by the parent class CommonSettings) should be reordered (defaults to false).

When disabled, each written record will contain values for all columns, in the order they are sent to the writer. Fields which were not selected will not be written but and the record will contain empty values.

When enabled, each written record will contain values only for the selected columns. The values will be ordered according to the selection.

Returns:boolean

true if the selected fields should be reordered when writing with field selection enabled, false otherwise

isHeaderWritingEnabledback to summary
public final boolean isHeaderWritingEnabled()

Returns a flag indicating whether automatic writing of headers is enabled. If enabled, and headers are defined (or derived automatically if isAutoConfigurationEnabled evaluates to true), the writer will invoke the AbstractWriter#writeHeaders() method automatically. In this case, attempting to explicitly write the headers will result in a TextWritingException.

Defaults to false

Returns:boolean

returns true if automatic header writing is enabled, otherwise false.

runAutomaticConfigurationback to summary
pack-priv final void runAutomaticConfiguration()

Overrides com.univocity.parsers.common.CommonSettings.runAutomaticConfiguration.

Annotations
@Override
setColumnReorderingEnabledback to summary
public void setColumnReorderingEnabled(boolean columnReorderingEnabled)

Defines whether fields selected using the field selection methods (defined by the parent class CommonSettings) should be reordered (defaults to false).

When disabled, each written record will contain values for all columns, in the order they are sent to the writer. Fields which were not selected will not be written but and the record will contain empty values.

When enabled, each written record will contain values only for the selected columns. The values will be ordered according to the selection.

Parameters
columnReorderingEnabled:boolean

the flag indicating whether or not selected fields should be reordered and written by the writer

setEmptyValueback to summary
public void setEmptyValue(String emptyValue)

Sets the String representation of an empty value (defaults to null)

If the writer has an empty String to write to the output, the emptyValue is used instead of an empty string

Parameters
emptyValue:String

the String representation of an empty value

setExpandIncompleteRowsback to summary
public final void setExpandIncompleteRows(boolean expandIncompleteRows)

Defines whether the writer should expand records with less columns than the number of headers. For example, if the writer is using "A,B,C" as the headers, and the user provides a row with "V1,V2", then null will be introduced in column C, generating the output "V1,V2,null".

Defaults to false

Parameters
expandIncompleteRows:boolean

a flag indicating whether records with less columns than the number of headers are to be expanded with nulls.

setHeaderWritingEnabledback to summary
public final void setHeaderWritingEnabled(boolean headerWritingEnabled)

Enables automatic writing of headers when they are available. If enabled, and headers are defined (or derived automatically if isAutoConfigurationEnabled evaluates to true), the writer will invoke the AbstractWriter#writeHeaders() method automatically. In this case, attempting to explicitly write the headers will result in a TextWritingException.

Defaults to false

Parameters
headerWritingEnabled:boolean

a flag to enable or disable automatic header writing.

setRowWriterProcessorback to summary
public void setRowWriterProcessor(RowWriterProcessor<?> rowWriterProcessor)

Defines a processor for input objects that converts them into a manageable format for writing.

Parameters
rowWriterProcessor:RowWriterProcessor<?>

the implementation of the interface RowWriterProcessor which processes input objects into a manageable format for writing.

See Also
com.univocity.parsers.common.processor.ObjectRowWriterProcessor, com.univocity.parsers.common.processor.BeanWriterProcessor