Spring Framework HttpOutputMessage - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework HttpOutputMessage class.

This code example shows how to use the following methods:getHeaders, getBody
		return readFromSource(clazz, inputMessage.getHeaders(), new StreamSource(inputMessage.getBody()));
	} 
 
	@Override 
	protected final void writeInternal(T t, HttpOutputMessage outputMessage) throws IOException {
		writeToResult(t, outputMessage.getHeaders(), new StreamResult(outputMessage.getBody()));
	} 
 
	/** 
	 * Transforms the given {@code Source} to the {@code Result}. 
	 * @param source the source to transform from 
	 * @param result the result to transform to 
	 * @throws TransformerException in case of transformation errors 
	 */ 
	protected void transform(Source source, Result result) throws TransformerException {
		this.transformerFactory.newTransformer().transform(source, result);
	} 
 
 
	/** 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getHeaders, getBody
This code example shows how to use the following methods:getHeaders, getBody
 
	@Override 
	protected void writeInternal(Message message, HttpOutputMessage outputMessage) 
			throws IOException, HttpMessageNotWritableException { 
 
		MediaType contentType = outputMessage.getHeaders().getContentType(); 
		Charset charset = getCharset(contentType); 
 
		if (MediaType.TEXT_HTML.isCompatibleWith(contentType)) { 
			HtmlFormat.print(message, new OutputStreamWriter(outputMessage.getBody(), charset)); 
		} 
		else if (MediaType.APPLICATION_JSON.isCompatibleWith(contentType)) { 
			JsonFormat.print(message, new OutputStreamWriter(outputMessage.getBody(), charset)); 
		} 
		else if (MediaType.TEXT_PLAIN.isCompatibleWith(contentType)) { 
			TextFormat.print(message, new OutputStreamWriter(outputMessage.getBody(), charset)); 
		} 
		else if (MediaType.APPLICATION_XML.isCompatibleWith(contentType)) { 
			XmlFormat.print(message, new OutputStreamWriter(outputMessage.getBody(), charset)); 
		} 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBody
		return (long) bytes.length;
	} 
 
	@Override 
	protected void writeInternal(byte[] bytes, HttpOutputMessage outputMessage) throws IOException {
		StreamUtils.copy(bytes, outputMessage.getBody());
	} 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getHeaders, getBody
 
	@Override 
	protected void writeInternal(Object o, HttpOutputMessage outputMessage)
			throws IOException, HttpMessageNotWritableException {
 
		Charset charset = getCharset(outputMessage.getHeaders());
		OutputStreamWriter writer = new OutputStreamWriter(outputMessage.getBody(), charset);
		try { 
			if (this.jsonPrefix != null) {
				writer.append(this.jsonPrefix);
			} 
			this.gson.toJson(o, writer);
			writer.close();
		} 
		catch (JsonIOException ex) {
			throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
		} 
	} 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBody
 
	@Override 
	protected void writeInternal(T t, HttpOutputMessage outputMessage)
			throws IOException, HttpMessageNotWritableException {
		try { 
			Result result = new StreamResult(outputMessage.getBody());
			transform(t, result);
		} 
		catch (TransformerException ex) {
			throw new HttpMessageNotWritableException("Could not transform [" + t + "] to output message", ex);
		} 
	} 
 
	private void transform(Source source, Result result) throws TransformerException {
		this.transformerFactory.newTransformer().transform(source, result);
	} 
 
 
	private static class CountingOutputStream extends OutputStream {
 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Spring Framework HttpOutputMessage Methods: