org.eclipse.rdf4j.query

## Interface QueryResultHandler

- All Known Subinterfaces:
    BooleanQueryResultHandler, BooleanQueryResultWriter, QueryResultWriter, TupleQueryResultHandler, TupleQueryResultWriter
  All Known Implementing Classes:
    AbstractQueryResultWriter, AbstractTupleQueryResultHandler, BackgroundTupleResult, BackgroundTupleResult, BinaryQueryResultWriter, BooleanTextWriter, ConsoleQueryResultWriter, DAWGTestResultSetWriter, QueryResultCollector, QueryResultWriterBase, SPARQLBooleanJSONWriter, SPARQLBooleanXMLWriter, SPARQLResultsCSVWriter, SPARQLResultsJSONWriter, SPARQLResultsTSVWriter, SPARQLResultsXMLWriter, SPARQLStarResultsJSONWriter, SPARQLStarResultsJSONWriter, SPARQLStarResultsTSVWriter, SPARQLStarResultsTSVWriter, SPARQLStarResultsXMLWriter, TupleQueryResultBuilder, TupleQueryResultHandlerBase

      public interface QueryResultHandler

  The super class of all handlers for processing query results.

  This interface contains methods for optionally processing both boolean and tuple results sets simultaneously, but there are no guarantees that an implementation will be able to process these values together. If a method is not supported then an `UnsupportedOperationException` will be thrown to indicate this failure. This failure may be prevented by checking for whether the class implements `BooleanQueryResultHandler` or `TupleQueryResultHandler`, for boolean and tuple results support respectively.

  If both boolean and tuple results are supported but they are not able to to be processed simultaneously, then a checked exception, either `BooleanQueryResultHandlerException` or `TupleQueryResultHandlerException`, will be thrown to indicate this failure when the relevant methods are called.

  Author:
    Peter Ansell

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `endQueryResult()` Indicates the end of a sequence of solutions.
    `void` | `handleBoolean(boolean value)` Handles the specified boolean value.
    `void` | `handleLinks(List<String> linkUrls)` Handles the links elements which are present in SPARQL Results JSON and SPARQL Results XML documents in the header.
    `void` | `handleSolution(BindingSet bindingSet)` Handles a solution.
    `void` | `startQueryResult(List<String> bindingNames)` Indicates the start of a sequence of Solutions.

- - ### Method Detail

    - #### handleBoolean

          void handleBoolean(boolean value)
                      throws QueryResultHandlerException

      Handles the specified boolean value.
      Parameters:
        `value` - The boolean value to handle.
      Throws:
        `QueryResultHandlerException` - If there was an error during the handling of this value. This exception may be thrown if the `startQueryResult(List)`, `handleSolution(BindingSet)` or `endQueryResult()` methods were called before this method was called, and the handler cannot process both boolean and tuple results simultaneously.
        `UnsupportedOperationException` - If this method is not supported

    - #### handleLinks

          void handleLinks(List<String> linkUrls)
                    throws QueryResultHandlerException

      Handles the links elements which are present in SPARQL Results JSON and SPARQL Results XML documents in the header.

      NOTE: If the format does not support links, it must silently ignore a call to this method.

      An accumulating handler should accumulate these links.

      Parameters:
        `linkUrls` - The URLs of the links to handle.
      Throws:
        `QueryResultHandlerException` - If there was an error handling the set of link URLs. This error is not thrown in cases where links are not supported.
      See Also:
        "link"

    - #### startQueryResult

          void startQueryResult(List<String> bindingNames)
                         throws TupleQueryResultHandlerException

      Indicates the start of a sequence of Solutions. The supplied bindingNames are an indication of the values that are in the Solutions. For example, a SeRQL query like `select X, Y from {X} P {Y}` will have binding names `X` and `Y`.
      Parameters:
        `bindingNames` - An ordered set of binding names.
      Throws:
        `TupleQueryResultHandlerException` - If there was an error during the starting of the query result handler. This exception may be thrown if the `handleBoolean(boolean)` method was called before this method and the handler cannot process both boolean and tuple results simultaneously.
        `UnsupportedOperationException` - If this method is not supported
        `IllegalStateException` - If the `handleSolution(BindingSet)` or `endQueryResult()` methods were called before this method and the handler cannot process multiple sets of tuple results simultaneously.

    - #### endQueryResult

          void endQueryResult()
                       throws TupleQueryResultHandlerException

      Indicates the end of a sequence of solutions.
      Throws:
        `TupleQueryResultHandlerException` - If there was an error during the ending of the query result handler. This exception may be thrown if the `handleBoolean(boolean)` method was called before this method and the handler cannot process both boolean and tuple results simultaneously.
        `UnsupportedOperationException` - If this method is not supported
        `IllegalStateException` - If the `endQueryResult()` was previously called for this handler or `startQueryResult(List)` was NOT called before this method.

    - #### handleSolution

          void handleSolution(BindingSet bindingSet)
                       throws TupleQueryResultHandlerException

      Handles a solution.
      Parameters:
        `bindingSet` - A single set of tuple results, with binding names bound to values. Each of the binding names in the solution must have previously been registered with the `startQueryResult(List)` method.
      Throws:
        `TupleQueryResultHandlerException` - If there was an error during the handling of the query solution. This exception may be thrown if the `handleBoolean(boolean)` method was called before this method and the handler cannot process both boolean and tuple results simultaneously.
        `UnsupportedOperationException` - If this method is not supported
        `IllegalStateException` - If the `endQueryResult()` method was called before this method or `startQueryResult(List)` was NOT called before this method.

Copyright © 2015-2022 Eclipse Foundation. All Rights Reserved.