public class StaxEventItemReader<T> extends AbstractItemCountingItemStreamItemReader<T> implements ResourceAwareItemReaderItemStream<T>, org.springframework.beans.factory.InitializingBean
Constructor and Description |
---|
StaxEventItemReader() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Ensure that all required dependencies for the ItemReader to run are provided after all properties have been set.
|
protected void |
doClose()
Close the resources opened in
AbstractItemCountingItemStreamItemReader.doOpen() . |
protected void |
doOpen()
Open resources necessary to start reading input.
|
protected T |
doRead()
Move to next fragment and map it to item.
|
protected void |
jumpToItem(int itemIndex)
Move to the given item index.
|
protected boolean |
moveCursorToNextFragment(javax.xml.stream.XMLEventReader reader)
Responsible for moving the cursor before the StartElement of the fragment root.
|
void |
setFragmentRootElementName(java.lang.String fragmentRootElementName) |
void |
setFragmentRootElementNames(java.lang.String[] fragmentRootElementNames) |
void |
setResource(org.springframework.core.io.Resource resource) |
void |
setStrict(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. |
void |
setUnmarshaller(org.springframework.oxm.Unmarshaller unmarshaller) |
void |
setXmlInputFactory(javax.xml.stream.XMLInputFactory xmlInputFactory)
Set the
XMLInputFactory . |
close, getCurrentItemCount, isSaveState, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, update
getExecutionContextKey, setExecutionContextName, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, open, update
read
public void setStrict(boolean strict)
AbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext)
if the input resource does not exist.strict
- true by defaultpublic void setResource(org.springframework.core.io.Resource resource)
setResource
in interface ResourceAwareItemReaderItemStream<T>
public void setUnmarshaller(org.springframework.oxm.Unmarshaller unmarshaller)
unmarshaller
- maps xml fragments corresponding to records to objectspublic void setFragmentRootElementName(java.lang.String fragmentRootElementName)
fragmentRootElementName
- name of the root element of the fragmentpublic void setFragmentRootElementNames(java.lang.String[] fragmentRootElementNames)
fragmentRootElementNames
- list of the names of the root element of the fragmentpublic void setXmlInputFactory(javax.xml.stream.XMLInputFactory xmlInputFactory)
XMLInputFactory
.xmlInputFactory
- to usepublic void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.IllegalArgumentException
- if the Resource, FragmentDeserializer or FragmentRootElementName is null, or if
the root element is empty.java.lang.IllegalStateException
- if the Resource does not exist.java.lang.Exception
InitializingBean.afterPropertiesSet()
protected boolean moveCursorToNextFragment(javax.xml.stream.XMLEventReader reader) throws NonTransientResourceException
true
if next fragment was found, false
otherwise.NonTransientResourceException
- if the cursor could not be moved. This will be treated as fatal and
subsequent calls to read will return null.protected void doClose() throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
AbstractItemCountingItemStreamItemReader.doOpen()
.doClose
in class AbstractItemCountingItemStreamItemReader<T>
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the frameworkprotected void doOpen() throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
doOpen
in class AbstractItemCountingItemStreamItemReader<T>
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the frameworkprotected T doRead() throws java.lang.Exception
doRead
in class AbstractItemCountingItemStreamItemReader<T>
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the frameworkprotected void jumpToItem(int itemIndex) throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
AbstractItemCountingItemStreamItemReader.doRead()
.jumpToItem
in class AbstractItemCountingItemStreamItemReader<T>
itemIndex
- index of item (0 based) to jump to.java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the framework