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

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

Introduction

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

Prototype

public static boolean isStaxResult(Result result) 

Source Link

Document

Indicate whether the given Result is a JAXP 1.4 StAX Result or custom StAX Result.

Usage

From source file:org.springframework.oxm.jaxb.Jaxb2Marshaller.java

@Override
public void marshal(Object graph, Result result, @Nullable MimeContainer mimeContainer)
        throws XmlMappingException {
    try {/*from ww w . j a v a 2 s .c  om*/
        Marshaller marshaller = createMarshaller();
        if (this.mtomEnabled && mimeContainer != null) {
            marshaller.setAttachmentMarshaller(new Jaxb2AttachmentMarshaller(mimeContainer));
        }
        if (StaxUtils.isStaxResult(result)) {
            marshalStaxResult(marshaller, graph, result);
        } else {
            marshaller.marshal(graph, result);
        }
    } catch (JAXBException ex) {
        throw convertJaxbException(ex);
    }
}

From source file:org.springframework.oxm.support.AbstractMarshaller.java

/**
 * Marshals the object graph with the given root into the provided {@code javax.xml.transform.Result}.
 * <p>This implementation inspects the given result, and calls {@code marshalDomResult},
 * {@code marshalSaxResult}, or {@code marshalStreamResult}.
 * @param graph the root of the object graph to marshal
 * @param result the result to marshal to
 * @throws IOException if an I/O exception occurs
 * @throws XmlMappingException if the given object cannot be marshalled to the result
 * @throws IllegalArgumentException if {@code result} if neither a {@code DOMResult},
 * a {@code SAXResult}, nor a {@code StreamResult}
 * @see #marshalDomResult(Object, javax.xml.transform.dom.DOMResult)
 * @see #marshalSaxResult(Object, javax.xml.transform.sax.SAXResult)
 * @see #marshalStreamResult(Object, javax.xml.transform.stream.StreamResult)
 *///from w  ww  .j a  va2  s . co  m
@Override
public final void marshal(Object graph, Result result) throws IOException, XmlMappingException {
    if (result instanceof DOMResult) {
        marshalDomResult(graph, (DOMResult) result);
    } else if (StaxUtils.isStaxResult(result)) {
        marshalStaxResult(graph, result);
    } else if (result instanceof SAXResult) {
        marshalSaxResult(graph, (SAXResult) result);
    } else if (result instanceof StreamResult) {
        marshalStreamResult(graph, (StreamResult) result);
    } else {
        throw new IllegalArgumentException("Unknown Result type: " + result.getClass());
    }
}