org.eclipse.rdf4j.query.resultio.sparqlxml

## Class SPARQLBooleanXMLWriter

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

- All Implemented Interfaces:
    CharSink, Sink, BooleanQueryResultHandler, QueryResultHandler, BooleanQueryResultWriter, QueryResultWriter

      public class SPARQLBooleanXMLWriter
      extends AbstractQueryResultWriter
      implements BooleanQueryResultWriter

  A `BooleanQueryResultWriter` that writes boolean query results in the SPARQL Query Results XML Format.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `documentOpen`
    `protected boolean` | `headerComplete`
    `protected boolean` | `headerOpen`
    `protected boolean` | `tupleVariablesFound`
    `protected XMLWriter` | `xmlWriter` XMLWriter to write XML to.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SPARQLBooleanXMLWriter(OutputStream out)`
    `SPARQLBooleanXMLWriter(Writer writer)`
    `SPARQLBooleanXMLWriter(XMLWriter xmlWriter)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `endDocument()`
    `void` | `endHeader()` Indicates the end of the header.
    `void` | `endQueryResult()` Indicates the end of a sequence of solutions.
    `BooleanQueryResultFormat` | `getBooleanQueryResultFormat()` Gets the query result format that this writer uses.
    `BooleanQueryResultFormat` | `getQueryResultFormat()` Gets the query result format that this writer uses.
    `Collection<RioSetting<?>>` | `getSupportedSettings()`
    `Writer` | `getWriter()` get the `Writer` used by this `CharSink`.
    `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` | `handleNamespace(String prefix, String uri)` Handles a namespace prefix declaration.
    `protected void` | `handleSolutionImpl(BindingSet bindingSet)` Extending classes must implement this method instead of overriding `AbstractQueryResultWriter.handleSolution(BindingSet)` in order to benefit from automatic handling of RDF* encoding.
    `void` | `handleStylesheet(String url)` Handles a stylesheet URL.
    `void` | `setPrettyPrint(boolean prettyPrint)` Deprecated. Use `AbstractQueryResultWriter.getWriterConfig()` .set(BasicWriterSettings.PRETTY_PRINT, prettyPrint) instead.
    `void` | `startDocument()` Indicates the start of the document.
    `void` | `startHeader()` Indicates the start of the header.
    `void` | `startQueryResult(List<String> bindingNames)` Indicates the start of a sequence of Solutions.
    `void` | `write(boolean value)` Writes the specified boolean value.

    - ### Methods inherited from class org.eclipse.rdf4j.query.resultio.AbstractQueryResultWriter

      `getFileFormat, getWriterConfig, handleSolution, setWriterConfig, 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, getSupportedSettings, getWriterConfig, handleNamespace, handleStylesheet, setWriterConfig, startDocument, startHeader`

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

      `endQueryResult, handleBoolean, handleLinks, handleSolution, startQueryResult`

    - ### Methods inherited from interface org.eclipse.rdf4j.common.io.Sink

      `acceptsFileFormat, getFileFormat`

- - ### Field Detail

    - #### xmlWriter

          protected XMLWriter xmlWriter

      XMLWriter to write XML to.

    - #### documentOpen

          protected boolean documentOpen

    - #### headerOpen

          protected boolean headerOpen

    - #### headerComplete

          protected boolean headerComplete

    - #### tupleVariablesFound

          protected boolean tupleVariablesFound

  - ### Constructor Detail

    - #### SPARQLBooleanXMLWriter

          public SPARQLBooleanXMLWriter(OutputStream out)

    - #### SPARQLBooleanXMLWriter

          public SPARQLBooleanXMLWriter(Writer writer)

    - #### SPARQLBooleanXMLWriter

          public SPARQLBooleanXMLWriter(XMLWriter xmlWriter)

  - ### Method Detail

    - #### getBooleanQueryResultFormat

          public final BooleanQueryResultFormat getBooleanQueryResultFormat()

      Description copied from interface: `BooleanQueryResultWriter`
      Gets the query result format that this writer uses.
      Specified by:
        `getBooleanQueryResultFormat` in interface `BooleanQueryResultWriter`

    - #### getQueryResultFormat

          public final BooleanQueryResultFormat getQueryResultFormat()

      Description copied from interface: `QueryResultWriter`
      Gets the query result format that this writer uses.
      Specified by:
        `getQueryResultFormat` in interface `QueryResultWriter`

    - #### write

          public void write(boolean value)
                     throws IOException

      Description copied from interface: `BooleanQueryResultWriter`
      Writes the specified boolean value.
      Specified by:
        `write` in interface `BooleanQueryResultWriter`
      Throws:
        `IOException`

    - #### getWriter

          public Writer getWriter()

      Description copied from interface: `CharSink`
      get the `Writer` used by this `CharSink`.
      Specified by:
        `getWriter` in interface `CharSink`
      Returns:
        an `Writer`

    - #### setPrettyPrint

          @Deprecated
          public void setPrettyPrint(boolean prettyPrint)

      Deprecated. Use `AbstractQueryResultWriter.getWriterConfig()` .set(BasicWriterSettings.PRETTY_PRINT, prettyPrint) instead.
      Enables/disables addition of indentation characters and newlines in the XML document. By default, pretty-printing is set to `true`. If set to `false`, no indentation and newlines are added to the XML document. This method has to be used before writing starts (that is, before `startDocument()` is called).

    - #### endDocument

          protected void endDocument()
                              throws IOException

      Throws:
        `IOException`

    - #### handleBoolean

          public void handleBoolean(boolean value)
                             throws QueryResultHandlerException

      Description copied from interface: `QueryResultHandler`
      Handles the specified boolean value.
      Specified by:
        `handleBoolean` in interface `QueryResultHandler`
      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 `QueryResultHandler.startQueryResult(List)`, `QueryResultHandler.handleSolution(BindingSet)` or `QueryResultHandler.endQueryResult()` methods were called before this method was called, and the handler cannot process both boolean and tuple results simultaneously.

    - #### startDocument

          public void startDocument()
                             throws QueryResultHandlerException

      Description copied from interface: `QueryResultWriter`
      Indicates the start of the document.
      Specified by:
        `startDocument` in interface `QueryResultWriter`
      Throws:
        `QueryResultHandlerException` - If there was an error starting the writing of the results.

    - #### handleStylesheet

          public void handleStylesheet(String url)
                                throws QueryResultHandlerException

      Description copied from interface: `QueryResultWriter`
      Handles a stylesheet URL. If this is called, it must be called after `QueryResultWriter.startDocument()` and before `QueryResultWriter.startHeader()`.

      NOTE: If the format does not support stylesheets, it must silently ignore calls to this method.

      Specified by:
        `handleStylesheet` in interface `QueryResultWriter`
      Parameters:
        `url` - The URL of the stylesheet to be used to style the results.
      Throws:
        `QueryResultHandlerException` - If there was an error handling the stylesheet. This error is not thrown in cases where stylesheets are not supported.

    - #### startHeader

          public void startHeader()
                           throws QueryResultHandlerException

      Description copied from interface: `QueryResultWriter`
      Indicates the start of the header.
      Specified by:
        `startHeader` in interface `QueryResultWriter`
      Throws:
        `QueryResultHandlerException` - If there was an error writing the start of the header.
      See Also:
        SPARQL Query Results XML Format documentation for head element.

    - #### handleLinks

          public void handleLinks(List<String> linkUrls)
                           throws QueryResultHandlerException

      Description copied from interface: `QueryResultHandler`
      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.

      Specified by:
        `handleLinks` in interface `QueryResultHandler`
      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"

    - #### endHeader

          public void endHeader()
                         throws QueryResultHandlerException

      Description copied from interface: `QueryResultWriter`
      Indicates the end of the header. This must be called after `QueryResultWriter.startHeader()` and before any calls to `QueryResultHandler.handleSolution(org.eclipse.rdf4j.query.BindingSet)`.
      Specified by:
        `endHeader` in interface `QueryResultWriter`
      Throws:
        `QueryResultHandlerException` - If there was an error writing the end of the header.

    - #### 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`
      Overrides:
        `startQueryResult` in class `AbstractQueryResultWriter`
      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.

    - #### endQueryResult

          public void endQueryResult()
                              throws TupleQueryResultHandlerException

      Description copied from interface: `QueryResultHandler`
      Indicates the end of a sequence of solutions.
      Specified by:
        `endQueryResult` in interface `QueryResultHandler`
      Throws:
        `TupleQueryResultHandlerException` - If there was an error during the ending 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.

    - #### handleSolutionImpl

          protected void handleSolutionImpl(BindingSet bindingSet)
                                     throws TupleQueryResultHandlerException

      Description copied from class: `AbstractQueryResultWriter`
      Extending classes must implement this method instead of overriding `AbstractQueryResultWriter.handleSolution(BindingSet)` in order to benefit from automatic handling of RDF* encoding.
      Overrides:
        `handleSolutionImpl` in class `AbstractQueryResultWriter`
      Parameters:
        `bindingSet` - the solution to handle
      Throws:
        `TupleQueryResultHandlerException`

    - #### getSupportedSettings

          public final Collection<RioSetting<?>> getSupportedSettings()

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

    - #### handleNamespace

          public void handleNamespace(String prefix,
                                      String uri)
                               throws QueryResultHandlerException

      Description copied from interface: `QueryResultWriter`
      Handles a namespace prefix declaration. If this is called, it should be called before `QueryResultWriter.startDocument()` to ensure that it has a document wide effect.

      NOTE: If the format does not support namespaces, it must silently ignore calls to this method.

      Specified by:
        `handleNamespace` in interface `QueryResultWriter`
      Parameters:
        `prefix` - The prefix to use for the namespace
        `uri` - The full URI that is to be represented by the prefix.
      Throws:
        `QueryResultHandlerException`

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