Class DefaultRecordSeparatorPolicy
java.lang.Object
org.springframework.batch.item.file.separator.SimpleRecordSeparatorPolicy
org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy
- All Implemented Interfaces:
RecordSeparatorPolicy
- Direct Known Subclasses:
SuffixRecordSeparatorPolicy
A
RecordSeparatorPolicy
that treats all lines as record endings, as long as
they do not have unterminated quotes, and do not end in a continuation marker.- Author:
- Dave Syer, Mahmoud Ben Hassine
-
Constructor Summary
ConstructorDescriptionDefault constructor.DefaultRecordSeparatorPolicy
(String quoteCharacter) Convenient constructor with quote character as parameter.DefaultRecordSeparatorPolicy
(String quoteCharacter, String continuation) Convenient constructor with quote character and continuation marker as parameters. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isEndOfRecord
(String line) Return true if the line does not have unterminated quotes (delimited by "), and does not end with a continuation marker ('\').preProcess
(String line) If we are in an unterminated quote, add a line separator.void
setContinuation
(String continuation) Public setter for the continuation.void
setQuoteCharacter
(String quoteCharacter) Public setter for the quoteCharacter.Methods inherited from class org.springframework.batch.item.file.separator.SimpleRecordSeparatorPolicy
postProcess
-
Constructor Details
-
DefaultRecordSeparatorPolicy
public DefaultRecordSeparatorPolicy()Default constructor. -
DefaultRecordSeparatorPolicy
Convenient constructor with quote character as parameter.- Parameters:
quoteCharacter
- value used to indicate a quoted string
-
DefaultRecordSeparatorPolicy
Convenient constructor with quote character and continuation marker as parameters.- Parameters:
quoteCharacter
- value used to indicate a quoted stringcontinuation
- value used to indicate a line continuation
-
-
Method Details
-
setQuoteCharacter
Public setter for the quoteCharacter. Defaults to double quote mark.- Parameters:
quoteCharacter
- the quoteCharacter to set
-
setContinuation
Public setter for the continuation. Defaults to back slash.- Parameters:
continuation
- the continuation to set
-
isEndOfRecord
Return true if the line does not have unterminated quotes (delimited by "), and does not end with a continuation marker ('\'). The test for the continuation marker ignores whitespace at the end of the line.- Specified by:
isEndOfRecord
in interfaceRecordSeparatorPolicy
- Overrides:
isEndOfRecord
in classSimpleRecordSeparatorPolicy
- Parameters:
line
- a String without a newline character at the end.- Returns:
- true if this line is a complete record.
- See Also:
-
preProcess
If we are in an unterminated quote, add a line separator. Otherwise remove the continuation marker (plus whitespace at the end) if it is there.- Specified by:
preProcess
in interfaceRecordSeparatorPolicy
- Overrides:
preProcess
in classSimpleRecordSeparatorPolicy
- Parameters:
line
- the current record.- Returns:
- the line as it should be appended to a record.
- See Also:
-