|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.batch.item.ExecutionContextUserSupport
org.springframework.batch.item.xml.StaxEventItemReader
public class StaxEventItemReader
Input source for reading XML input based on StAX. It extracts fragments from the input XML document which correspond to records for processing. The fragments are wrapped with StartDocument and EndDocument events so that the fragments can be further processed like standalone XML documents.
| Constructor Summary | |
|---|---|
StaxEventItemReader()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Ensure that all required dependencies for the ItemReader to run are provided after all properties have been set. |
void |
close(ExecutionContext executionContext)
If any resources are needed for the stream to operate they need to be destroyed here. |
void |
mark()
Mark is supported as long as this ItemStream is used in a
single-threaded environment. |
protected boolean |
moveCursorToNextFragment(javax.xml.stream.XMLEventReader reader)
Responsible for moving the cursor before the StartElement of the fragment root. |
void |
open(ExecutionContext executionContext)
Open the stream for the provided ExecutionContext. |
Object |
read()
Read in the next root element from the file, and return it. |
void |
reset()
Reset the stream to the last mark. |
void |
setFragmentDeserializer(EventReaderDeserializer eventReaderDeserializer)
|
void |
setFragmentRootElementName(String fragmentRootElementName)
|
void |
setResource(Resource resource)
|
void |
setSaveState(boolean saveState)
Set the flag that determines whether to save internal data for ExecutionContext. |
void |
update(ExecutionContext executionContext)
Indicates that the execution context provided during open is about to be saved. |
| Methods inherited from class org.springframework.batch.item.ExecutionContextUserSupport |
|---|
getKey, setName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StaxEventItemReader()
| Method Detail |
|---|
public Object read()
read in interface ItemReaderItemReader.read()public void close(ExecutionContext executionContext)
ItemStream
close in interface ItemStreamexecutionContext - TODOpublic void open(ExecutionContext executionContext)
ItemStreamExecutionContext.
open in interface ItemStreampublic void setResource(Resource resource)
public void setFragmentDeserializer(EventReaderDeserializer eventReaderDeserializer)
eventReaderDeserializer - maps xml fragments corresponding to
records to objectspublic void setFragmentRootElementName(String fragmentRootElementName)
fragmentRootElementName - name of the root element of the fragment
TODO String can be ambiguous due to namespaces, use QName?
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface InitializingBeanIllegalArgumentException - if the Resource, FragmentDeserializer or
FragmentRootElementName is null, or if the root element is empty.
IllegalStateException - if the Resource does not exist.
ExceptionInitializingBean.afterPropertiesSet()public void update(ExecutionContext executionContext)
ItemStream
update in interface ItemStreamexecutionContext - to be updatedItemStream.update(ExecutionContext)protected boolean moveCursorToNextFragment(javax.xml.stream.XMLEventReader reader)
true if next fragment was found,
false otherwise.public void mark()
ItemStream is used in a
single-threaded environment. The state backing the mark is a single
counter, keeping track of the current position, so multiple threads
cannot be accommodated.
mark in interface ItemReaderAbstractItemReader.mark()public void reset()
ItemReader
reset in interface ItemReaderpublic void setSaveState(boolean saveState)
ExecutionContext. Only switch this to false if you don't want to
save any state from this stream, and you don't need it to be restartable.
saveState - flag value (default true)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||