Class ResultSetFormatter

java.lang.Object
org.apache.jena.query.ResultSetFormatter

public class ResultSetFormatter extends Object
ResultSetFormatter - Convenience ways to call the various output formatters. in various formats.
See Also:
  • Method Details

    • out

      public static void out(ResultSet qresults)
      Output a result set in a text format. The result set is consumed. Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one.

      This caches the entire results in memory in order to determine the appropriate column widths and therefore may exhaust memory for large results

      Parameters:
      qresults - result set
    • out

      public static void out(OutputStream out, ResultSet qresults)
      Output a result set in a text format. The result set is consumed. Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one.

      This caches the entire results in memory in order to determine the appropriate column widths and therefore may exhaust memory for large results

      Parameters:
      out - OutputStream
      qresults - result set
    • out

      public static void out(ResultSet qresults, Query query)
      Output a result set in a text format. The result set is consumed. Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one.

      This caches the entire results in memory in order to determine the appropriate column widths and therefore may exhaust memory for large results

      Parameters:
      qresults - result set
      query - May be used to abbreviate URIs
    • out

      public static void out(ResultSet qresults, Prologue prologue)
      Output a result set in a text format. The result set is consumed. Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one.

      This caches the entire results in memory in order to determine the appropriate column widths and therefore may exhaust memory for large results

      Parameters:
      qresults - result set
      prologue - May be used to abbreviate URIs
    • out

      public static void out(ResultSet qresults, org.apache.jena.shared.PrefixMapping pmap)
      Output a result set in a text format. The result set is consumed. Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one.

      This caches the entire results in memory in order to determine the appropriate column widths and therefore may exhaust memory for large results

      Parameters:
      qresults - result set
      pmap - Prefix mapping for abbreviating URIs.
    • out

      public static void out(OutputStream out, ResultSet resultSet, org.apache.jena.shared.PrefixMapping pmap)
      Output a result set in a text format. The result set is consumed. Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one.

      This caches the entire results in memory in order to determine the appropriate column widths and therefore may exhaust memory for large results

      Parameters:
      out - OutputStream
      resultSet - Result set
      pmap - Prefix mapping for abbreviating URIs.
    • out

      public static void out(OutputStream out, ResultSet resultSet, Prologue prologue)
      Output a result set in a text format. The result set is consumed. Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one.

      This caches the entire results in memory in order to determine the appropriate column widths and therefore may exhaust memory for large results

      Parameters:
      out - OutputStream
      resultSet - result set
      prologue - Prologue, used to abbreviate IRIs
    • out

      public static void out(boolean answer)
      Output an ASK answer
      Parameters:
      answer - The boolean answer
    • out

      public static void out(OutputStream out, boolean answer)
      Output an ASK answer
      Parameters:
      out - OutputStream
      answer - The boolean answer
    • asText

      public static String asText(ResultSet qresults)
      Return a string that has the result set serialized as a text table

      This caches the entire results in memory in order to determine the appropriate column widths and therefore may exhaust memory for large results

      Parameters:
      qresults - result set
      Returns:
      string
    • asText

      public static String asText(ResultSet qresults, Prologue prologue)
      Return a string that has the result set serialized as a text table

      This caches the entire results in memory in order to determine the appropriate column widths and therefore may exhaust memory for large results

      Parameters:
      qresults - result set
      prologue - Prologue, used to abbreviate IRIs
      Returns:
      string
    • consume

      public static int consume(ResultSet resultSet)
      This operation faithfully walks the results but does nothing with them.
      Returns:
      The count of the number of solutions.
    • toList

      public static List<QuerySolution> toList(ResultSet resultSet)
      Turn the result set into a java.util.List
      Parameters:
      resultSet - The result set
      Returns:
      List of QuerySolutions
    • output

      public static void output(ResultSet resultSet, ResultsFormat rFmt)
      Output a ResultSet in some format.
      Parameters:
      resultSet - Result set
      rFmt - A format to encode the result set in
    • output

      public static void output(OutputStream outStream, ResultSet resultSet, ResultsFormat rFmt)
      Output a ResultSet in some format. To get detailed control over each format, call the appropriate operation directly.
      Parameters:
      outStream - Output
      resultSet - Result set
      rFmt - A format to encode the result set in
    • output

      public static void output(ResultSet resultSet, Lang resultFormat)
    • output

      public static void output(OutputStream outStream, ResultSet resultSet, Lang resultFormat)
    • output

      public static void output(boolean result, Lang resultFormat)
    • output

      public static void output(OutputStream outStream, boolean result, Lang resultFormat)
    • output

      public static void output(OutputStream outStream, Iterator<JsonObject> jsonItems)
      Output an iterator of JSON values.
      Parameters:
      outStream - output stream
      jsonItems - The JSON values
    • outputAsXML

      public static void outputAsXML(ResultSet qresults)
      Output a result set in the XML format
      Parameters:
      qresults - result set
    • outputAsXML

      public static void outputAsXML(OutputStream outStream, ResultSet qresults)
      Output a result set in the XML format
      Parameters:
      outStream - output stream
      qresults - result set
    • outputAsXML

      public static void outputAsXML(ResultSet qresults, String stylesheet)
      Output a result set in the XML format, inserting a style sheet in the XML output
      Parameters:
      qresults - result set
      stylesheet - The URL of the stylesheet
    • outputAsXML

      public static void outputAsXML(OutputStream outStream, ResultSet qresults, String stylesheet)
      Output a result set in the XML format, inserting a style sheet in the XML output
      Parameters:
      outStream - output stream
      qresults - result set
      stylesheet - The URL of the stylesheet
    • outputAsXML

      public static void outputAsXML(boolean booleanResult)
      Output a boolean result in the XML format
      Parameters:
      booleanResult - The boolean result to encode
    • outputAsXML

      public static void outputAsXML(OutputStream outStream, boolean booleanResult)
      Output a boolean result in the XML format
      Parameters:
      outStream - output stream
      booleanResult - The boolean result to encode
    • outputAsXML

      public static void outputAsXML(boolean booleanResult, String stylesheet)
      Output a boolean result in the XML format
      Parameters:
      booleanResult -
      stylesheet - The URL of the stylesheet
    • outputAsXML

      public static void outputAsXML(OutputStream outStream, boolean booleanResult, String stylesheet)
      Output a boolean result in the XML format
      Parameters:
      outStream - output stream
      booleanResult -
      stylesheet - The URL of the stylesheet
    • asXMLString

      public static String asXMLString(ResultSet qresults)
      Return a string that has the result set serialized as XML (not RDF)

      This builds the string in memory which can lead to memory exhaustion for large results. It is generally better to use the outputAsXML(OutputStream, ResultSet) overload instead

      Parameters:
      qresults - result set
      Returns:
      string
    • asXMLString

      public static String asXMLString(ResultSet qresults, String stylesheet)
      Return a string that has the result set serialized as XML (not RDF) with a style sheet directive inserted into the XML.

      This builds the string in memory which can lead to memory exhaustion for large results. It is generally better to use the outputAsXML(OutputStream, ResultSet, String) overload instead

      Parameters:
      qresults - result set
      stylesheet -
      Returns:
      string
    • asXMLString

      public static String asXMLString(boolean booleanResult)
      Return a string that has the result set serialized as XML (not RDF)

      This builds the string in memory which can lead to memory exhaustion for large results. It is generally better to use the outputAsXML(OutputStream, boolean) overload instead

      Parameters:
      booleanResult - The boolean result to encode
      Returns:
      string
    • asXMLString

      public static String asXMLString(boolean booleanResult, String stylesheet)
      Return a string that has the result set serialized as XML (not RDF)

      This builds the string in memory which can lead to memory exhaustion for large results. It is generally better to use the outputAsXML(OutputStream, boolean, String) overload instead

      Parameters:
      booleanResult - The boolean result to encode
      stylesheet -
      Returns:
      string
    • outputAsJSON

      public static void outputAsJSON(ResultSet resultSet)
      Output a result set in the JSON format Format: Serializing SPARQL Query Results in JSON JSON: http://json.org/
      Parameters:
      resultSet - result set
    • outputAsJSON

      public static void outputAsJSON(OutputStream outStream, ResultSet resultSet)
      Output a result set in the JSON format Format: Serializing SPARQL Query Results in JSON JSON: http://json.org/
      Parameters:
      outStream - output stream
      resultSet - result set
    • outputAsJSON

      public static void outputAsJSON(boolean booleanResult)
      Output a result set in the JSON format Format: Serializing SPARQL Query Results in JSON JSON: http://json.org/
      Parameters:
      booleanResult - The boolean result to encode
    • outputAsJSON

      public static void outputAsJSON(OutputStream outStream, boolean booleanResult)
      Output a result set in the JSON format Format: Serializing SPARQL Query Results in JSON JSON: http://json.org/
      Parameters:
      outStream - output stream
      booleanResult - The boolean result to encode
    • outputAsSSE

      public static void outputAsSSE(boolean booleanResult)
      Output a boolean result in the SSE format Format: SSE
      Parameters:
      booleanResult - The boolean result to encode
    • outputAsSSE

      public static void outputAsSSE(OutputStream outStream, boolean booleanResult)
      Output a boolean result in the SSE format Format: SSE
      Parameters:
      outStream - output stream
      booleanResult - The boolean result to encode
    • outputAsSSE

      public static void outputAsSSE(ResultSet resultSet)
      Output a result set in the SSE format Format: SSE
      Parameters:
      resultSet - result set
    • outputAsSSE

      public static void outputAsSSE(ResultSet resultSet, Prologue prologue)
      Output a result set in the SSE format Format: SSE
      Parameters:
      resultSet - result set
    • outputAsSSE

      public static void outputAsSSE(OutputStream outStream, ResultSet resultSet)
      Output a result set in the SSE format Format: SSE
      Parameters:
      outStream - The output stream
      resultSet - The result set
    • outputAsSSE

      public static void outputAsSSE(OutputStream outStream, ResultSet resultSet, Prologue prologue)
      Output a result set in the SSE format Format: SSE
      Parameters:
      outStream - output stream
      resultSet - result set
      prologue -
    • outputAsCSV

      public static void outputAsCSV(boolean booleanResult)
      Output a boolean result in CSV format
      Parameters:
      booleanResult - The boolean result to encode
    • outputAsCSV

      public static void outputAsCSV(OutputStream outStream, boolean booleanResult)
      Output a boolean result in CSV format
      Parameters:
      outStream - output stream
      booleanResult - The boolean result to encode
    • outputAsCSV

      public static void outputAsCSV(ResultSet resultSet)
      Output a result set in CSV format
      Parameters:
      resultSet - result set
    • outputAsCSV

      public static void outputAsCSV(OutputStream outStream, ResultSet resultSet)
      Output a result set in CSV format
      Parameters:
      outStream - The output stream
      resultSet - The result set
    • outputAsTSV

      public static void outputAsTSV(boolean booleanResult)
      Output a boolean result in TSV (tab separated values) format
      Parameters:
      booleanResult - The boolean result to encode
    • outputAsTSV

      public static void outputAsTSV(OutputStream outStream, boolean booleanResult)
      Output a boolean result in TSV format
      Parameters:
      outStream - output stream
      booleanResult - The boolean result to encode
    • outputAsTSV

      public static void outputAsTSV(ResultSet resultSet)
      Output a result set in TSV format
      Parameters:
      resultSet - result set
    • outputAsTSV

      public static void outputAsTSV(OutputStream outStream, ResultSet resultSet)
      Output a result set in TSV format
      Parameters:
      outStream - The output stream
      resultSet - The result set