Package org.springframework.batch.item.ldif.builder

# Class LdifReaderBuilder

java.lang.Object
org.springframework.batch.item.ldif.builder.LdifReaderBuilder

public class LdifReaderBuilder extends Object
Creates a fully qualified LdifReader.

Since:
  4.0
Author:
  Glenn Renfro

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LdifReaderBuilder()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `LdifReader`
  `build()`
  Returns a fully constructed `LdifReader`.
  `LdifReaderBuilder`
  `currentItemCount(int currentItemCount)`
  Index for the current item.
  `LdifReaderBuilder`
  `maxItemCount(int maxItemCount)`
  Configure the max number of items to be read.
  `LdifReaderBuilder`
  `name(String name)`
  The name used to calculate the key within the `ExecutionContext`.
  `LdifReaderBuilder`
  `recordsToSkip(int recordsToSkip)`
  Public setter for the number of lines to skip at the start of a file.
  `LdifReaderBuilder`
  `resource(org.springframework.core.io.Resource resource)`
  Establishes the resource that will be used as the input for the LdifReader.
  `LdifReaderBuilder`
  `saveState(boolean saveState)`
  Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
  `LdifReaderBuilder`
  `skippedRecordsCallback(RecordCallbackHandler skippedRecordsCallback)`
  `RecordCallbackHandler` implementations can be used to take action on skipped records.
  `LdifReaderBuilder`
  `strict(boolean strict)`
  In strict mode the reader will throw an exception on `AbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext)` if the input resource does not exist.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LdifReaderBuilder

    public LdifReaderBuilder()

- ## Method Details

  - ### saveState

    public LdifReaderBuilder saveState(boolean saveState)
    Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
    Parameters:
      `saveState` - defaults to true
    Returns:
      The current instance of the builder.

  - ### name

    public LdifReaderBuilder name(String name)
    The name used to calculate the key within the `ExecutionContext`. Required if `saveState(boolean)` is set to true.
    Parameters:
      `name` - name of the reader instance
    Returns:
      The current instance of the builder.
    See Also:
      - `ItemStreamSupport.setName(String)`

  - ### maxItemCount

    public LdifReaderBuilder maxItemCount(int maxItemCount)
    Configure the max number of items to be read.
    Parameters:
      `maxItemCount` - the max items to be read
    Returns:
      The current instance of the builder.
    See Also:
      - `AbstractItemCountingItemStreamItemReader.setMaxItemCount(int)`

  - ### currentItemCount

    public LdifReaderBuilder currentItemCount(int currentItemCount)
    Index for the current item. Used on restarts to indicate where to start from.
    Parameters:
      `currentItemCount` - current index
    Returns:
      this instance for method chaining
    See Also:
      - `AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)`

  - ### strict

    public LdifReaderBuilder strict(boolean strict)
    In strict mode the reader will throw an exception on `AbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext)` if the input resource does not exist.
    Parameters:
      `strict` - true by default
    Returns:
      this instance for method chaining.
    See Also:
      - `LdifReader.setStrict(boolean)`

  - ### skippedRecordsCallback

    public LdifReaderBuilder skippedRecordsCallback(RecordCallbackHandler skippedRecordsCallback)
    `RecordCallbackHandler` implementations can be used to take action on skipped records.
    Parameters:
      `skippedRecordsCallback` - will be called for each one of the initial skipped lines before any items are read.
    Returns:
      this instance for method chaining.
    See Also:
      - `LdifReader.setSkippedRecordsCallback(RecordCallbackHandler)`

  - ### recordsToSkip

    public LdifReaderBuilder recordsToSkip(int recordsToSkip)
    Public setter for the number of lines to skip at the start of a file. Can be used if the file contains a header without useful (column name) information, and without a comment delimiter at the beginning of the lines.
    Parameters:
      `recordsToSkip` - the number of lines to skip
    Returns:
      this instance for method chaining.
    See Also:
      - `LdifReader.setRecordsToSkip(int)`

  - ### resource

    public LdifReaderBuilder resource(org.springframework.core.io.Resource resource)
    Establishes the resource that will be used as the input for the LdifReader.
    Parameters:
      `resource` - the resource that will be read.
    Returns:
      this instance for method chaining.
    See Also:
      - `LdifReader.setResource(Resource)`

  - ### build

    public LdifReader build()
    Returns a fully constructed `LdifReader`.
    Returns:
      a new `LdifReader`