|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.item.util.ExecutionContextUserSupport org.springframework.batch.item.xml.StaxEventItemWriter
public class StaxEventItemWriter
An implementation of ItemWriter
which uses StAX and
EventWriterSerializer
for serializing object to XML.
This item writer also provides restart, statistics and transaction features
by implementing corresponding interfaces.
Output is buffered until flush()
is called - only then the actual
writing to file takes place.
The implementation is *not* thread-safe.
Constructor Summary | |
---|---|
StaxEventItemWriter()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
void |
clear()
Clear the output buffer |
void |
close(ExecutionContext executionContext)
Flush and close the output source. |
protected void |
endDocument(javax.xml.stream.XMLEventWriter writer)
Writes the EndDocument tag manually. |
void |
flush()
Writes buffered items to XML stream and marks restore point. |
String |
getEncoding()
Get used encoding. |
Map |
getRootElementAttributes()
Get attributes of the root element. |
String |
getRootTagName()
Get the tag name of the root element. |
String |
getVersion()
Get XML version. |
void |
open(ExecutionContext executionContext)
Open the output source |
void |
setEncoding(String encoding)
Set encoding to be used for output file. |
void |
setHeaderItems(Object[] headers)
Setter for the headers. |
void |
setOverwriteOutput(boolean overwriteOutput)
Set "overwrite" flag for the output file. |
void |
setResource(Resource resource)
Set output file. |
void |
setRootElementAttributes(Map rootElementAttributes)
Set the root element attributes to be written. |
void |
setRootTagName(String rootTagName)
Set the tag name of the root element. |
void |
setSaveState(boolean saveState)
|
void |
setSerializer(EventWriterSerializer serializer)
Set Object to XML serializer. |
void |
setVersion(String version)
Set XML version to be used for output XML. |
void |
update(ExecutionContext executionContext)
Get the restart data. |
void |
write(Object item)
Write the value object to internal buffer. |
Methods inherited from class org.springframework.batch.item.util.ExecutionContextUserSupport |
---|
getKey, setName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StaxEventItemWriter()
Method Detail |
---|
public void setResource(Resource resource)
resource
- the output filepublic void setSerializer(EventWriterSerializer serializer)
serializer
- the Object to XML serializerpublic String getEncoding()
public void setEncoding(String encoding)
encoding
- the encoding to be usedpublic String getVersion()
public void setVersion(String version)
version
- the XML version to be usedpublic String getRootTagName()
public void setRootTagName(String rootTagName)
rootTagName
- the tag name to be used for the root elementpublic Map getRootElementAttributes()
public void setRootElementAttributes(Map rootElementAttributes)
rootElementAttributes
- attributes of the root elementpublic void setOverwriteOutput(boolean overwriteOutput)
overwriteOutput
- public void setHeaderItems(Object[] headers)
write(Object)
.
headers
- public void setSaveState(boolean saveState)
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
InitializingBean.afterPropertiesSet()
public void open(ExecutionContext executionContext)
open
in interface ItemStream
ItemStream.open(ExecutionContext)
protected void endDocument(javax.xml.stream.XMLEventWriter writer) throws javax.xml.stream.XMLStreamException
writer
- XML event writer
javax.xml.stream.XMLStreamException
public void close(ExecutionContext executionContext)
close
in interface ItemStream
executionContext
- the current execution context in case it is neededItemStream.close(ExecutionContext)
public void write(Object item)
write
in interface ItemWriter
item
- the value objectflush()
public void update(ExecutionContext executionContext)
update
in interface ItemStream
executionContext
- to be updatedItemStream.update(ExecutionContext)
public void flush() throws FlushFailedException
flush
in interface ItemWriter
FlushFailedException
- in case of an error. If this exception is
thrown the writer may be in an inconsistent state and manual intervention
might be required to reconcile the data with persistent output.public void clear() throws ClearFailedException
clear
in interface ItemWriter
ClearFailedException
- in case of an error. If this exception is
thrown the writer may be in an inconsistent state and manual intervention
might be required to reconcile the data with persistent output.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |