org.springframework.batch.item.file.separator
Class SuffixRecordSeparatorPolicy

java.lang.Object
  extended by org.springframework.batch.item.file.separator.SimpleRecordSeparatorPolicy
      extended by org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy
          extended by org.springframework.batch.item.file.separator.SuffixRecordSeparatorPolicy
All Implemented Interfaces:
RecordSeparatorPolicy

public class SuffixRecordSeparatorPolicy
extends DefaultRecordSeparatorPolicy

A RecordSeparatorPolicy that looks for an exact match for a String at the end of a line (e.g. a semicolon).

Author:
Dave Syer

Field Summary
static String DEFAULT_SUFFIX
          Default value for record terminator suffix.
 
Constructor Summary
SuffixRecordSeparatorPolicy()
           
 
Method Summary
 boolean isEndOfRecord(String line)
          Return true if the line ends with the specified substring.
 String postProcess(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(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SUFFIX

public static final String DEFAULT_SUFFIX
Default value for record terminator suffix.

See Also:
Constant Field Values
Constructor Detail

SuffixRecordSeparatorPolicy

public SuffixRecordSeparatorPolicy()
Method Detail

setSuffix

public void setSuffix(String suffix)
Lines ending in this terminator String signal the end of a record.

Parameters:
suffix -

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 -

isEndOfRecord

public boolean isEndOfRecord(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 interface RecordSeparatorPolicy
Overrides:
isEndOfRecord in class DefaultRecordSeparatorPolicy
Parameters:
line - a String without a newline character at the end.
Returns:
true if this line is the end of a record.
See Also:
RecordSeparatorPolicy.isEndOfRecord(java.lang.String)

postProcess

public String postProcess(String record)
Remove the suffix from the end of the record.

Specified by:
postProcess in interface RecordSeparatorPolicy
Overrides:
postProcess in class SimpleRecordSeparatorPolicy
Parameters:
record - the complete record.
Returns:
a modified version of the record if desired.
See Also:
SimpleRecordSeparatorPolicy.postProcess(java.lang.String)


Copyright © 2008 SpringSource. All Rights Reserved.