Java Code Examples for org.springframework.oxm.Unmarshaller#unmarshal()

The following examples show how to use org.springframework.oxm.Unmarshaller#unmarshal() . These examples are extracted from open source projects. 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
private List<ThirdPartyProduct> buildProducts(InputStream inputStream) throws Exception {
	Unmarshaller unmarshaller = createUnmarshaller();
	StreamSource source = new StreamSource(inputStream);
	AmazonProductSearchResponse amazonProductSearchResponse = (AmazonProductSearchResponse) unmarshaller.unmarshal(source);
	return amazonProductSearchResponse.getProducts();
}
 
Example 2
/**
 * Unmarshal the given {@link TextMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromTextMessage(TextMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	Source source = new StreamSource(new StringReader(message.getText()));
	return unmarshaller.unmarshal(source);
}
 
Example 3
/**
 * Unmarshal the given {@link BytesMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromBytesMessage(BytesMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	byte[] bytes = new byte[(int) message.getBodyLength()];
	message.readBytes(bytes);
	ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
	StreamSource source = new StreamSource(bis);
	return unmarshaller.unmarshal(source);
}
 
Example 4
/**
 * Unmarshal the given {@link TextMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromTextMessage(TextMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	Source source = new StreamSource(new StringReader(message.getText()));
	return unmarshaller.unmarshal(source);
}
 
Example 5
/**
 * Unmarshal the given {@link BytesMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromBytesMessage(BytesMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	byte[] bytes = new byte[(int) message.getBodyLength()];
	message.readBytes(bytes);
	ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
	StreamSource source = new StreamSource(bis);
	return unmarshaller.unmarshal(source);
}
 
Example 6
/**
 * Unmarshal the given {@link TextMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromTextMessage(TextMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	Source source = new StreamSource(new StringReader(message.getText()));
	return unmarshaller.unmarshal(source);
}
 
Example 7
/**
 * Unmarshal the given {@link BytesMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromBytesMessage(BytesMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	byte[] bytes = new byte[(int) message.getBodyLength()];
	message.readBytes(bytes);
	ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
	StreamSource source = new StreamSource(bis);
	return unmarshaller.unmarshal(source);
}
 
Example 8
Source Project: cia   File: AbstractUnmarshallXmlTest.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Unmarshall xml.
 *
 * @param unmarshaller
 *            the unmarshaller
 * @param filename
 *            the filename
 * @return the t
 * @throws Exception
 *             the exception
 */
protected final T unmarshallXml(final Unmarshaller unmarshaller, final String filename) throws Exception {
	final BufferedReader inputStream = new BufferedReader(new InputStreamReader(
			java.nio.file.Files.newInputStream(
					Paths.get(FilenameUtils.getFullPath(filename), FilenameUtils.getName(filename))),
			StandardCharsets.UTF_8));

	return (T) unmarshaller.unmarshal(new StreamSource(inputStream));
}