public class DelegatingGenericResponse<T> extends javax.ws.rs.core.Response implements GenericResponse<T>
GenericResponse
implementation that delegates to an underlying JAX-RS Response
.Modifier | Constructor and Description |
---|---|
protected |
DelegatingGenericResponse(T body,
ErrorBody errorBody,
javax.ws.rs.core.Response rawResponse)
This constructor exists so that
DelegatingGenericResponse class can be extended. |
Modifier and Type | Method and Description |
---|---|
T |
body()
Get the response entity body,
null if no entity body is present. |
boolean |
bufferEntity() |
void |
close()
Closes the underlying response input stream.
|
static <T> DelegatingGenericResponse<T> |
create(T body,
javax.ws.rs.core.Response rawResponse)
Creates a new
DelegatingGenericResponse . |
ErrorBody |
errorBody()
Get the error body,
null if the response is not an error or no entity body is present. |
Set<String> |
getAllowedMethods()
Gets the allowed HTTP methods.
|
Map<String,javax.ws.rs.core.NewCookie> |
getCookies()
Gets any new cookies on the response.
|
Date |
getDate()
Gets the resposne date,
null if not present. |
Object |
getEntity() |
Class<?> |
getEntityClass()
Null will be returned if there is no body present.
|
javax.ws.rs.core.EntityTag |
getEntityTag()
Gets the entity tag.
|
Type |
getGenericType()
Null will be returned if there is no body present.
|
javax.ws.rs.core.MultivaluedMap<String,Object> |
getHeaders()
Gets a view of the response headers.
|
String |
getHeaderString(String name)
Gets a response header as a string value.
|
Locale |
getLanguage()
Gets the language of the response entity,
null if not specified. |
Date |
getLastModified()
Gets the last modified date,
null if not present. |
int |
getLength()
Gets the
Content-Length of the response if present, -1 otherwise. |
javax.ws.rs.core.Link |
getLink(String relation)
Gets the link for the relation,
null if not present. |
javax.ws.rs.core.Link.Builder |
getLinkBuilder(String relation)
Returns a link builder for the relation,
null if not present. |
Set<javax.ws.rs.core.Link> |
getLinks()
Gets the links from the response headers.
|
URI |
getLocation()
Gets the location,
null if not present. |
javax.ws.rs.core.MediaType |
getMediaType()
Gets the response entity media type, or
null of there is no response entity. |
javax.ws.rs.core.MultivaluedMap<String,Object> |
getMetadata() |
int |
getStatus()
Get the status of the response response.
|
javax.ws.rs.core.Response.StatusType |
getStatusInfo()
Get the status of the response response.
|
javax.ws.rs.core.MultivaluedMap<String,String> |
getStringHeaders()
Gets a view of the response headers.
|
boolean |
hasEntity() |
boolean |
hasLink(String relation)
Returns true if a link exists for the specified relation, false otherwise.
|
boolean |
isSuccessful()
Returns true if
GenericResponse.getStatus() is in the range [200..300), false otherwise. |
<U> U |
readEntity(Class<U> entityType) |
<U> U |
readEntity(Class<U> entityType,
Annotation[] annotations) |
<U> U |
readEntity(javax.ws.rs.core.GenericType<U> entityType) |
<U> U |
readEntity(javax.ws.rs.core.GenericType<U> entityType,
Annotation[] annotations) |
String |
toString() |
protected DelegatingGenericResponse(T body, ErrorBody errorBody, javax.ws.rs.core.Response rawResponse)
DelegatingGenericResponse
class can be extended.
DelegatingGenericResponse
should not be instantiated directly.
public static <T> DelegatingGenericResponse<T> create(T body, javax.ws.rs.core.Response rawResponse)
DelegatingGenericResponse
.
If the rawResponse status code is in the range [200..300) the ErrorBody
will be
null. If the rawResponse status code is outside of the range [200..300) then a new
ErrorBody
will be created from the rawResponse and associated to this generic
response.
body
- the entity body of the response, may be null
if no body is presentrawResponse
- the raw JAX-RS response to delegate topublic boolean isSuccessful()
GenericResponse
GenericResponse.getStatus()
is in the range [200..300), false otherwise.isSuccessful
in interface GenericResponse<T>
public T body()
GenericResponse
null
if no entity body is present.body
in interface GenericResponse<T>
public ErrorBody errorBody()
GenericResponse
null
if the response is not an error or no entity body is present.errorBody
in interface GenericResponse<T>
public Class<?> getEntityClass()
public Type getGenericType()
public int getStatus()
GenericResponse
getStatus
in interface GenericResponse<T>
getStatus
in class javax.ws.rs.core.Response
public javax.ws.rs.core.Response.StatusType getStatusInfo()
GenericResponse
getStatusInfo
in interface GenericResponse<T>
getStatusInfo
in class javax.ws.rs.core.Response
public Object getEntity()
getEntity
in class javax.ws.rs.core.Response
public <U> U readEntity(Class<U> entityType)
readEntity
in class javax.ws.rs.core.Response
public <U> U readEntity(javax.ws.rs.core.GenericType<U> entityType)
readEntity
in class javax.ws.rs.core.Response
public <U> U readEntity(Class<U> entityType, Annotation[] annotations)
readEntity
in class javax.ws.rs.core.Response
public <U> U readEntity(javax.ws.rs.core.GenericType<U> entityType, Annotation[] annotations)
readEntity
in class javax.ws.rs.core.Response
public boolean hasEntity()
hasEntity
in class javax.ws.rs.core.Response
public boolean bufferEntity()
bufferEntity
in class javax.ws.rs.core.Response
public void close()
GenericResponse
close
in interface GenericResponse<T>
close
in interface Closeable
close
in interface AutoCloseable
close
in class javax.ws.rs.core.Response
Response.close()
public javax.ws.rs.core.MediaType getMediaType()
GenericResponse
null
of there is no response entity.getMediaType
in interface GenericResponse<T>
getMediaType
in class javax.ws.rs.core.Response
public Locale getLanguage()
GenericResponse
null
if not specified.getLanguage
in interface GenericResponse<T>
getLanguage
in class javax.ws.rs.core.Response
public int getLength()
GenericResponse
Content-Length
of the response if present, -1
otherwise.getLength
in interface GenericResponse<T>
getLength
in class javax.ws.rs.core.Response
public Set<String> getAllowedMethods()
GenericResponse
getAllowedMethods
in interface GenericResponse<T>
getAllowedMethods
in class javax.ws.rs.core.Response
public Map<String,javax.ws.rs.core.NewCookie> getCookies()
GenericResponse
getCookies
in interface GenericResponse<T>
getCookies
in class javax.ws.rs.core.Response
public javax.ws.rs.core.EntityTag getEntityTag()
GenericResponse
getEntityTag
in interface GenericResponse<T>
getEntityTag
in class javax.ws.rs.core.Response
public Date getDate()
GenericResponse
null
if not present.getDate
in interface GenericResponse<T>
getDate
in class javax.ws.rs.core.Response
public Date getLastModified()
GenericResponse
null
if not present.getLastModified
in interface GenericResponse<T>
getLastModified
in class javax.ws.rs.core.Response
public URI getLocation()
GenericResponse
null
if not present.getLocation
in interface GenericResponse<T>
getLocation
in class javax.ws.rs.core.Response
public Set<javax.ws.rs.core.Link> getLinks()
GenericResponse
getLinks
in interface GenericResponse<T>
getLinks
in class javax.ws.rs.core.Response
Response.getLinks()
public boolean hasLink(String relation)
GenericResponse
hasLink
in interface GenericResponse<T>
hasLink
in class javax.ws.rs.core.Response
public javax.ws.rs.core.Link getLink(String relation)
GenericResponse
null
if not present.getLink
in interface GenericResponse<T>
getLink
in class javax.ws.rs.core.Response
Response.getLink(String)
public javax.ws.rs.core.Link.Builder getLinkBuilder(String relation)
GenericResponse
null
if not present.getLinkBuilder
in interface GenericResponse<T>
getLinkBuilder
in class javax.ws.rs.core.Response
Response.getLinkBuilder(String)
public javax.ws.rs.core.MultivaluedMap<String,Object> getMetadata()
getMetadata
in class javax.ws.rs.core.Response
public javax.ws.rs.core.MultivaluedMap<String,Object> getHeaders()
GenericResponse
getHeaders
in interface GenericResponse<T>
getHeaders
in class javax.ws.rs.core.Response
Response.getHeaders()
,
GenericResponse.getStringHeaders()
,
GenericResponse.getHeaderString(java.lang.String)
public javax.ws.rs.core.MultivaluedMap<String,String> getStringHeaders()
GenericResponse
getStringHeaders
in interface GenericResponse<T>
getStringHeaders
in class javax.ws.rs.core.Response
Response.getStringHeaders()
,
GenericResponse.getHeaders()
,
GenericResponse.getHeaderString(java.lang.String)
public String getHeaderString(String name)
GenericResponse
If the header contains multiple values, they will be joined by a ','
character,
null
if the header is not present.
getHeaderString
in interface GenericResponse<T>
getHeaderString
in class javax.ws.rs.core.Response
Response.getHeaderString(String)
,
GenericResponse.getHeaders()
,
GenericResponse.getHeaderString(java.lang.String)
Copyright © 2020 Cerner Innovation, Inc.. All rights reserved.