Example usage for org.springframework.util.xml StaxUtils createStaxResult

List of usage examples for org.springframework.util.xml StaxUtils createStaxResult

Introduction

In this page you can find the example usage for org.springframework.util.xml StaxUtils createStaxResult.

Prototype

public static Result createStaxResult(XMLEventWriter eventWriter) 

Source Link

Document

Create a JAXP 1.4 StAXResult for the given XMLEventWriter .

Usage

From source file:org.emonocot.job.io.StaxEventItemWriter.java

/**
 * Write the value objects and flush them to the file.
 *
 * @param items//from ww  w . j a v  a  2  s .c o  m
 *            the value object
 * @throws IOException
 *             if there is a problem writing to the resource
 */
public final void write(final List<? extends T> items) throws IOException {

    currentRecordCount += items.size();

    for (Object object : items) {
        Assert.state(marshaller.supports(object.getClass()),
                "Marshaller must support the class of the marshalled object");
        try {
            marshaller.marshal(object, StaxUtils.createStaxResult(eventWriter));
        } catch (XmlMappingException e) {
            throw new IOException(e.getMessage());
        } catch (XMLStreamException e) {
            throw new IOException(e.getMessage());
        }
    }
    try {
        eventWriter.flush();
    } catch (XMLStreamException e) {
        throw new WriteFailedException("Failed to flush the events", e);
    }

}