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
Fields inherited from class org.refcodes.web.AbstractHttpResponse
_httpStatusCode
-
Constructor Summary
ConstructorDescriptionHttpServerResponse
(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> RES
Retrieves the response from the response property.void
setHttpStatusCode
(HttpStatusCode aStatusCode) Sets the HTTP Status-Code for the HTTP Status-Code property.<RES> void
setResponse
(RES aResponse) Sets the response for the response property.Converts an object representing the HTTP body to aString
instance.toString()
withHttpStatusCode
(HttpStatusCode aStatusCode) Sets the HTTP Status-Code for the HTTP Status-Code property.<RES> HttpServerResponse
withResponse
(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.mixin.Dumpable
toDump, toDump
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 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:
withHttpStatusCode
in 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 theHttpBodyMap
to marshal anHttpBodyMap
into 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:
setHttpStatusCode
in 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 aString
instance. Automatically determines theContentType
from any headers when applicable.- Specified by:
toHttpBody
in interfaceHttpBodyAccessor.HttpBodyProvider<BadResponseException>
- Returns:
- The converted
String
instance represented by the according object. - Throws:
BadResponseException
-
toString
-