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()
GenericResponseGenericResponse.getStatus() is in the range [200..300), false otherwise.isSuccessful in interface GenericResponse<T>public T body()
GenericResponsenull if no entity body is present.body in interface GenericResponse<T>public ErrorBody errorBody()
GenericResponsenull 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()
GenericResponsegetStatus in interface GenericResponse<T>getStatus in class javax.ws.rs.core.Responsepublic javax.ws.rs.core.Response.StatusType getStatusInfo()
GenericResponsegetStatusInfo in interface GenericResponse<T>getStatusInfo in class javax.ws.rs.core.Responsepublic Object getEntity()
getEntity in class javax.ws.rs.core.Responsepublic <U> U readEntity(Class<U> entityType)
readEntity in class javax.ws.rs.core.Responsepublic <U> U readEntity(javax.ws.rs.core.GenericType<U> entityType)
readEntity in class javax.ws.rs.core.Responsepublic <U> U readEntity(Class<U> entityType, Annotation[] annotations)
readEntity in class javax.ws.rs.core.Responsepublic <U> U readEntity(javax.ws.rs.core.GenericType<U> entityType,
Annotation[] annotations)
readEntity in class javax.ws.rs.core.Responsepublic boolean hasEntity()
hasEntity in class javax.ws.rs.core.Responsepublic boolean bufferEntity()
bufferEntity in class javax.ws.rs.core.Responsepublic void close()
GenericResponseclose in interface GenericResponse<T>close in interface Closeableclose in interface AutoCloseableclose in class javax.ws.rs.core.ResponseResponse.close()public javax.ws.rs.core.MediaType getMediaType()
GenericResponsenull of there is no response entity.getMediaType in interface GenericResponse<T>getMediaType in class javax.ws.rs.core.Responsepublic Locale getLanguage()
GenericResponsenull if not specified.getLanguage in interface GenericResponse<T>getLanguage in class javax.ws.rs.core.Responsepublic int getLength()
GenericResponseContent-Length of the response if present, -1 otherwise.getLength in interface GenericResponse<T>getLength in class javax.ws.rs.core.Responsepublic Set<String> getAllowedMethods()
GenericResponsegetAllowedMethods in interface GenericResponse<T>getAllowedMethods in class javax.ws.rs.core.Responsepublic Map<String,javax.ws.rs.core.NewCookie> getCookies()
GenericResponsegetCookies in interface GenericResponse<T>getCookies in class javax.ws.rs.core.Responsepublic javax.ws.rs.core.EntityTag getEntityTag()
GenericResponsegetEntityTag in interface GenericResponse<T>getEntityTag in class javax.ws.rs.core.Responsepublic Date getDate()
GenericResponsenull if not present.getDate in interface GenericResponse<T>getDate in class javax.ws.rs.core.Responsepublic Date getLastModified()
GenericResponsenull if not present.getLastModified in interface GenericResponse<T>getLastModified in class javax.ws.rs.core.Responsepublic URI getLocation()
GenericResponsenull if not present.getLocation in interface GenericResponse<T>getLocation in class javax.ws.rs.core.Responsepublic Set<javax.ws.rs.core.Link> getLinks()
GenericResponsegetLinks in interface GenericResponse<T>getLinks in class javax.ws.rs.core.ResponseResponse.getLinks()public boolean hasLink(String relation)
GenericResponsehasLink in interface GenericResponse<T>hasLink in class javax.ws.rs.core.Responsepublic javax.ws.rs.core.Link getLink(String relation)
GenericResponsenull if not present.getLink in interface GenericResponse<T>getLink in class javax.ws.rs.core.ResponseResponse.getLink(String)public javax.ws.rs.core.Link.Builder getLinkBuilder(String relation)
GenericResponsenull if not present.getLinkBuilder in interface GenericResponse<T>getLinkBuilder in class javax.ws.rs.core.ResponseResponse.getLinkBuilder(String)public javax.ws.rs.core.MultivaluedMap<String,Object> getMetadata()
getMetadata in class javax.ws.rs.core.Responsepublic javax.ws.rs.core.MultivaluedMap<String,Object> getHeaders()
GenericResponsegetHeaders in interface GenericResponse<T>getHeaders in class javax.ws.rs.core.ResponseResponse.getHeaders(),
GenericResponse.getStringHeaders(),
GenericResponse.getHeaderString(java.lang.String)public javax.ws.rs.core.MultivaluedMap<String,String> getStringHeaders()
GenericResponsegetStringHeaders in interface GenericResponse<T>getStringHeaders in class javax.ws.rs.core.ResponseResponse.getStringHeaders(),
GenericResponse.getHeaders(),
GenericResponse.getHeaderString(java.lang.String)public String getHeaderString(String name)
GenericResponseIf 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.ResponseResponse.getHeaderString(String),
GenericResponse.getHeaders(),
GenericResponse.getHeaderString(java.lang.String)Copyright © 2020 Cerner Innovation, Inc.. All rights reserved.