AbstractMarshaller.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:spring4-understanding 作者:
/**
 * Template method for handling {@code StaxResult}s.
 * <p>This implementation delegates to {@code marshalXMLSteamWriter} or
 * {@code marshalXMLEventConsumer}, depending on what is contained in the
 * {@code StaxResult}.
 * @param graph the root of the object graph to marshal
 * @param staxResult a JAXP 1.4 {@link StAXSource}
 * @throws XmlMappingException if the given object cannot be marshalled to the result
 * @throws IllegalArgumentException if the {@code domResult} is empty
 * @see #marshalDomNode(Object, org.w3c.dom.Node)
 */
protected void marshalStaxResult(Object graph, Result staxResult) throws XmlMappingException {
    XMLStreamWriter streamWriter = StaxUtils.getXMLStreamWriter(staxResult);
    if (streamWriter != null) {
        marshalXmlStreamWriter(graph, streamWriter);
    }
    else {
        XMLEventWriter eventWriter = StaxUtils.getXMLEventWriter(staxResult);
        if (eventWriter != null) {
            marshalXmlEventWriter(graph, eventWriter);
        }
        else {
            throw new IllegalArgumentException("StaxResult contains neither XMLStreamWriter nor XMLEventConsumer");
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号