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 a
HttpServerResponse as 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
FieldsFields inherited from class org.refcodes.web.AbstractHttpResponse
_httpStatusCode -
Constructor Summary
ConstructorsConstructorDescriptionHttpServerResponse(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
Modifier and TypeMethodDescription<RES> RESRetrieves 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.Converts an object representing the HTTP body to aStringinstance.toString()withHttpStatusCode(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, getHttpStatusCodeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.refcodes.mixin.Dumpable
toDump, toDumpMethods inherited from interface org.refcodes.web.HeaderFieldsAccessor
getHeaderFieldsMethods inherited from interface org.refcodes.web.HttpStatusCodeAccessor
getHttpStatusCodeMethods inherited from interface org.refcodes.web.HttpStatusCodeAccessor.HttpStatusCodeProperty
letHttpStatusCode
-
Field Details
-
_mediaTypeFactoryLookup
-
-
Constructor Details
-
HttpServerResponse
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 Details
-
withHttpStatusCode
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
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
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
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
-
toString
-