Class HttpServerResponse
java.lang.Object
org.refcodes.web.AbstractHttpResponse
org.refcodes.web.HttpServerResponse
- All Implemented Interfaces:
HeaderFieldsAccessor<ResponseHeaderFields>, HttpBodyAccessor.HttpBodyProvider<BadResponseException>, HttpResponse, HttpStatusCodeAccessor, HttpStatusCodeAccessor.HttpStatusCodeBuilder<HttpServerResponse>, HttpStatusCodeAccessor.HttpStatusCodeMutator, HttpStatusCodeAccessor.HttpStatusCodeProperty
public class HttpServerResponse
extends AbstractHttpResponse
implements HttpStatusCodeAccessor.HttpStatusCodeProperty, HttpStatusCodeAccessor.HttpStatusCodeBuilder<HttpServerResponse>, HttpBodyAccessor.HttpBodyProvider<BadResponseException>
Defines a
HttpServerResponse as produced by the server.-
Nested Class Summary
Nested classes/interfaces inherited from interface HeaderFieldsAccessor
HeaderFieldsAccessor.HeaderFieldsBuilder<T,B>, HeaderFieldsAccessor.HeaderFieldsMutator<T>, HeaderFieldsAccessor.HeaderFieldsProperty<T> Nested classes/interfaces inherited from interface HttpStatusCodeAccessor
HttpStatusCodeAccessor.HttpStatusCodeBuilder<B>, HttpStatusCodeAccessor.HttpStatusCodeMutator, HttpStatusCodeAccessor.HttpStatusCodeProperty -
Field Summary
FieldsFields inherited from class AbstractHttpResponse
_httpStatusCode -
Constructor Summary
ConstructorsConstructorDescriptionHttpServerResponse(HttpStatusCode aHttpStatusCode, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates the classHttpServerResponse.HttpServerResponse(MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http server response impl.HttpServerResponse(ResponseHeaderFields aResponseHeaderFields, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates the classHttpServerResponse. -
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 AbstractHttpResponse
getHeaderFields, getHttpStatusCodeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface HttpStatusCodeAccessor
getHttpStatusCodeMethods inherited from interface 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 the classHttpServerResponse.- Parameters:
aMediaTypeFactoryLookup- TheMediaTypeFactoryLookupregistry to use- See Also:
-
HttpServerResponse
public HttpServerResponse(ResponseHeaderFields aResponseHeaderFields, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates the classHttpServerResponse.- Parameters:
aMediaTypeFactoryLookup- TheMediaTypeFactoryLookupregistry to use- See Also:
-
-
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 theHttpBodyTableto marshal anHttpBodyTableinto 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
-