Class AbstractUniVocityDataFormat<F extends com.univocity.parsers.common.Format,CWS extends com.univocity.parsers.common.CommonWriterSettings<F>,W extends com.univocity.parsers.common.AbstractWriter<CWS>,CPS extends com.univocity.parsers.common.CommonParserSettings<F>,P extends com.univocity.parsers.common.AbstractParser<CPS>,DF extends AbstractUniVocityDataFormat<F,CWS,W,CPS,P,DF>>
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.dataformat.univocity.AbstractUniVocityDataFormat<F,CWS,W,CPS,P,DF>
-
- Type Parameters:
F
- uniVocity format classCWS
- uniVocity writer settings classW
- uniVocity writer classCPS
- uniVocity parser settings classP
- uniVocity parser classDF
- the data format class (for providing a fluent API)
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.DataFormat
,org.apache.camel.spi.DataFormatName
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
- Direct Known Subclasses:
UniVocityCsvDataFormat
,UniVocityFixedWidthDataFormat
,UniVocityTsvDataFormat
public abstract class AbstractUniVocityDataFormat<F extends com.univocity.parsers.common.Format,CWS extends com.univocity.parsers.common.CommonWriterSettings<F>,W extends com.univocity.parsers.common.AbstractWriter<CWS>,CPS extends com.univocity.parsers.common.CommonParserSettings<F>,P extends com.univocity.parsers.common.AbstractParser<CPS>,DF extends AbstractUniVocityDataFormat<F,CWS,W,CPS,P,DF>> extends org.apache.camel.support.service.ServiceSupport implements org.apache.camel.spi.DataFormat, org.apache.camel.spi.DataFormatName
This abstract class contains all the common parts for all the uniVocity parsers.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
asMap
protected Character
comment
protected String
emptyValue
protected Boolean
headerExtractionEnabled
protected String[]
headers
protected boolean
headersDisabled
protected Boolean
ignoreLeadingWhitespaces
protected Boolean
ignoreTrailingWhitespaces
protected boolean
lazyLoad
protected String
lineSeparator
protected Character
normalizedLineSeparator
protected String
nullValue
protected Integer
numberOfRecordsToRead
protected Boolean
skipEmptyLines
-
Constructor Summary
Constructors Constructor Description AbstractUniVocityDataFormat()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
configureFormat(F format)
Configures the format.protected void
configureParserSettings(CPS settings)
Configure the parser settings.protected void
configureWriterSettings(CWS settings)
Configures the writer settings.protected abstract P
createParser(CPS settings)
Creates a new instance of the uniVocity parser.protected abstract CPS
createParserSettings()
Creates a new instance of the parser settings.protected abstract W
createWriter(Writer writer, CWS settings)
Creates a new instance of the uniVocity writer.protected abstract CWS
createWriterSettings()
Creates a new instance of the writer settings.protected void
doStart()
protected void
doStop()
Character
getComment()
Gets the comment symbol.String
getEmptyValue()
Gets the String representation of an empty value.Boolean
getHeaderExtractionEnabled()
Gets whether or not the header extraction is enabled.String[]
getHeaders()
Gets the headers.Boolean
getIgnoreLeadingWhitespaces()
Gets whether or not leading whitespaces should be ignored.Boolean
getIgnoreTrailingWhitespaces()
Gets whether or not trailing whitespaces should be ignored.String
getLineSeparator()
Gets the line separator.Character
getNormalizedLineSeparator()
Gets the normalized line separator.String
getNullValue()
Gets the String representation of a null value.Integer
getNumberOfRecordsToRead()
Gets the number of records to read.Boolean
getSkipEmptyLines()
Gets whether or not empty lines should be ignored.boolean
isAsMap()
Gets whether or not the unmarshalling should produces maps instead of lists.boolean
isHeadersDisabled()
Gets whether or not headers are disabled.boolean
isLazyLoad()
Gets whether or not the unmarshalling should read lines lazily.void
marshal(org.apache.camel.Exchange exchange, Object body, OutputStream stream)
DF
setAsMap(boolean asMap)
Sets whether or not the unmarshalling should produces maps instead of lists.DF
setComment(Character comment)
Gets the comment symbol.DF
setEmptyValue(String emptyValue)
Sets the String representation of an empty value.DF
setHeaderExtractionEnabled(Boolean headerExtractionEnabled)
Sets whether or not the header extraction is enabled.DF
setHeaders(String[] headers)
Sets the headers.DF
setHeadersDisabled(boolean headersDisabled)
Sets whether or not headers are disabled.DF
setIgnoreLeadingWhitespaces(Boolean ignoreLeadingWhitespaces)
Sets whether or not leading whitespaces should be ignored.DF
setIgnoreTrailingWhitespaces(Boolean ignoreTrailingWhitespaces)
Sets whether or not trailing whitespaces should be ignored.DF
setLazyLoad(boolean lazyLoad)
Sets whether or not the unmarshalling should read lines lazily.DF
setLineSeparator(String lineSeparator)
Sets the line separator.DF
setNormalizedLineSeparator(Character normalizedLineSeparator)
Sets the normalized line separator.DF
setNullValue(String nullValue)
Sets the String representation of a null value.DF
setNumberOfRecordsToRead(Integer numberOfRecordsToRead)
Sets the number of records to read.DF
setSkipEmptyLines(Boolean skipEmptyLines)
Sets whether or not empty lines should be ignored.Object
unmarshal(org.apache.camel.Exchange exchange, InputStream stream)
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
nullValue
protected String nullValue
-
skipEmptyLines
protected Boolean skipEmptyLines
-
ignoreTrailingWhitespaces
protected Boolean ignoreTrailingWhitespaces
-
ignoreLeadingWhitespaces
protected Boolean ignoreLeadingWhitespaces
-
headersDisabled
protected boolean headersDisabled
-
headers
protected String[] headers
-
headerExtractionEnabled
protected Boolean headerExtractionEnabled
-
numberOfRecordsToRead
protected Integer numberOfRecordsToRead
-
emptyValue
protected String emptyValue
-
lineSeparator
protected String lineSeparator
-
normalizedLineSeparator
protected Character normalizedLineSeparator
-
comment
protected Character comment
-
lazyLoad
protected boolean lazyLoad
-
asMap
protected boolean asMap
-
-
Method Detail
-
marshal
public void marshal(org.apache.camel.Exchange exchange, Object body, OutputStream stream) throws Exception
- Specified by:
marshal
in interfaceorg.apache.camel.spi.DataFormat
- Throws:
Exception
-
unmarshal
public Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
- Specified by:
unmarshal
in interfaceorg.apache.camel.spi.DataFormat
- Throws:
Exception
-
getNullValue
public String getNullValue()
Gets the String representation of a null value. Ifnull
then the default settings value is used.- Returns:
- the String representation of a null value
- See Also:
CommonSettings.getNullValue()
-
setNullValue
public DF setNullValue(String nullValue)
Sets the String representation of a null value. Ifnull
then the default settings value is used.- Parameters:
nullValue
- the String representation of a null value- Returns:
- current data format instance, fluent API
- See Also:
CommonSettings.setNullValue(String)
-
getSkipEmptyLines
public Boolean getSkipEmptyLines()
Gets whether or not empty lines should be ignored. Ifnull
then the default settings value is used.- Returns:
- whether or not empty lines should be ignored
- See Also:
CommonSettings.getSkipEmptyLines()
-
setSkipEmptyLines
public DF setSkipEmptyLines(Boolean skipEmptyLines)
Sets whether or not empty lines should be ignored. Ifnull
then the default settings value is used.- Parameters:
skipEmptyLines
- whether or not empty lines should be ignored- Returns:
- current data format instance, fluent API
- See Also:
CommonSettings.setSkipEmptyLines(boolean)
-
getIgnoreTrailingWhitespaces
public Boolean getIgnoreTrailingWhitespaces()
Gets whether or not trailing whitespaces should be ignored. Ifnull
then the default settings value is used.- Returns:
- whether or not trailing whitespaces should be ignored
- See Also:
CommonSettings.getIgnoreTrailingWhitespaces()
-
setIgnoreTrailingWhitespaces
public DF setIgnoreTrailingWhitespaces(Boolean ignoreTrailingWhitespaces)
Sets whether or not trailing whitespaces should be ignored. Ifnull
then the default settings value is used.- Parameters:
ignoreTrailingWhitespaces
- whether or not trailing whitespaces should be ignored- Returns:
- current data format instance, fluent API
- See Also:
CommonSettings.setIgnoreTrailingWhitespaces(boolean)
-
getIgnoreLeadingWhitespaces
public Boolean getIgnoreLeadingWhitespaces()
Gets whether or not leading whitespaces should be ignored. Ifnull
then the default settings value is used.- Returns:
- whether or not leading whitespaces should be ignored
- See Also:
CommonSettings.getIgnoreLeadingWhitespaces()
-
setIgnoreLeadingWhitespaces
public DF setIgnoreLeadingWhitespaces(Boolean ignoreLeadingWhitespaces)
Sets whether or not leading whitespaces should be ignored. Ifnull
then the default settings value is used.- Parameters:
ignoreLeadingWhitespaces
- whether or not leading whitespaces should be ignored- Returns:
- current data format instance, fluent API
- See Also:
CommonSettings.setIgnoreLeadingWhitespaces(boolean)
-
isHeadersDisabled
public boolean isHeadersDisabled()
Gets whether or not headers are disabled. Iftrue
then it passesnull
toCommonSettings.setHeaders(String...)
in order to disabled them.- Returns:
- whether or not headers are disabled
- See Also:
CommonSettings.getHeaders()
-
setHeadersDisabled
public DF setHeadersDisabled(boolean headersDisabled)
Sets whether or not headers are disabled. Iftrue
then it passesnull
toCommonSettings.setHeaders(String...)
in order to disabled them.- Parameters:
headersDisabled
- whether or not headers are disabled- Returns:
- current data format instance, fluent API
- See Also:
CommonSettings.setHeaders(String...)
-
getHeaders
public String[] getHeaders()
Gets the headers. Ifnull
then the default settings value is used.- Returns:
- the headers
- See Also:
CommonSettings.getHeaders()
-
setHeaders
public DF setHeaders(String[] headers)
Sets the headers. Ifnull
then the default settings value is used.- Parameters:
headers
- the headers- Returns:
- current data format instance, fluent API
- See Also:
CommonSettings.setHeaders(String...)
-
getHeaderExtractionEnabled
public Boolean getHeaderExtractionEnabled()
Gets whether or not the header extraction is enabled. Ifnull
then the default settings value is used.- Returns:
- whether or not the header extraction is enabled
- See Also:
CommonParserSettings.isHeaderExtractionEnabled()
-
setHeaderExtractionEnabled
public DF setHeaderExtractionEnabled(Boolean headerExtractionEnabled)
Sets whether or not the header extraction is enabled. Ifnull
then the default settings value is used.- Parameters:
headerExtractionEnabled
- whether or not the header extraction is enabled- Returns:
- current data format instance, fluent API
- See Also:
CommonParserSettings.setHeaderExtractionEnabled(boolean)
-
getNumberOfRecordsToRead
public Integer getNumberOfRecordsToRead()
Gets the number of records to read. Ifnull
then the default settings value is used.- Returns:
- the number of records to read
- See Also:
CommonParserSettings.getNumberOfRecordsToRead()
-
setNumberOfRecordsToRead
public DF setNumberOfRecordsToRead(Integer numberOfRecordsToRead)
Sets the number of records to read. Ifnull
then the default settings value is used.- Parameters:
numberOfRecordsToRead
- the number of records to read- Returns:
- current data format instance, fluent API
- See Also:
CommonParserSettings.setNumberOfRecordsToRead(long)
-
getEmptyValue
public String getEmptyValue()
Gets the String representation of an empty value. Ifnull
then the default settings value is used.- Returns:
- the String representation of an empty value
- See Also:
CommonWriterSettings.getEmptyValue()
-
setEmptyValue
public DF setEmptyValue(String emptyValue)
Sets the String representation of an empty value. Ifnull
then the default settings value is used.- Parameters:
emptyValue
- the String representation of an empty value- Returns:
- current data format instance, fluent API
- See Also:
CommonWriterSettings.setEmptyValue(String)
-
getLineSeparator
public String getLineSeparator()
Gets the line separator. Ifnull
then the default format value is used.- Returns:
- the line separator
- See Also:
Format.getLineSeparatorString()
-
setLineSeparator
public DF setLineSeparator(String lineSeparator)
Sets the line separator. Ifnull
then the default format value is used.- Parameters:
lineSeparator
- the line separator- Returns:
- current data format instance, fluent API
- See Also:
Format.setLineSeparator(String)
-
getNormalizedLineSeparator
public Character getNormalizedLineSeparator()
Gets the normalized line separator. Ifnull
then the default format value is used.- Returns:
- the normalized line separator
- See Also:
Format.getNormalizedNewline()
-
setNormalizedLineSeparator
public DF setNormalizedLineSeparator(Character normalizedLineSeparator)
Sets the normalized line separator. Ifnull
then the default format value is used.- Parameters:
normalizedLineSeparator
- the normalized line separator- Returns:
- current data format instance, fluent API
- See Also:
Format.setNormalizedNewline(char)
-
getComment
public Character getComment()
Gets the comment symbol. Ifnull
then the default format value is used.- Returns:
- the comment symbol
- See Also:
Format.getComment()
-
setComment
public DF setComment(Character comment)
Gets the comment symbol. Ifnull
then the default format value is used.- Parameters:
comment
- the comment symbol- Returns:
- current data format instance, fluent API
- See Also:
Format.setComment(char)
-
isLazyLoad
public boolean isLazyLoad()
Gets whether or not the unmarshalling should read lines lazily.- Returns:
- whether or not the unmarshalling should read lines lazily
-
setLazyLoad
public DF setLazyLoad(boolean lazyLoad)
Sets whether or not the unmarshalling should read lines lazily.- Parameters:
lazyLoad
- whether or not the unmarshalling should read lines lazily- Returns:
- current data format instance, fluent API
-
isAsMap
public boolean isAsMap()
Gets whether or not the unmarshalling should produces maps instead of lists.- Returns:
- whether or not the unmarshalling should produces maps instead of lists
-
setAsMap
public DF setAsMap(boolean asMap)
Sets whether or not the unmarshalling should produces maps instead of lists.- Parameters:
asMap
- whether or not the unmarshalling should produces maps instead of lists- Returns:
- current data format instance, fluent API
-
createWriterSettings
protected abstract CWS createWriterSettings()
Creates a new instance of the writer settings.- Returns:
- New instance of the writer settings
-
configureWriterSettings
protected void configureWriterSettings(CWS settings)
Configures the writer settings.- Parameters:
settings
- Writer settings to configure
-
createWriter
protected abstract W createWriter(Writer writer, CWS settings)
Creates a new instance of the uniVocity writer.- Parameters:
writer
- Output writer to usesettings
- Writer settings to use- Returns:
- New uinstance of the uniVocity writer
-
createParserSettings
protected abstract CPS createParserSettings()
Creates a new instance of the parser settings.- Returns:
- New instance of the parser settings
-
configureParserSettings
protected void configureParserSettings(CPS settings)
Configure the parser settings.- Parameters:
settings
- Parser settings to configure
-
createParser
protected abstract P createParser(CPS settings)
Creates a new instance of the uniVocity parser.- Parameters:
settings
- Parser settings to use- Returns:
- New instance of the uniVocity parser
-
configureFormat
protected void configureFormat(F format)
Configures the format.- Parameters:
format
- format to configure
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
-