Class FHIRResponseImpl
- java.lang.Object
-
- org.linuxforhealth.fhir.client.impl.FHIRResponseImpl
-
- All Implemented Interfaces:
FHIRResponse
public class FHIRResponseImpl extends java.lang.Object implements FHIRResponse
An implementation of the FHIRResponse interface which exposes the results of a FHIR REST API operation.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFHIRResponseImpl()FHIRResponseImpl(javax.ws.rs.core.Response response)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetETag()This method is used to retrieve the value of the ETag response HTTP header.java.time.InstantgetLastModified()This method is used to retrieve the Last-Modified response HTTP header.java.lang.StringgetLocation()This method is used to retrieve the value of the Location response HTTP header as a String.java.net.URIgetLocationURI()This method is used to retrieve the value of the Location response HTTP header as a URI.<T> TgetResource(java.lang.Class<T> type)This method is used to retrieve the resource returned in a FHIR REST API response.javax.ws.rs.core.ResponsegetResponse()Returns the underlying JAX-RS 2.0 Response object associated with this FHIRResponse.intgetStatus()This method is used to retrieve the numeric HTTP status code associated with a FHIR REST API response.booleanisEmpty()Returns whether the response contains a FHIR Resource entity.java.lang.String[]parseLocation(java.lang.String location)This function will parse the specified location value into its constituent parts and return a String array containing the individual parts.
-
-
-
Method Detail
-
getStatus
public int getStatus()
Description copied from interface:FHIRResponseThis method is used to retrieve the numeric HTTP status code associated with a FHIR REST API response.- Specified by:
getStatusin interfaceFHIRResponse- Returns:
- the HTTP status code
-
getLocationURI
public java.net.URI getLocationURI() throws java.lang.ExceptionDescription copied from interface:FHIRResponseThis method is used to retrieve the value of the Location response HTTP header as a URI.- Specified by:
getLocationURIin interfaceFHIRResponse- Returns:
- the Location response header value as a URI
- Throws:
java.lang.Exception
-
getLocation
public java.lang.String getLocation() throws java.lang.ExceptionDescription copied from interface:FHIRResponseThis method is used to retrieve the value of the Location response HTTP header as a String.- Specified by:
getLocationin interfaceFHIRResponse- Returns:
- the Location response header value as a String
- Throws:
java.lang.Exception
-
getLastModified
public java.time.Instant getLastModified() throws java.lang.ExceptionDescription copied from interface:FHIRResponseThis method is used to retrieve the Last-Modified response HTTP header.- Specified by:
getLastModifiedin interfaceFHIRResponse- Returns:
- Throws:
java.lang.Exception
-
getETag
public java.lang.String getETag() throws java.lang.ExceptionDescription copied from interface:FHIRResponseThis method is used to retrieve the value of the ETag response HTTP header.- Specified by:
getETagin interfaceFHIRResponse- Returns:
- the ETag response header value
- Throws:
java.lang.Exception
-
getResource
public <T> T getResource(java.lang.Class<T> type) throws java.lang.ExceptionDescription copied from interface:FHIRResponseThis method is used to retrieve the resource returned in a FHIR REST API response.- Specified by:
getResourcein interfaceFHIRResponse- Parameters:
type- this should be ajava.lang.Classvalue which indicates the type of return value expected- Returns:
- Throws:
java.lang.Exception
-
getResponse
public javax.ws.rs.core.Response getResponse() throws java.lang.ExceptionDescription copied from interface:FHIRResponseReturns the underlying JAX-RS 2.0 Response object associated with this FHIRResponse.- Specified by:
getResponsein interfaceFHIRResponse- Returns:
- the JAX-RS Response
- Throws:
java.lang.Exception
-
parseLocation
public java.lang.String[] parseLocation(java.lang.String location) throws java.lang.ExceptionDescription copied from interface:FHIRResponseThis function will parse the specified location value into its constituent parts and return a String array containing the individual parts. The resulting String array returned by this function will contain the following values:- Index 0 - the resource type
- Index 1 - the resource id
- Index 2 - the version id (optional)
- If you call
parseLocationwith the value "http://localhost:9080/fhir-server/api/v4/Patient/23/_history/2", then you should receive this String array:- [0] - "Patient"
- [1] - "23"
- [2] - "2"
- If you call
parseLocationwith the value "http://localhost:9080/fhir-server/api/v4/Observation/38", then you should receive this String array:- [0] - "Observation"
- [1] - "38"
- Specified by:
parseLocationin interfaceFHIRResponse- Parameters:
location- a resource's location URI as a string; this will typically be the value returned by the getLocation() method.- Returns:
- a String array containing the individual parts of the location string or null if the specified location value could not be parsed or was passed in as null.
- Throws:
java.lang.Exception
-
isEmpty
public boolean isEmpty()
Description copied from interface:FHIRResponseReturns whether the response contains a FHIR Resource entity.- Specified by:
isEmptyin interfaceFHIRResponse- Returns:
- true if the response body is empty, otherwise false
-
-