Class SuffixRecordSeparatorPolicy
- java.lang.Object
- org.springframework.batch.item.file.separator.SimpleRecordSeparatorPolicy
- org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy
- org.springframework.batch.item.file.separator.SuffixRecordSeparatorPolicy
- All Implemented Interfaces:
RecordSeparatorPolicy
public class SuffixRecordSeparatorPolicy extends DefaultRecordSeparatorPolicy
ARecordSeparatorPolicy
that looks for an exact match for a String at the end of a line (e.g. a semicolon).- Author:
- Dave Syer
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_SUFFIX
Default value for record terminator suffix.
Constructor Summary
Constructors Constructor Description SuffixRecordSeparatorPolicy()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isEndOfRecord(java.lang.String line)
Return true if the line ends with the specified substring.java.lang.String
postProcess(java.lang.String record)
Remove the suffix from the end of the record.void
setIgnoreWhitespace(boolean ignoreWhitespace)
Flag to indicate that the decision to terminate a record should ignore whitespace at the end of the line.void
setSuffix(java.lang.String suffix)
Lines ending in this terminator String signal the end of a record.Methods inherited from class org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy
preProcess, setContinuation, setQuoteCharacter
Field Detail
DEFAULT_SUFFIX
public static final java.lang.String DEFAULT_SUFFIX
Default value for record terminator suffix.- See Also:
- Constant Field Values
Method Detail
setSuffix
public void setSuffix(java.lang.String suffix)
Lines ending in this terminator String signal the end of a record.- Parameters:
suffix
- suffix to indicate the end of a record
setIgnoreWhitespace
public void setIgnoreWhitespace(boolean ignoreWhitespace)
Flag to indicate that the decision to terminate a record should ignore whitespace at the end of the line.- Parameters:
ignoreWhitespace
- indicator
isEndOfRecord
public boolean isEndOfRecord(java.lang.String line)
Return true if the line ends with the specified substring. By default whitespace is trimmed before the comparison. Also returns true if the line is null, but not if it is empty.- Specified by:
isEndOfRecord
in interfaceRecordSeparatorPolicy
- Overrides:
isEndOfRecord
in classDefaultRecordSeparatorPolicy
- Parameters:
line
- a String without a newline character at the end.- Returns:
- true if this line is a complete record.
- See Also:
RecordSeparatorPolicy.isEndOfRecord(java.lang.String)
postProcess
public java.lang.String postProcess(java.lang.String record)
Remove the suffix from the end of the record.- Specified by:
postProcess
in interfaceRecordSeparatorPolicy
- Overrides:
postProcess
in classSimpleRecordSeparatorPolicy
- Parameters:
record
- the complete record.- Returns:
- a modified version of the record if desired.
- See Also:
SimpleRecordSeparatorPolicy.postProcess(java.lang.String)