Class StaxEventItemReaderBuilder<T>
- java.lang.Object
- org.springframework.batch.item.xml.builder.StaxEventItemReaderBuilder<T>
public class StaxEventItemReaderBuilder<T> extends java.lang.ObjectA fluent builder for theStaxEventItemReader- Since:
- 4.0
- Author:
- Michael Minella, Glenn Renfro
Constructor Summary
Constructors Constructor Description StaxEventItemReaderBuilder()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StaxEventItemReaderBuilder<T>addFragmentRootElements(java.lang.String... fragmentRootElements)Adds the list of fragments to be used as the root of each chunk to the configuration.StaxEventItemReaderBuilder<T>addFragmentRootElements(java.util.List<java.lang.String> fragmentRootElements)Adds the list of fragments to be used as the root of each chunk to the configuration.StaxEventItemReader<T>build()Validates the configuration and builds a newStaxEventItemReaderStaxEventItemReaderBuilder<T>currentItemCount(int currentItemCount)Index for the current item.StaxEventItemReaderBuilder<T>maxItemCount(int maxItemCount)Configure the max number of items to be read.StaxEventItemReaderBuilder<T>name(java.lang.String name)The name used to calculate the key within theExecutionContext.StaxEventItemReaderBuilder<T>resource(org.springframework.core.io.Resource resource)TheResourceto be used as input.StaxEventItemReaderBuilder<T>saveState(boolean saveState)Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.StaxEventItemReaderBuilder<T>strict(boolean strict)Setting this value to true indicates that it is an error if the input does not exist and an exception will be thrown.StaxEventItemReaderBuilder<T>unmarshaller(org.springframework.oxm.Unmarshaller unmarshaller)An implementation of theUnmarshallerfrom Spring's OXM module.StaxEventItemReaderBuilder<T>xmlInputFactory(javax.xml.stream.XMLInputFactory xmlInputFactory)Set theXMLInputFactory.
Method Detail
saveState
public StaxEventItemReaderBuilder<T> saveState(boolean saveState)
Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.- Parameters:
saveState- defaults to true- Returns:
- The current instance of the builder.
name
public StaxEventItemReaderBuilder<T> name(java.lang.String name)
The name used to calculate the key within theExecutionContext. Required ifsaveState(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 StaxEventItemReaderBuilder<T> 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 StaxEventItemReaderBuilder<T> 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)
resource
public StaxEventItemReaderBuilder<T> resource(org.springframework.core.io.Resource resource)
TheResourceto be used as input.- Parameters:
resource- the input to the reader.- Returns:
- The current instance of the builder.
- See Also:
StaxEventItemReader.setResource(Resource)
unmarshaller
public StaxEventItemReaderBuilder<T> unmarshaller(org.springframework.oxm.Unmarshaller unmarshaller)
An implementation of theUnmarshallerfrom Spring's OXM module.- Parameters:
unmarshaller- component responsible for unmarshalling XML chunks- Returns:
- The current instance of the builder.
- See Also:
StaxEventItemReader.setUnmarshaller(org.springframework.oxm.Unmarshaller)
addFragmentRootElements
public StaxEventItemReaderBuilder<T> addFragmentRootElements(java.lang.String... fragmentRootElements)
Adds the list of fragments to be used as the root of each chunk to the configuration.- Parameters:
fragmentRootElements- the XML root elements to be used to identify XML chunks.- Returns:
- The current instance of the builder.
- See Also:
StaxEventItemReader.setFragmentRootElementNames(String[])
addFragmentRootElements
public StaxEventItemReaderBuilder<T> addFragmentRootElements(java.util.List<java.lang.String> fragmentRootElements)
Adds the list of fragments to be used as the root of each chunk to the configuration.- Parameters:
fragmentRootElements- the XML root elements to be used to identify XML chunks.- Returns:
- The current instance of the builder.
- See Also:
StaxEventItemReader.setFragmentRootElementNames(String[])
strict
public StaxEventItemReaderBuilder<T> strict(boolean strict)
Setting this value to true indicates that it is an error if the input does not exist and an exception will be thrown. Defaults to true.- Parameters:
strict- indicates the input file must exist- Returns:
- The current instance of the builder
- See Also:
StaxEventItemReader.setStrict(boolean)
xmlInputFactory
public StaxEventItemReaderBuilder<T> xmlInputFactory(javax.xml.stream.XMLInputFactory xmlInputFactory)
Set theXMLInputFactory.- Parameters:
xmlInputFactory- to use- Returns:
- The current instance of the builder
- See Also:
StaxEventItemReader.setXmlInputFactory(XMLInputFactory)
build
public StaxEventItemReader<T> build()
Validates the configuration and builds a newStaxEventItemReader- Returns:
- a new instance of the
StaxEventItemReader