public class CsvDataFormat
extends org.apache.camel.support.ServiceSupport
implements org.apache.camel.spi.DataFormat, org.apache.camel.spi.DataFormatName
Constructor and Description |
---|
CsvDataFormat() |
CsvDataFormat(org.apache.commons.csv.CSVFormat format) |
Modifier and Type | Method and Description |
---|---|
protected void |
doStart() |
protected void |
doStop() |
Boolean |
getAllowMissingColumnNames()
Indicates whether or not missing column names are allowed.
|
Character |
getCommentMarker()
Gets the comment marker.
|
String |
getDataFormatName() |
Character |
getDelimiter()
Gets the delimiter.
|
Character |
getEscape()
Gets the escape character.
|
org.apache.commons.csv.CSVFormat |
getFormat()
Gets the CSV format before applying any changes.
|
String[] |
getHeader()
Gets the header.
|
Boolean |
getIgnoreEmptyLines()
Indicates whether or not empty lines must be ignored.
|
Boolean |
getIgnoreSurroundingSpaces()
Indicates whether or not surrounding spaces must be ignored.
|
String |
getNullString()
Gets the null string replacement.
|
Character |
getQuote()
Gets the quote character.
|
org.apache.commons.csv.QuoteMode |
getQuoteMode()
Gets the quote mode.
|
org.apache.camel.dataformat.csv.CsvRecordConverter<?> |
getRecordConverter()
Gets the record converter to use.
|
String |
getRecordSeparator()
Gets the record separator.
|
Boolean |
getSkipHeaderRecord()
Indicates whether or not header record must be skipped.
|
boolean |
isCommentMarkerDisabled()
Indicates whether or not the comment markers are disabled.
|
boolean |
isEscapeDisabled()
Indicates whether or not the escaping is disabled.
|
boolean |
isHeaderDisabled()
Indicates whether or not the headers are disabled.
|
boolean |
isLazyLoad()
Indicates whether or not the unmarshalling should lazily load the records.
|
boolean |
isNullStringDisabled()
Indicates whether or not the null string replacement is disabled.
|
boolean |
isQuoteDisabled()
Indicates whether or not quotes are disabled.
|
boolean |
isRecordSeparatorDisabled()
Indicates whether or not the record separator is disabled.
|
boolean |
isUseMaps()
Indicates whether or not the unmarshalling should produce maps instead of lists.
|
void |
marshal(org.apache.camel.Exchange exchange,
Object object,
OutputStream outputStream) |
CsvDataFormat |
setAllowMissingColumnNames(Boolean allowMissingColumnNames)
Sets whether or not missing column names are allowed.
|
CsvDataFormat |
setCommentMarker(Character commentMarker)
Sets the comment marker to use.
|
CsvDataFormat |
setCommentMarkerDisabled(boolean commentMarkerDisabled)
Sets whether or not the comment markers are disabled.
|
CsvDataFormat |
setDelimiter(Character delimiter)
Sets the delimiter.
|
CsvDataFormat |
setEscape(Character escape)
Sets the escape character.
|
CsvDataFormat |
setEscapeDisabled(boolean escapeDisabled)
Sets whether or not the escaping is disabled.
|
CsvDataFormat |
setFormat(org.apache.commons.csv.CSVFormat format)
Sets the CSV format before applying any changes.
|
CsvDataFormat |
setFormatName(String name)
Sets the CSV format by name before applying any changes.
|
CsvDataFormat |
setHeader(String[] header)
Gets the header.
|
CsvDataFormat |
setHeaderDisabled(boolean headerDisabled)
Sets whether or not the headers are disabled.
|
CsvDataFormat |
setIgnoreEmptyLines(Boolean ignoreEmptyLines)
Sets whether or not empty lines must be ignored.
|
CsvDataFormat |
setIgnoreSurroundingSpaces(Boolean ignoreSurroundingSpaces)
Sets whether or not surrounding spaces must be ignored.
|
CsvDataFormat |
setLazyLoad(boolean lazyLoad)
Indicates whether or not the unmarshalling should lazily load the records.
|
CsvDataFormat |
setNullString(String nullString)
Sets the null string replacement.
|
CsvDataFormat |
setNullStringDisabled(boolean nullStringDisabled)
Sets whether or not the null string replacement is disabled.
|
CsvDataFormat |
setQuote(Character quote)
Sets the quote character.
|
CsvDataFormat |
setQuoteDisabled(boolean quoteDisabled)
Sets whether or not quotes are disabled
|
CsvDataFormat |
setQuoteMode(org.apache.commons.csv.QuoteMode quoteMode)
Sets the quote mode.
|
CsvDataFormat |
setRecordConverter(org.apache.camel.dataformat.csv.CsvRecordConverter<?> recordConverter)
Sets the record converter to use.
|
CsvDataFormat |
setRecordSeparator(String recordSeparator)
Sets the record separator.
|
CsvDataFormat |
setRecordSeparatorDisabled(boolean recordSeparatorDisabled)
Sets whether or not the record separator is disabled.
|
CsvDataFormat |
setSkipHeaderRecord(Boolean skipHeaderRecord)
Sets whether or not header record must be skipped.
|
CsvDataFormat |
setUseMaps(boolean useMaps)
Sets whether or not the unmarshalling should produce maps instead of lists.
|
Object |
unmarshal(org.apache.camel.Exchange exchange,
InputStream inputStream) |
public CsvDataFormat()
public CsvDataFormat(org.apache.commons.csv.CSVFormat format)
public String getDataFormatName()
getDataFormatName
in interface org.apache.camel.spi.DataFormatName
public void marshal(org.apache.camel.Exchange exchange, Object object, OutputStream outputStream) throws Exception
marshal
in interface org.apache.camel.spi.DataFormat
Exception
public Object unmarshal(org.apache.camel.Exchange exchange, InputStream inputStream) throws Exception
unmarshal
in interface org.apache.camel.spi.DataFormat
Exception
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.ServiceSupport
Exception
protected void doStop() throws Exception
doStop
in class org.apache.camel.support.ServiceSupport
Exception
public org.apache.commons.csv.CSVFormat getFormat()
null
, the default one is CSVFormat.DEFAULT
.public CsvDataFormat setFormat(org.apache.commons.csv.CSVFormat format)
null
, then CSVFormat.DEFAULT
is used instead.format
- CSV formatCsvDataFormat
, fluent APICSVFormat
,
CSVFormat.DEFAULT
public CsvDataFormat setFormatName(String name)
name
- CSV format nameCsvDataFormat
, fluent APIsetFormat(org.apache.commons.csv.CSVFormat)
,
CSVFormat
public boolean isCommentMarkerDisabled()
true
if the comment markers are disabled, false
otherwisepublic CsvDataFormat setCommentMarkerDisabled(boolean commentMarkerDisabled)
commentMarkerDisabled
- true
if the comment markers are disabled, false
otherwiseCsvDataFormat
, fluent APICSVFormat.withCommentMarker(java.lang.Character)
public Character getCommentMarker()
null
then the default one of the format used.public CsvDataFormat setCommentMarker(Character commentMarker)
null
then the default one of the format used.commentMarker
- Comment markerCsvDataFormat
, fluent APICSVFormat.withCommentMarker(Character)
public Character getDelimiter()
null
then the default one of the format used.public CsvDataFormat setDelimiter(Character delimiter)
null
then the default one of the format used.delimiter
- DelimiterCsvDataFormat
, fluent APICSVFormat.withDelimiter(char)
public boolean isEscapeDisabled()
true
if the escaping is disabled, false
otherwisepublic CsvDataFormat setEscapeDisabled(boolean escapeDisabled)
escapeDisabled
- true
if the escaping is disabled, false
otherwiseCsvDataFormat
, fluent APICSVFormat.withEscape(Character)
public Character getEscape()
null
then the default one of the format used.public CsvDataFormat setEscape(Character escape)
null
then the default one of the format used.escape
- Escape characterCsvDataFormat
, fluent APICSVFormat.withEscape(Character)
public boolean isHeaderDisabled()
true
if the headers are disabled, false
otherwisepublic CsvDataFormat setHeaderDisabled(boolean headerDisabled)
headerDisabled
- true
if the headers are disabled, false
otherwiseCsvDataFormat
, fluent APICSVFormat.withHeader(String...)
public String[] getHeader()
null
then the default one of the format used. If empty then it will be automatically handled.public CsvDataFormat setHeader(String[] header)
null
then the default one of the format used. If empty then it will be automatically handled.header
- HeaderCsvDataFormat
, fluent APICSVFormat.withHeader(String...)
public Boolean getAllowMissingColumnNames()
null
then the default value of the format used.public CsvDataFormat setAllowMissingColumnNames(Boolean allowMissingColumnNames)
null
then the default value of the format used.allowMissingColumnNames
- Whether or not missing column names are allowedCsvDataFormat
, fluent APICSVFormat.withAllowMissingColumnNames(boolean)
public Boolean getIgnoreEmptyLines()
null
then the default value of the format used.public CsvDataFormat setIgnoreEmptyLines(Boolean ignoreEmptyLines)
null
then the default value of the format used.ignoreEmptyLines
- Whether or not empty lines must be ignoredCsvDataFormat
, fluent APICSVFormat.withIgnoreEmptyLines(boolean)
public Boolean getIgnoreSurroundingSpaces()
null
then the default value of the format used.public CsvDataFormat setIgnoreSurroundingSpaces(Boolean ignoreSurroundingSpaces)
null
then the default value of the format used.ignoreSurroundingSpaces
- Whether or not surrounding spaces must be ignoredCsvDataFormat
, fluent APICSVFormat.withIgnoreSurroundingSpaces(boolean)
public boolean isNullStringDisabled()
true
if the null string replacement is disabled, false
otherwisepublic CsvDataFormat setNullStringDisabled(boolean nullStringDisabled)
nullStringDisabled
- true
if the null string replacement is disabled, false
otherwiseCsvDataFormat
, fluent APICSVFormat.withNullString(String)
public String getNullString()
null
then the default one of the format used.public CsvDataFormat setNullString(String nullString)
null
then the default one of the format used.nullString
- Null string replacementCsvDataFormat
, fluent APICSVFormat.withNullString(String)
public boolean isQuoteDisabled()
true
if quotes are disabled, false
otherwisepublic CsvDataFormat setQuoteDisabled(boolean quoteDisabled)
quoteDisabled
- true
if quotes are disabled, false
otherwiseCsvDataFormat
, fluent APICSVFormat.withQuote(Character)
public Character getQuote()
null
then the default one of the format used.public CsvDataFormat setQuote(Character quote)
null
then the default one of the format used.quote
- Quote characterCsvDataFormat
, fluent APICSVFormat.withQuote(Character)
public org.apache.commons.csv.QuoteMode getQuoteMode()
null
then the default one of the format used.public CsvDataFormat setQuoteMode(org.apache.commons.csv.QuoteMode quoteMode)
null
then the default one of the format used.quoteMode
- Quote modeCsvDataFormat
, fluent APICSVFormat.withQuoteMode(org.apache.commons.csv.QuoteMode)
public boolean isRecordSeparatorDisabled()
true
if the record separator disabled, false
otherwisepublic CsvDataFormat setRecordSeparatorDisabled(boolean recordSeparatorDisabled)
recordSeparatorDisabled
- true
if the record separator disabled, false
otherwiseCsvDataFormat
, fluent APICSVFormat.withRecordSeparator(String)
public String getRecordSeparator()
null
then the default one of the format used.public CsvDataFormat setRecordSeparator(String recordSeparator)
null
then the default one of the format used.recordSeparator
- Record separatorCsvDataFormat
, fluent APICSVFormat.withRecordSeparator(String)
public Boolean getSkipHeaderRecord()
null
then the default value of the format used.public CsvDataFormat setSkipHeaderRecord(Boolean skipHeaderRecord)
null
then the default value of the format used.skipHeaderRecord
- Whether or not header record must be skippedCsvDataFormat
, fluent APICSVFormat.withSkipHeaderRecord(boolean)
public boolean isLazyLoad()
true
for lazy loading, false
otherwisepublic CsvDataFormat setLazyLoad(boolean lazyLoad)
lazyLoad
- true
for lazy loading, false
otherwiseCsvDataFormat
, fluent APIpublic boolean isUseMaps()
true
for maps, false
for listspublic CsvDataFormat setUseMaps(boolean useMaps)
useMaps
- true
for maps, false
for listsCsvDataFormat
, fluent APIpublic org.apache.camel.dataformat.csv.CsvRecordConverter<?> getRecordConverter()
null
then it will use isUseMaps()
for finding
the proper converter.public CsvDataFormat setRecordConverter(org.apache.camel.dataformat.csv.CsvRecordConverter<?> recordConverter)
null
then it will use isUseMaps()
for finding
the proper converter.recordConverter
- Record converter to useCsvDataFormat
, fluent APIApache Camel