Java Code Examples for javax.xml.transform.Result#getClass()

The following examples show how to use javax.xml.transform.Result#getClass() . 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
/**
 * 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)
 */
@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());
	}
}
 
Example 2
Source File: AbstractMarshaller.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * 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)
 */
@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());
	}
}
 
Example 3
Source File: AbstractMarshaller.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * 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)
 */
@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());
	}
}