Interface DataRetrievalResponse<T>

Type Parameters:
T - - the type of data obtained via the corresponding retrieval request
All Known Subinterfaces:
CardinalityResponse, JSONResponse, RecordsResponse, SolMapsResponse, StringResponse, TPFResponse, TriplesResponse
All Known Implementing Classes:
CachedCardinalityResponse, CardinalityResponseImpl, DataRetrievalResponseBase, JSONResponseImpl, RecordsResponseImpl, SolMapsResponseImpl, StringResponseImpl, TPFResponseImpl

public interface DataRetrievalResponse<T>
Represents the response obtained for a DataRetrievalRequest.

We distinguish three cases for such responses:

  1. The response contains the requested data; hence, the corresponding request for which this response was obtained did not result in an error message and there was no exception related to the request. In this case, getResponseData() can be used to get the data.
  2. The response is an error. This would be the case if the corresponding request resulted in the retrieval of an error message (typically, an HTTP error). In this case, isError() returns true and getResponseData() throws an exception. Information about the error can be accessed via getErrorStatusCode() and getErrorDescription().
  3. The response is defective. This may be because of one of the following two reasons: i) The corresponding request could not be issued successfully but, instead, failed with an exception. ii) The request was issued successfully and resulted in retrieval of data (not an error message) but reading this data failed with an exception. In this case, isDefective() returns true, getResponseData() throws an exception, the exception that caused the response to be defective can be accessed via getException().
Hence, code that consumes such a response should check isError() and isDefective() before calling getResponseData() (or call getResponseData() directly and be ready to deal with the error and the defective case when handling the exception thrown by getResponseData()).
  • Method Summary

    Modifier and Type
    Method
    Description
    In case that isError() is true, this method returns a short description of the error if available, or null otherwise.
    Returns the HTTP status code if the corresponding request resulted in an error, or null otherwise.
    In case that issuing the request that was supposed to result in this response failed with an exception or reading the data obtained via the request failed with an exception, this method returns that exception; otherwise it returns null.
    default Duration
    Returns the total duration between request start and request end.
    Returns the time at which the corresponding data retrieval request (see
    invalid reference
    #getRequest()
    ) was started.
    Returns the data retrieved in this response, or throws an exception (UnsupportedOperationDueToRetrievalError) if either the response to the corresponding request was an error message (see isError()) or the response is defective (see isDefective()).
    Returns the time at which the retrieval of this response was completed.
    default boolean
    Indicates whether this response is defective because either issuing the request that was supposed to result in this response failed with an exception or reading the data obtained via the request failed with an exception.
    default boolean
    Indicates whether an error message was retrieved.
  • Method Details

    • getResponseData

      T getResponseData() throws UnsupportedOperationDueToRetrievalError
      Returns the data retrieved in this response, or throws an exception (UnsupportedOperationDueToRetrievalError) if either the response to the corresponding request was an error message (see isError()) or the response is defective (see isDefective()).
      Throws:
      UnsupportedOperationDueToRetrievalError
    • isError

      default boolean isError()
      Indicates whether an error message was retrieved. If this method returns true, then getErrorStatusCode() and getErrorDescription() can be used to get information about the error.
    • isDefective

      default boolean isDefective()
      Indicates whether this response is defective because either issuing the request that was supposed to result in this response failed with an exception or reading the data obtained via the request failed with an exception. In both cases, the exception that caused the response to be defective can be accessed via getException().
    • getRequestStartTime

      Date getRequestStartTime()
      Returns the time at which the corresponding data retrieval request (see
      invalid reference
      #getRequest()
      ) was started.
    • getRetrievalEndTime

      Date getRetrievalEndTime()
      Returns the time at which the retrieval of this response was completed.
    • getRequestDuration

      default Duration getRequestDuration()
      Returns the total duration between request start and request end.
    • getErrorStatusCode

      Integer getErrorStatusCode()
      Returns the HTTP status code if the corresponding request resulted in an error, or null otherwise.
    • getErrorDescription

      String getErrorDescription()
      In case that isError() is true, this method returns a short description of the error if available, or null otherwise.
    • getException

      Exception getException()
      In case that issuing the request that was supposed to result in this response failed with an exception or reading the data obtained via the request failed with an exception, this method returns that exception; otherwise it returns null. The exception returned by this method (if any) should have a message that contains the right amount of detail to be shown to the user as part of an explanation that the query result produced by HeFQUIN may be incomplete.