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

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

public class DefaultRecordSeparatorPolicy
extends SimpleRecordSeparatorPolicy

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

Constructor Summary
DefaultRecordSeparatorPolicy()
          Default 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
 boolean isEndOfRecord(String line)
          Return true if the line does not have unterminated quotes (delimited by "), and does not end with a continuation marker ('\').
 String 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRecordSeparatorPolicy

public DefaultRecordSeparatorPolicy()
Default constructor.


DefaultRecordSeparatorPolicy

public DefaultRecordSeparatorPolicy(String quoteCharacter)
Convenient constructor with quote character as parameter.


DefaultRecordSeparatorPolicy

public DefaultRecordSeparatorPolicy(String quoteCharacter,
                                    String continuation)
Convenient constructor with quote character and continuation marker as parameters.

Method Detail

setQuoteCharacter

public void setQuoteCharacter(String quoteCharacter)
Public setter for the quoteCharacter. Defaults to double quote mark.

Parameters:
quoteCharacter - the quoteCharacter to set

setContinuation

public void setContinuation(String continuation)
Public setter for the continuation. Defaults to back slash.

Parameters:
continuation - the continuation to set

isEndOfRecord

public boolean isEndOfRecord(String line)
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 interface RecordSeparatorPolicy
Overrides:
isEndOfRecord in class SimpleRecordSeparatorPolicy
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)

preProcess

public String preProcess(String line)
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 interface RecordSeparatorPolicy
Overrides:
preProcess in class SimpleRecordSeparatorPolicy
Parameters:
line - the current record.
Returns:
the line as it should be appended to a record.
See Also:
SimpleRecordSeparatorPolicy.preProcess(java.lang.String)


Copyright © 2008 SpringSource. All Rights Reserved.