org.springframework.batch.item.file.separator

## 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

      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

    Constructors
    Constructor and Description
    `DefaultRecordSeparatorPolicy()` Default constructor.
    `DefaultRecordSeparatorPolicy(java.lang.String quoteCharacter)` Convenient constructor with quote character as parameter.
    `DefaultRecordSeparatorPolicy(java.lang.String quoteCharacter, java.lang.String continuation)` Convenient constructor with quote character and continuation marker as parameters.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isEndOfRecord(java.lang.String line)` Return true if the line does not have unterminated quotes (delimited by "), and does not end with a continuation marker ('\').
    `java.lang.String` | `preProcess(java.lang.String line)` If we are in an unterminated quote, add a line separator.
    `void` | `setContinuation(java.lang.String continuation)` Public setter for the continuation.
    `void` | `setQuoteCharacter(java.lang.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(java.lang.String quoteCharacter)

      Convenient constructor with quote character as parameter.
      Parameters:
        `quoteCharacter` - value used to indicate a quoted string

    - #### DefaultRecordSeparatorPolicy

          public DefaultRecordSeparatorPolicy(java.lang.String quoteCharacter,
                                              java.lang.String continuation)

      Convenient constructor with quote character and continuation marker as parameters.
      Parameters:
        `quoteCharacter` - value used to indicate a quoted string
        `continuation` - value used to indicate a line continuation

  - ### Method Detail

    - #### setQuoteCharacter

          public void setQuoteCharacter(java.lang.String quoteCharacter)

      Public setter for the quoteCharacter. Defaults to double quote mark.
      Parameters:
        `quoteCharacter` - the quoteCharacter to set

    - #### setContinuation

          public void setContinuation(java.lang.String continuation)

      Public setter for the continuation. Defaults to back slash.
      Parameters:
        `continuation` - the continuation to set

    - #### isEndOfRecord

          public boolean isEndOfRecord(java.lang.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 a complete record.
      See Also:
        `RecordSeparatorPolicy.isEndOfRecord(java.lang.String)`

    - #### preProcess

          public java.lang.String preProcess(java.lang.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)`