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:
-
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. -
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()returnstrueandgetResponseData()throws an exception. Information about the error can be accessed viagetErrorStatusCode()andgetErrorDescription(). -
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()returnstrue,getResponseData()throws an exception, the exception that caused the response to be defective can be accessed viagetException().
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 TypeMethodDescriptionIn case thatisError()istrue, this method returns a short description of the error if available, ornullotherwise.Returns the HTTP status code if the corresponding request resulted in an error, ornullotherwise.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 returnsnull.default DurationReturns the total duration between request start and request end.Returns the time at which the corresponding data retrieval request (see) was started.invalid reference
#getRequest()Returns the data retrieved in this response, or throws an exception (UnsupportedOperationDueToRetrievalError) if either the response to the corresponding request was an error message (seeisError()) or the response is defective (seeisDefective()).Returns the time at which the retrieval of this response was completed.default booleanIndicates 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 booleanisError()Indicates whether an error message was retrieved.
-
Method Details
-
getResponseData
Returns the data retrieved in this response, or throws an exception (UnsupportedOperationDueToRetrievalError) if either the response to the corresponding request was an error message (seeisError()) or the response is defective (seeisDefective()). -
isError
default boolean isError()Indicates whether an error message was retrieved. If this method returnstrue, thengetErrorStatusCode()andgetErrorDescription()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 viagetException(). -
getRequestStartTime
Date getRequestStartTime()Returns the time at which the corresponding data retrieval request (see) was started.invalid reference
#getRequest() -
getRetrievalEndTime
Date getRetrievalEndTime()Returns the time at which the retrieval of this response was completed. -
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, ornullotherwise. -
getErrorDescription
-
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 returnsnull. 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.
-