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

java.lang.Object
  extended by com.univocity.parsers.common.CommonSettings<F>
      extended by com.univocity.parsers.common.CommonParserSettings<F>
Type Parameters:
F - the format supported by this parser.
Direct Known Subclasses:
CsvParserSettings, FixedWidthParserSettings, TsvParserSettings

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

This is the parent class for all configuration classes used by parsers (AbstractParser)

By default, all parsers 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:
RowProcessor, CsvParserSettings, FixedWidthParserSettings

Constructor Summary
CommonParserSettings()
           
 
Method Summary
 int getInputBufferSize()
          Informs the number of characters held by the parser's buffer when processing the input (defaults to 1024*1024 characters).
 int getNumberOfRecordsToRead()
          The number of valid records to be parsed before the process is stopped.
 boolean getReadInputOnSeparateThread()
          Indicates whether or not a separate thread will be used to read characters from the input while parsing (defaults true if the number of available processors at runtime is greater than 1)
 RowProcessor getRowProcessor()
          Returns the callback implementation of the interface RowProcessor which handles the lifecyle of the parsing process and processes each record extracted from the input
 boolean isColumnReorderingEnabled()
          Indicates whether fields selected using the field selection methods (defined by the parent class CommonSettings) should be reordered (defaults to true).
 boolean isHeaderExtractionEnabled()
          Indicates whether or not the first valid record parsed from the input should be considered as the row containing the names of each column
 boolean isLineSeparatorDetectionEnabled()
          Indicates whether the parser should detect the line separator automatically.
protected  CharAppender newCharAppender()
          Returns an instance of CharAppender with the configured limit of maximum characters per column and the default value used to represent a null value (when the String parsed from the input is empty)
 void setColumnReorderingEnabled(boolean columnReorderingEnabled)
          Defines whether fields selected using the field selection methods (defined by the parent class CommonSettings) should be reordered (defaults to true).
 void setHeaderExtractionEnabled(boolean headerExtractionEnabled)
          Defines whether or not the first valid record parsed from the input should be considered as the row containing the names of each column
 void setInputBufferSize(int inputBufferSize)
          Defines the number of characters held by the parser's buffer when processing the input (defaults to 1024*1024 characters).
 void setLineSeparatorDetectionEnabled(boolean lineSeparatorDetectionEnabled)
          Defines whether the parser should detect the line separator automatically.
 void setNumberOfRecordsToRead(int numberOfRecordsToRead)
          Defines the number of valid records to be parsed before the process is stopped.
 void setReadInputOnSeparateThread(boolean readInputOnSeparateThread)
          Defines whether or not a separate thread will be used to read characters from the input while parsing (defaults true if the number of available processors at runtime is greater than 1)
 void setRowProcessor(RowProcessor processor)
          Defines the callback implementation of the interface RowProcessor which handles the lifecyle of the parsing process and processes each record extracted from the input
 
Methods inherited from class com.univocity.parsers.common.CommonSettings
createDefaultFormat, excludeFields, excludeIndexes, getFormat, getHeaders, getIgnoreLeadingWhitespaces, getIgnoreTrailingWhitespaces, getMaxCharsPerColumn, getMaxColumns, getNullValue, getSkipEmptyLines, selectFields, selectIndexes, setFormat, setHeaders, setIgnoreLeadingWhitespaces, setIgnoreTrailingWhitespaces, setMaxCharsPerColumn, setMaxColumns, setNullValue, setSkipEmptyLines
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonParserSettings

public CommonParserSettings()
Method Detail

getReadInputOnSeparateThread

public boolean getReadInputOnSeparateThread()
Indicates whether or not a separate thread will be used to read characters from the input while parsing (defaults true if the number of available processors at runtime is greater than 1)

When enabled, a reading thread (in com.univocity.parsers.common.input.concurrent.ConcurrentCharInputReader) will be started and load characters from the input, while the parser is processing its input buffer. This yields better performance, especially when reading from big input (greater than 100 mb)

When disabled, the parsing process will briefly pause so the buffer can be replenished every time it is exhausted (in DefaultCharInputReader it is not as bad or slow as it sounds, and can even be (slightly) more efficient if your input is small)

Returns:
true if the input should be read on a separate thread, false otherwise

setReadInputOnSeparateThread

public void setReadInputOnSeparateThread(boolean readInputOnSeparateThread)
Defines whether or not a separate thread will be used to read characters from the input while parsing (defaults true if the number of available processors at runtime is greater than 1)

When enabled, a reading thread (in com.univocity.parsers.common.input.concurrent.ConcurrentCharInputReader) will be started and load characters from the input, while the parser is processing its input buffer. This yields better performance, especially when reading from big input (greater than 100 mb)

When disabled, the parsing process will briefly pause so the buffer can be replenished every time it is exhausted (in DefaultCharInputReader it is not as bad or slow as it sounds, and can even be (slightly) more efficient if your input is small)

Parameters:
readInputOnSeparateThread - the flag indicating whether or not the input should be read on a separate thread

isHeaderExtractionEnabled

public boolean isHeaderExtractionEnabled()
Indicates whether or not the first valid record parsed from the input should be considered as the row containing the names of each column

Returns:
true if the first valid record parsed from the input should be considered as the row containing the names of each column, false otherwise

setHeaderExtractionEnabled

public void setHeaderExtractionEnabled(boolean headerExtractionEnabled)
Defines whether or not the first valid record parsed from the input should be considered as the row containing the names of each column

Parameters:
headerExtractionEnabled - a flag indicating whether the first valid record parsed from the input should be considered as the row containing the names of each column

getRowProcessor

public RowProcessor getRowProcessor()
Returns the callback implementation of the interface RowProcessor which handles the lifecyle of the parsing process and processes each record extracted from the input

Returns:
Returns the RowProcessor used by the parser to handle each record
See Also:
ObjectRowProcessor, ObjectRowListProcessor, MasterDetailProcessor, MasterDetailListProcessor, BeanProcessor, BeanListProcessor

setRowProcessor

public void setRowProcessor(RowProcessor processor)
Defines the callback implementation of the interface RowProcessor which handles the lifecyle of the parsing process and processes each record extracted from the input

Parameters:
processor - the RowProcessor instance which should used by the parser to handle each record
See Also:
ObjectRowProcessor, ObjectRowListProcessor, MasterDetailProcessor, MasterDetailListProcessor, BeanProcessor, BeanListProcessor

getNumberOfRecordsToRead

public int getNumberOfRecordsToRead()
The number of valid records to be parsed before the process is stopped. A negative value indicates there's no limit (defaults to -1).

Returns:
the number of records to read before stopping the parsing process.

setNumberOfRecordsToRead

public void setNumberOfRecordsToRead(int numberOfRecordsToRead)
Defines the number of valid records to be parsed before the process is stopped. A negative value indicates there's no limit (defaults to -1).

Parameters:
numberOfRecordsToRead - the number of records to read before stopping the parsing process.

isColumnReorderingEnabled

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

When disabled, each parsed record will contain values for all columns, in the order they occur in the input. Fields which were not selected will not be parsed but and the record will contain empty values.

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

Returns:
true if the selected fields should be reordered and returned by the parser, false otherwise

setColumnReorderingEnabled

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 true).

When disabled, each parsed record will contain values for all columns, in the order they occur in the input. Fields which were not selected will not be parsed but and the record will contain empty values.

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

Parameters:
columnReorderingEnabled - the flag indicating whether or not selected fields should be reordered and returned by the parser

getInputBufferSize

public int getInputBufferSize()
Informs the number of characters held by the parser's buffer when processing the input (defaults to 1024*1024 characters).

Returns:
the number of characters held by the parser's buffer when processing the input

setInputBufferSize

public void setInputBufferSize(int inputBufferSize)
Defines the number of characters held by the parser's buffer when processing the input (defaults to 1024*1024 characters).

Parameters:
inputBufferSize - the new input buffer size (in number of characters)

newCharAppender

protected CharAppender newCharAppender()
Returns an instance of CharAppender with the configured limit of maximum characters per column and the default value used to represent a null value (when the String parsed from the input is empty)

Returns:
an instance of CharAppender with the configured limit of maximum characters per column and the default value used to represent a null value (when the String parsed from the input is empty)

isLineSeparatorDetectionEnabled

public final boolean isLineSeparatorDetectionEnabled()
Indicates whether the parser should detect the line separator automatically.

Returns:
true if the first line of the input should be used to search for common line separator sequences (the matching sequence will be used as the line separator for parsing). Otherwise false.

setLineSeparatorDetectionEnabled

public final void setLineSeparatorDetectionEnabled(boolean lineSeparatorDetectionEnabled)
Defines whether the parser should detect the line separator automatically.

Parameters:
lineSeparatorDetectionEnabled - a flag indicating whether the first line of the input should be used to search for common line separator sequences (the matching sequence will be used as the line separator for parsing).


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