- java.lang.Object
-
- org.refcodes.web.AbstractHttpResponse
-
- org.refcodes.web.HttpServerResponse
-
- All Implemented Interfaces:
org.refcodes.mixin.Dumpable,HeaderFieldsAccessor<ResponseHeaderFields>,HttpBodyAccessor.HttpBodyProvider<BadResponseException>,HttpResponse,HttpStatusCodeAccessor,HttpStatusCodeAccessor.HttpStatusCodeBuilder<HttpServerResponse>,HttpStatusCodeAccessor.HttpStatusCodeMutator,HttpStatusCodeAccessor.HttpStatusCodeProperty
public class HttpServerResponse extends AbstractHttpResponse implements HttpResponse, HttpStatusCodeAccessor.HttpStatusCodeProperty, HttpStatusCodeAccessor.HttpStatusCodeBuilder<HttpServerResponse>, HttpBodyAccessor.HttpBodyProvider<BadResponseException>, org.refcodes.mixin.Dumpable
Defines aHttpServerResponseas produced by the server.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.web.HeaderFieldsAccessor
HeaderFieldsAccessor.HeaderFieldsBuilder<T extends HeaderFields<?,?>,B extends HeaderFieldsAccessor.HeaderFieldsBuilder<T,B>>, HeaderFieldsAccessor.HeaderFieldsMutator<T extends HeaderFields<?,?>>, HeaderFieldsAccessor.HeaderFieldsProperty<T extends HeaderFields<?,?>>
-
Nested classes/interfaces inherited from interface org.refcodes.web.HttpStatusCodeAccessor
HttpStatusCodeAccessor.HttpStatusCodeBuilder<B extends HttpStatusCodeAccessor.HttpStatusCodeBuilder<B>>, HttpStatusCodeAccessor.HttpStatusCodeMutator, HttpStatusCodeAccessor.HttpStatusCodeProperty
-
-
Field Summary
Fields Modifier and Type Field Description protected MediaTypeFactoryLookup_mediaTypeFactoryLookup-
Fields inherited from class org.refcodes.web.AbstractHttpResponse
_httpStatusCode
-
-
Constructor Summary
Constructors Constructor Description HttpServerResponse(HttpStatusCode aHttpStatusCode, MediaTypeFactoryLookup aMediaTypeFactoryLookup)Instantiates a new http server response impl.HttpServerResponse(MediaTypeFactoryLookup aMediaTypeFactoryLookup)Instantiates a new http server response impl.HttpServerResponse(ResponseHeaderFields aResponseHeaderFields, MediaTypeFactoryLookup aMediaTypeFactoryLookup)Instantiates a new http server response impl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <RES> RESgetResponse()Retrieves the response from the response property.voidsetHttpStatusCode(HttpStatusCode aStatusCode)Sets the HTTP Status-Code for the HTTP Status-Code property.<RES> voidsetResponse(RES aResponse)Sets the response for the response property.StringtoHttpBody()Converts an object representing the HTTP body to aStringinstance.StringtoString()HttpServerResponsewithHttpStatusCode(HttpStatusCode aStatusCode)Sets the HTTP Status-Code for the HTTP Status-Code property.<RES> HttpServerResponsewithResponse(RES aResponse)Sets the response for the response property.-
Methods inherited from class org.refcodes.web.AbstractHttpResponse
getHeaderFields, getHttpStatusCode
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.web.HeaderFieldsAccessor
getHeaderFields
-
Methods inherited from interface org.refcodes.web.HttpStatusCodeAccessor
getHttpStatusCode
-
Methods inherited from interface org.refcodes.web.HttpStatusCodeAccessor.HttpStatusCodeProperty
letHttpStatusCode
-
-
-
-
Field Detail
-
_mediaTypeFactoryLookup
protected MediaTypeFactoryLookup _mediaTypeFactoryLookup
-
-
Constructor Detail
-
HttpServerResponse
public HttpServerResponse(MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new http server response impl.- Parameters:
aMediaTypeFactoryLookup- the media type factory lookup
-
HttpServerResponse
public HttpServerResponse(HttpStatusCode aHttpStatusCode, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new http server response impl.- Parameters:
aHttpStatusCode- the http status codeaMediaTypeFactoryLookup- the media type factory lookup
-
HttpServerResponse
public HttpServerResponse(ResponseHeaderFields aResponseHeaderFields, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new http server response impl.- Parameters:
aResponseHeaderFields- the response Header-FieldsaMediaTypeFactoryLookup- the media type factory lookup
-
-
Method Detail
-
withHttpStatusCode
public HttpServerResponse withHttpStatusCode(HttpStatusCode aStatusCode)
Sets the HTTP Status-Code for the HTTP Status-Code property.- Specified by:
withHttpStatusCodein interfaceHttpStatusCodeAccessor.HttpStatusCodeBuilder<HttpServerResponse>- Parameters:
aStatusCode- The HTTP Status-Code to be stored by the HTTP HTTP Status-Code property.- Returns:
- The builder for applying multiple build operations.
-
withResponse
public <RES> HttpServerResponse withResponse(RES aResponse)
Sets the response for the response property.- Type Parameters:
RES- the generic type- Parameters:
aResponse- The response to be stored by the response property.- Returns:
- The builder for applying multiple build operations.
-
getResponse
public <RES> RES getResponse()
Retrieves the response from the response property.- Type Parameters:
RES- the generic type- Returns:
- The response stored by the response property.
-
setResponse
public <RES> void setResponse(RES aResponse)
Sets the response for the response property. ThesetResponse(Object)supports theHttpBodyMapto marshal anHttpBodyMapinto an HTTP Request-Body.- Type Parameters:
RES- the generic type- Parameters:
aResponse- The response to be stored by the response property.
-
setHttpStatusCode
public void setHttpStatusCode(HttpStatusCode aStatusCode)
Sets the HTTP Status-Code for the HTTP Status-Code property.- Specified by:
setHttpStatusCodein interfaceHttpStatusCodeAccessor.HttpStatusCodeMutator- Parameters:
aStatusCode- The HTTP Status-Code to be stored by the HTTP HTTP Status-Code property.
-
toHttpBody
public String toHttpBody() throws BadResponseException
Converts an object representing the HTTP body to aStringinstance. Automatically determines theContentTypefrom any headers when applicable.- Specified by:
toHttpBodyin interfaceHttpBodyAccessor.HttpBodyProvider<BadResponseException>- Returns:
- The converted
Stringinstance represented by the according object. - Throws:
BadResponseException
-
-