org.springframework.util.xml.StaxUtils#getXMLEventWriter ( )源码实例Demo

下面列出了org.springframework.util.xml.StaxUtils#getXMLEventWriter ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: spring-analysis-note   文件: AbstractMarshaller.java
/**
 * 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");
		}
	}
}
 
/**
 * 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");
		}
	}
}
 
/**
 * 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");
		}
	}
}
 
源代码4 项目: spring-analysis-note   文件: Jaxb2Marshaller.java
private void marshalStaxResult(Marshaller jaxbMarshaller, Object graph, Result staxResult) throws JAXBException {
	XMLStreamWriter streamWriter = StaxUtils.getXMLStreamWriter(staxResult);
	if (streamWriter != null) {
		jaxbMarshaller.marshal(graph, streamWriter);
	}
	else {
		XMLEventWriter eventWriter = StaxUtils.getXMLEventWriter(staxResult);
		if (eventWriter != null) {
			jaxbMarshaller.marshal(graph, eventWriter);
		}
		else {
			throw new IllegalArgumentException("StAX Result contains neither XMLStreamWriter nor XMLEventConsumer");
		}
	}
}
 
源代码5 项目: java-technology-stack   文件: Jaxb2Marshaller.java
private void marshalStaxResult(Marshaller jaxbMarshaller, Object graph, Result staxResult) throws JAXBException {
	XMLStreamWriter streamWriter = StaxUtils.getXMLStreamWriter(staxResult);
	if (streamWriter != null) {
		jaxbMarshaller.marshal(graph, streamWriter);
	}
	else {
		XMLEventWriter eventWriter = StaxUtils.getXMLEventWriter(staxResult);
		if (eventWriter != null) {
			jaxbMarshaller.marshal(graph, eventWriter);
		}
		else {
			throw new IllegalArgumentException("StAX Result contains neither XMLStreamWriter nor XMLEventConsumer");
		}
	}
}
 
源代码6 项目: spring4-understanding   文件: Jaxb2Marshaller.java
private void marshalStaxResult(Marshaller jaxbMarshaller, Object graph, Result staxResult) throws JAXBException {
	XMLStreamWriter streamWriter = StaxUtils.getXMLStreamWriter(staxResult);
	if (streamWriter != null) {
		jaxbMarshaller.marshal(graph, streamWriter);
	}
	else {
		XMLEventWriter eventWriter = StaxUtils.getXMLEventWriter(staxResult);
		if (eventWriter != null) {
			jaxbMarshaller.marshal(graph, eventWriter);
		}
		else {
			throw new IllegalArgumentException("StAX Result contains neither XMLStreamWriter nor XMLEventConsumer");
		}
	}
}