public class ResponseBuilder
extends java.lang.Object
| Constructor and Description |
|---|
ResponseBuilder()
Creates a response builder.
|
ResponseBuilder(int statusCode)
Creates a response builder with a response code.
|
ResponseBuilder(int statusCode,
byte[] body)
Creates a response builder with a response code and body as bytes.
|
ResponseBuilder(int statusCode,
ByteSource bodySource)
Creates a response builder with a response code and body as a
ByteSource. |
ResponseBuilder(int statusCode,
java.lang.String body)
Creates a response builder with a response code and body as a string.
|
| Modifier and Type | Method and Description |
|---|---|
ResponseBuilder |
addAttribute(java.lang.String name,
java.lang.Object object)
Adds an attribute.
|
ResponseBuilder |
addAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
Adds a map of attributes.
|
ResponseBuilder |
addHeader(java.lang.String name,
java.lang.String value)
Adds a header.
|
ResponseBuilder |
addHeaders(java.util.Map<?,?> headerMap)
Adds a map of headers.
|
Response |
create()
Creates an immutable response.
|
StreamedResponse |
createStreamed()
Creates an immutable streamed response.
|
ResponseBuilder |
putHeaders(java.util.Collection<Header> headers)
Adds a collection of headers.
|
ResponseBuilder |
setBody(byte[] body)
Sets the response body bytes.
|
ResponseBuilder |
setBody(ByteSource body)
Sets a
ByteSource for the response body. |
ResponseBuilder |
setBody(java.lang.String body)
Sets the response body as a string.
|
ResponseBuilder |
setStatusCode(int statusCode)
Sets the response code.
|
public ResponseBuilder()
public ResponseBuilder(int statusCode)
statusCode - The response code.public ResponseBuilder(int statusCode,
byte[] body)
statusCode - The response code.body - The response body.public ResponseBuilder(int statusCode,
java.lang.String body)
statusCode - The response code.body - The response body.public ResponseBuilder(int statusCode,
ByteSource bodySource)
ByteSource.statusCode - The response code.bodySource - The response body source.public ResponseBuilder setStatusCode(int statusCode)
statusCode - The response code.public ResponseBuilder setBody(byte[] body)
body - The body.public ResponseBuilder setBody(java.lang.String body)
body - The body.public ResponseBuilder setBody(ByteSource body)
ByteSource for the response body.body - The body byte source.public Response create()
public StreamedResponse createStreamed()
public ResponseBuilder addHeader(java.lang.String name, java.lang.String value)
name - The header name.value - The header value.public ResponseBuilder putHeaders(java.util.Collection<Header> headers)
headers - The headers to add.public ResponseBuilder addHeaders(java.util.Map<?,?> headerMap)
headerMap - The map of headers.public ResponseBuilder addAttribute(java.lang.String name, java.lang.Object object)
name - The attribute name.object - The attribute value.public ResponseBuilder addAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
attributes - The map of attributes.