Package org.springframework.batch.item.xml.builder

# Class StaxEventItemWriterBuilder<T>

java.lang.Object
org.springframework.batch.item.xml.builder.StaxEventItemWriterBuilder<T>

public class StaxEventItemWriterBuilder<T> extends Object
A builder for the `StaxEventItemWriter`.

Since:
  4.0
Author:
  Michael Minella, Parikshit Dutta, Mahmoud Ben Hassine
See Also:
  - `StaxEventItemWriter`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StaxEventItemWriterBuilder()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `StaxEventItemWriter<T>`
  `build()`
  Returns a configured `StaxEventItemWriter`
  `StaxEventItemWriterBuilder<T>`
  `encoding(String encoding)`
  Encoding for the file.
  `StaxEventItemWriterBuilder<T>`
  `footerCallback(StaxWriterCallback footerCallback)`
  A `StaxWriterCallback` to provide any footer elements
  `StaxEventItemWriterBuilder<T>`
  `forceSync(boolean forceSync)`
  Flag to indicate that changes should be force-synced to disk on flush.
  `StaxEventItemWriterBuilder<T>`
  `headerCallback(StaxWriterCallback headerCallback)`
  A `StaxWriterCallback` to provide any header elements
  `StaxEventItemWriterBuilder<T>`
  `marshaller(org.springframework.oxm.Marshaller marshaller)`
  The `Marshaller` implementation responsible for the serialization of the items to XML.
  `StaxEventItemWriterBuilder<T>`
  `name(String name)`
  The name used to calculate the key within the `ExecutionContext`.
  `StaxEventItemWriterBuilder<T>`
  `overwriteOutput(boolean overwriteOutput)`
  Indicates if an existing file should be overwritten if found.
  `StaxEventItemWriterBuilder<T>`
  `resource(org.springframework.core.io.Resource resource)`
  The `Resource` to be used as output.
  `StaxEventItemWriterBuilder<T>`
  `rootElementAttributes(Map<String,String> rootElementAttributes)`
  A Map of attributes to be included in the document's root element.
  `StaxEventItemWriterBuilder<T>`
  `rootTagName(String rootTagName)`
  The name of the root tag for the output document.
  `StaxEventItemWriterBuilder<T>`
  `saveState(boolean saveState)`
  Indicates if the state of the writer should be saved in the `ExecutionContext`.
  `StaxEventItemWriterBuilder<T>`
  `shouldDeleteIfEmpty(boolean shouldDelete)`
  Flag to indicate that the output file should be deleted if no results were written to it.
  `StaxEventItemWriterBuilder<T>`
  `standalone(Boolean standalone)`
  Standalone document declaration for the output document.
  `StaxEventItemWriterBuilder<T>`
  `transactional(boolean transactional)`
  The resulting writer is participating in a transaction and writes should be delayed as late as possible.
  `StaxEventItemWriterBuilder<T>`
  `version(String version)`
  Version of XML to be generated.

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

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

- ## Constructor Details

  - ### StaxEventItemWriterBuilder

    public StaxEventItemWriterBuilder()

- ## Method Details

  - ### name

    public StaxEventItemWriterBuilder<T> 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)`

  - ### resource

    public StaxEventItemWriterBuilder<T> resource(org.springframework.core.io.Resource resource)
    The `Resource` to be used as output.
    Parameters:
      `resource` - the output from the writer
    Returns:
      the current instance of the builder.
    See Also:
      - `StaxEventItemWriter.setResource(Resource)`

  - ### marshaller

    public StaxEventItemWriterBuilder<T> marshaller(org.springframework.oxm.Marshaller marshaller)
    The `Marshaller` implementation responsible for the serialization of the items to XML. This field is required.
    Parameters:
      `marshaller` - the component used to generate XML
    Returns:
      the current instance of the builder.
    See Also:
      - `StaxEventItemWriter.setMarshaller(Marshaller)`

  - ### headerCallback

    public StaxEventItemWriterBuilder<T> headerCallback(StaxWriterCallback headerCallback)
    A `StaxWriterCallback` to provide any header elements
    Parameters:
      `headerCallback` - a `StaxWriterCallback`
    Returns:
      the current instance of the builder.
    See Also:
      - `StaxEventItemWriter.setHeaderCallback(StaxWriterCallback)`

  - ### footerCallback

    public StaxEventItemWriterBuilder<T> footerCallback(StaxWriterCallback footerCallback)
    A `StaxWriterCallback` to provide any footer elements
    Parameters:
      `footerCallback` - a `StaxWriterCallback`
    Returns:
      the current instance of the builder.
    See Also:
      - `StaxEventItemWriter.setFooterCallback(StaxWriterCallback)`

  - ### transactional

    public StaxEventItemWriterBuilder<T> transactional(boolean transactional)
    The resulting writer is participating in a transaction and writes should be delayed as late as possible.
    Parameters:
      `transactional` - indicates that the writer is transactional. Defaults to false.
    Returns:
      the current instance of the builder
    See Also:
      - `StaxEventItemWriter.setTransactional(boolean)`

  - ### forceSync

    public StaxEventItemWriterBuilder<T> forceSync(boolean forceSync)
    Flag to indicate that changes should be force-synced to disk on flush.
    Parameters:
      `forceSync` - indicates if force sync should occur. Defaults to false.
    Returns:
      the current instance of the builder
    See Also:
      - `StaxEventItemWriter.setForceSync(boolean)`

  - ### shouldDeleteIfEmpty

    public StaxEventItemWriterBuilder<T> shouldDeleteIfEmpty(boolean shouldDelete)
    Flag to indicate that the output file should be deleted if no results were written to it. Defaults to false.
    Parameters:
      `shouldDelete` - indicator
    Returns:
      the current instance of the builder
    See Also:
      - `StaxEventItemWriter.setShouldDeleteIfEmpty(boolean)`

  - ### encoding

    public StaxEventItemWriterBuilder<T> encoding(String encoding)
    Encoding for the file. Defaults to UTF-8.
    Parameters:
      `encoding` - String encoding algorithm
    Returns:
      the current instance of the builder
    See Also:
      - `StaxEventItemWriter.setEncoding(String)`

  - ### version

    public StaxEventItemWriterBuilder<T> version(String version)
    Version of XML to be generated. Must be supported by the `Marshaller` provided.
    Parameters:
      `version` - XML version
    Returns:
      the current instance of the builder
    See Also:
      - `StaxEventItemWriter.setVersion(String)`

  - ### standalone

    public StaxEventItemWriterBuilder<T> standalone(Boolean standalone)
    Standalone document declaration for the output document. Defaults to `null`.
    Parameters:
      `standalone` - Boolean standalone document declaration
    Returns:
      the current instance of the builder
    Since:
      4.3
    See Also:
      - `StaxEventItemWriter.setStandalone(Boolean)`

  - ### rootTagName

    public StaxEventItemWriterBuilder<T> rootTagName(String rootTagName)
    The name of the root tag for the output document.
    Parameters:
      `rootTagName` - tag name
    Returns:
      the current instance of the builder
    See Also:
      - `StaxEventItemWriter.setRootTagName(String)`

  - ### rootElementAttributes

    public StaxEventItemWriterBuilder<T> rootElementAttributes(Map<String,String> rootElementAttributes)
    A Map of attributes to be included in the document's root element.
    Parameters:
      `rootElementAttributes` - map fo attributes
    Returns:
      the current instance of the builder.
    See Also:
      - `StaxEventItemWriter.setRootElementAttributes(Map)`

  - ### overwriteOutput

    public StaxEventItemWriterBuilder<T> overwriteOutput(boolean overwriteOutput)
    Indicates if an existing file should be overwritten if found. Defaults to true.
    Parameters:
      `overwriteOutput` - indicator
    Returns:
      the current instance of the builder.
    See Also:
      - `StaxEventItemWriter.setOverwriteOutput(boolean)`

  - ### saveState

    public StaxEventItemWriterBuilder<T> saveState(boolean saveState)
    Indicates if the state of the writer should be saved in the `ExecutionContext`. Setting this to false will impact restartability. Defaults to true.
    Parameters:
      `saveState` - indicator
    Returns:
      the current instance of the builder
    See Also:
      - `StaxEventItemWriter.setSaveState(boolean)`

  - ### build

    public StaxEventItemWriter<T> build()
    Returns a configured `StaxEventItemWriter`
    Returns:
      a StaxEventItemWriter