java.lang.Object
org.refcodes.web.HttpResponseImpl
org.refcodes.web.HttpServerResponseImpl
- All Implemented Interfaces:
org.refcodes.mixin.Dumpable,HeaderFieldsAccessor<ResponseHeaderFields>,HttpBodyAccessor.HttpBodyProvider<BadResponseException>,HttpResponse,HttpServerResponse,HttpStatusCodeAccessor,HttpStatusCodeAccessor.HttpStatusCodeBuilder<HttpServerResponse>,HttpStatusCodeAccessor.HttpStatusCodeMutator,HttpStatusCodeAccessor.HttpStatusCodeProperty
public class HttpServerResponseImpl extends HttpResponseImpl implements HttpServerResponse
Implementation of the
HttpResponse interface.-
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_mediaTypeFactoryLookupFields inherited from class org.refcodes.web.HttpResponseImpl
_httpStatusCode -
Constructor Summary
Constructors Constructor Description HttpServerResponseImpl(HttpStatusCode aHttpStatusCode, MediaTypeFactoryLookup aMediaTypeFactoryLookup)Instantiates a new http server response impl.HttpServerResponseImpl(MediaTypeFactoryLookup aMediaTypeFactoryLookup)Instantiates a new http server response impl.HttpServerResponseImpl(ResponseHeaderFields aResponseHeaderFields, MediaTypeFactoryLookup aMediaTypeFactoryLookup)Instantiates a new http server response impl. -
Method Summary
Modifier and Type Method Description <RES> RESgetResponse()Gets the response.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()Methods inherited from class org.refcodes.web.HttpResponseImpl
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, toDump, toPrintableMethods inherited from interface org.refcodes.web.HeaderFieldsAccessor
getHeaderFieldsMethods inherited from interface org.refcodes.web.HttpServerResponse
withHttpStatusCode, withResponseMethods inherited from interface org.refcodes.web.HttpStatusCodeAccessor
getHttpStatusCodeMethods inherited from interface org.refcodes.web.HttpStatusCodeAccessor.HttpStatusCodeProperty
letHttpStatusCode
-
Field Details
-
_mediaTypeFactoryLookup
-
-
Constructor Details
-
HttpServerResponseImpl
Instantiates a new http server response impl.- Parameters:
aMediaTypeFactoryLookup- the media type factory lookup
-
HttpServerResponseImpl
public HttpServerResponseImpl(HttpStatusCode aHttpStatusCode, MediaTypeFactoryLookup aMediaTypeFactoryLookup)Instantiates a new http server response impl.- Parameters:
aHttpStatusCode- the http status codeaMediaTypeFactoryLookup- the media type factory lookup
-
HttpServerResponseImpl
public HttpServerResponseImpl(ResponseHeaderFields aResponseHeaderFields, MediaTypeFactoryLookup aMediaTypeFactoryLookup)Instantiates a new http server response impl.- Parameters:
aResponseHeaderFields- the response Header-FieldsaMediaTypeFactoryLookup- the media type factory lookup
-
-
Method Details
-
getResponse
public <RES> RES getResponse()Gets the response.- Specified by:
getResponsein interfaceHttpServerResponse- Type Parameters:
RES- the generic type- Returns:
- the response
-
setResponse
public <RES> void setResponse(RES aResponse)Sets the response for the response property. ThesetResponse(Object)supports theHttpBodyMapto marshal anHttpBodyMapinto an HTTP Request-Body.- Specified by:
setResponsein interfaceHttpServerResponse- 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
-