org.eclipse.rdf4j.query.resultio

## Class AbstractQueryResultWriter

- java.lang.Object
- - org.eclipse.rdf4j.query.resultio.AbstractQueryResultWriter

- All Implemented Interfaces:
    QueryResultHandler, QueryResultWriter
  Direct Known Subclasses:
    BinaryQueryResultWriter, BooleanTextWriter, ConsoleQueryResultWriter, QueryResultWriterBase, SPARQLBooleanJSONWriter, SPARQLBooleanXMLWriter, SPARQLResultsCSVWriter, SPARQLResultsJSONWriter, SPARQLResultsTSVWriter, SPARQLResultsXMLWriter

      public abstract class AbstractQueryResultWriter
      extends Object
      implements QueryResultWriter

  Base class for `QueryResultWriter`s offering common functionality for query result writers.
  Author:
    Peter Ansell

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractQueryResultWriter()` Default constructor.
    `protected` | `AbstractQueryResultWriter(OutputStream out)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Optional<OutputStream>` | `getOutputStream()` Gets the `OutputStream` this writer writes to, if it uses one.
    `Collection<RioSetting<?>>` | `getSupportedSettings()`
    `WriterConfig` | `getWriterConfig()` Retrieves the current writer configuration as a single object.
    `void` | `handleSolution(BindingSet bindingSet)` Handles a solution.
    `protected void` | `handleSolutionImpl(BindingSet bindings)` Extending classes must implement this method instead of overriding `handleSolution(BindingSet)` in order to benefit from automatic handling of RDF* encoding.
    `void` | `setWriterConfig(WriterConfig config)` Sets all supplied writer configuration options.
    `void` | `startQueryResult(List<String> bindingNames)` Indicates the start of a sequence of Solutions.
    `protected boolean` | `xsdStringToPlainLiteral()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.rdf4j.query.resultio.QueryResultWriter

      `endHeader, getQueryResultFormat, handleNamespace, handleStylesheet, startDocument, startHeader`

    - ### Methods inherited from interface org.eclipse.rdf4j.query.QueryResultHandler

      `endQueryResult, handleBoolean, handleLinks`

- - ### Constructor Detail

    - #### AbstractQueryResultWriter

          protected AbstractQueryResultWriter()

      Default constructor.

    - #### AbstractQueryResultWriter

          protected AbstractQueryResultWriter(OutputStream out)

  - ### Method Detail

    - #### getOutputStream

          public Optional<OutputStream> getOutputStream()

      Description copied from interface: `QueryResultWriter`
      Gets the `OutputStream` this writer writes to, if it uses one.
      Specified by:
        `getOutputStream` in interface `QueryResultWriter`
      Returns:
        an optional OutputStream

    - #### setWriterConfig

          public void setWriterConfig(WriterConfig config)

      Description copied from interface: `QueryResultWriter`
      Sets all supplied writer configuration options.
      Specified by:
        `setWriterConfig` in interface `QueryResultWriter`
      Parameters:
        `config` - a writer configuration object.

    - #### getWriterConfig

          public WriterConfig getWriterConfig()

      Description copied from interface: `QueryResultWriter`
      Retrieves the current writer configuration as a single object.
      Specified by:
        `getWriterConfig` in interface `QueryResultWriter`
      Returns:
        a writer configuration object representing the current configuration of the writer.

    - #### getSupportedSettings

          public Collection<RioSetting<?>> getSupportedSettings()

      Specified by:
        `getSupportedSettings` in interface `QueryResultWriter`
      Returns:
        A collection of `RioSetting`s that are supported by this `QueryResultWriter`.

    - #### startQueryResult

          public void startQueryResult(List<String> bindingNames)
                                throws TupleQueryResultHandlerException

      Description copied from interface: `QueryResultHandler`
      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`.
      Specified by:
        `startQueryResult` in interface `QueryResultHandler`
      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 `QueryResultHandler.handleBoolean(boolean)` method was called before this method and the handler cannot process both boolean and tuple results simultaneously.

    - #### handleSolution

          public void handleSolution(BindingSet bindingSet)
                              throws TupleQueryResultHandlerException

      Description copied from interface: `QueryResultHandler`
      Handles a solution.
      Specified by:
        `handleSolution` in interface `QueryResultHandler`
      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 `QueryResultHandler.startQueryResult(List)` method.
      Throws:
        `TupleQueryResultHandlerException` - If there was an error during the handling of the query solution. This exception may be thrown if the `QueryResultHandler.handleBoolean(boolean)` method was called before this method and the handler cannot process both boolean and tuple results simultaneously.

    - #### handleSolutionImpl

          protected void handleSolutionImpl(BindingSet bindings)
                                     throws TupleQueryResultHandlerException

      Extending classes must implement this method instead of overriding `handleSolution(BindingSet)` in order to benefit from automatic handling of RDF* encoding.
      Parameters:
        `bindings` - the solution to handle
      Throws:
        `TupleQueryResultHandlerException`
      Since:
        3.2.0

    - #### xsdStringToPlainLiteral

          protected boolean xsdStringToPlainLiteral()

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