Class StaxEventItemReaderBuilder<T>
java.lang.Object
org.springframework.batch.item.xml.builder.StaxEventItemReaderBuilder<T>
A fluent builder for the
StaxEventItemReader
- Since:
- 4.0
- Author:
- Michael Minella, Glenn Renfro, Mahmoud Ben Hassine, Parikshit Dutta
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddFragmentRootElements
(String... fragmentRootElements) Adds the list of fragments to be used as the root of each chunk to the configuration.addFragmentRootElements
(List<String> fragmentRootElements) Adds the list of fragments to be used as the root of each chunk to the configuration.build()
Validates the configuration and builds a newStaxEventItemReader
currentItemCount
(int currentItemCount) Index for the current item.Encoding for the input file.maxItemCount
(int maxItemCount) Configure the max number of items to be read.The name used to calculate the key within theExecutionContext
.resource
(org.springframework.core.io.Resource resource) TheResource
to be used as input.saveState
(boolean saveState) Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.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.unmarshaller
(org.springframework.oxm.Unmarshaller unmarshaller) An implementation of theUnmarshaller
from Spring's OXM module.xmlInputFactory
(XMLInputFactory xmlInputFactory) Set theXMLInputFactory
.
-
Field Details
-
logger
protected org.apache.commons.logging.Log logger
-
-
Constructor Details
-
StaxEventItemReaderBuilder
public StaxEventItemReaderBuilder()
-
-
Method Details
-
saveState
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.- Parameters:
saveState
- defaults to true- Returns:
- The current instance of the builder.
-
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:
-
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:
-
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:
-
resource
TheResource
to be used as input.- Parameters:
resource
- the input to the reader.- Returns:
- The current instance of the builder.
- See Also:
-
unmarshaller
public StaxEventItemReaderBuilder<T> unmarshaller(org.springframework.oxm.Unmarshaller unmarshaller) An implementation of theUnmarshaller
from Spring's OXM module.- Parameters:
unmarshaller
- component responsible for unmarshalling XML chunks- Returns:
- The current instance of the builder.
- See Also:
-
addFragmentRootElements
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:
-
addFragmentRootElements
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:
-
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:
-
xmlInputFactory
Set theXMLInputFactory
.- Parameters:
xmlInputFactory
- to use- Returns:
- The current instance of the builder
- See Also:
-
encoding
Encoding for the input file. Defaults toStaxEventItemReader.DEFAULT_ENCODING
.- Parameters:
encoding
- String encoding algorithm- Returns:
- the current instance of the builder
- See Also:
-
build
Validates the configuration and builds a newStaxEventItemReader
- Returns:
- a new instance of the
StaxEventItemReader
-