Java Code Examples for org.springframework.util.xml.StaxUtils#getXMLEventWriter()

The following examples show how to use org.springframework.util.xml.StaxUtils#getXMLEventWriter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractMarshaller.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * 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");
		}
	}
}
 
Example 2
Source File: AbstractMarshaller.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * 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");
		}
	}
}
 
Example 3
Source File: AbstractMarshaller.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * 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");
		}
	}
}
 
Example 4
Source File: Jaxb2Marshaller.java    From spring-analysis-note with MIT License 5 votes vote down vote up
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");
		}
	}
}
 
Example 5
Source File: Jaxb2Marshaller.java    From java-technology-stack with MIT License 5 votes vote down vote up
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");
		}
	}
}
 
Example 6
Source File: Jaxb2Marshaller.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
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");
		}
	}
}