com.univocity.parsers.common
Class CommonWriterSettings<F extends Format>

java.lang.Object
  extended by com.univocity.parsers.common.CommonSettings<F>
      extended by com.univocity.parsers.common.CommonWriterSettings<F>
Type Parameters:
F - the format supported by this writer.
Direct Known Subclasses:
CsvWriterSettings, FixedWidthWriterSettings, TsvWriterSettings

public abstract class CommonWriterSettings<F extends Format>
extends CommonSettings<F>

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:
RowWriterProcessor, CsvWriterSettings, FixedWidthWriterSettings

Constructor Summary
CommonWriterSettings()
           
 
Method Summary
protected  void addConfiguration(Map<String,Object> out)
           
 String getEmptyValue()
          Returns the String representation of an empty value (defaults to null)
 boolean getExpandIncompleteRows()
          Indicates whether the writer should expand records with less columns than the number of headers.
 RowWriterProcessor<?> getRowWriterProcessor()
          Returns the implementation of the interface RowWriterProcessor which processes input objects into a manageable format for writing.
 boolean isHeaderWritingEnabled()
          Returns a flag indicating whether automatic writing of headers is enabled.
 void setEmptyValue(String emptyValue)
          Sets the String representation of an empty value (defaults to null)
 void setExpandIncompleteRows(boolean expandIncompleteRows)
          Defines whether the writer should expand records with less columns than the number of headers.
 void setHeaderWritingEnabled(boolean headerWritingEnabled)
          Enables automatic writing of headers when they are available.
 void setRowWriterProcessor(RowWriterProcessor<?> rowWriterProcessor)
          Defines a processor for input objects that converts them into a manageable format for writing.
 
Methods inherited from class com.univocity.parsers.common.CommonSettings
createDefaultFormat, excludeFields, excludeFields, excludeIndexes, getFormat, getHeaders, getIgnoreLeadingWhitespaces, getIgnoreTrailingWhitespaces, getMaxCharsPerColumn, getMaxColumns, getNullValue, getRowProcessorErrorHandler, getSkipEmptyLines, isAutoConfigurationEnabled, selectFields, selectFields, selectIndexes, setAutoConfigurationEnabled, setFormat, setHeaders, setIgnoreLeadingWhitespaces, setIgnoreTrailingWhitespaces, setMaxCharsPerColumn, setMaxColumns, setNullValue, setRowProcessorErrorHandler, setSkipEmptyLines, toString, trimValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommonWriterSettings

public CommonWriterSettings()
Method Detail

getEmptyValue

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:
the String representation of an empty value

setEmptyValue

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 - the String representation of an empty value

getRowWriterProcessor

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

Returns:
the implementation of the interface RowWriterProcessor which processes input objects into a manageable format for writing.
See Also:
ObjectRowWriterProcessor, BeanWriterProcessor

setRowWriterProcessor

public void setRowWriterProcessor(RowWriterProcessor<?> rowWriterProcessor)
Defines a processor for input objects that converts them into a manageable format for writing.

Parameters:
rowWriterProcessor - the implementation of the interface RowWriterProcessor which processes input objects into a manageable format for writing.
See Also:
ObjectRowWriterProcessor, BeanWriterProcessor

isHeaderWritingEnabled

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 CommonSettings.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:
returns true if automatic header writing is enabled, otherwise false.

setHeaderWritingEnabled

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 CommonSettings.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 - a flag to enable or disable automatic header writing.

getExpandIncompleteRows

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:
a flag indicating whether records with less columns than the number of headers are to be expanded with nulls.

setExpandIncompleteRows

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 - a flag indicating whether records with less columns than the number of headers are to be expanded with nulls.

addConfiguration

protected void addConfiguration(Map<String,Object> out)
Overrides:
addConfiguration in class CommonSettings<F extends Format>


Copyright © 2016 uniVocity Software Pty Ltd. All rights reserved.