Class RunHttpQuery

java.lang.Object
org.apache.jena.cmd.CommandLineBase
org.apache.jena.cmd.CmdLineArgs
org.apache.jena.cmd.CmdMain
org.apache.jena.cmd.CmdArgModule
org.apache.jena.cmd.CmdGeneral
se.liu.ida.hefquin.cli.RunHttpQuery

public class RunHttpQuery extends org.apache.jena.cmd.CmdGeneral
A command-line tool that interacts with a HeFQUIN service to execute a SPARQL query over the federation for which the service is set up, and prints the query result returned by the service. The tool sends a SPARQL SELECT query to a given HTTP endpoint using a standard HTTP POST request with SPARQL Protocol encoding. It expects the endpoint to return results in SPARQL JSON Results format, which is then parsed into a Jena ResultSet. The resulting solution mappings are printed to standard output or written to a file in a user-selected results format.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.apache.jena.cmd.ArgDecl
     
    protected static final Pattern
     
    protected final ModPlanPrinting
     
    protected final ModQuery
     
    protected final ModResultsOutExt
     
    protected final arq.cmdline.ModTime
     

    Fields inherited from class org.apache.jena.cmd.CmdGeneral

    cmdName, modGeneral, modVersion

    Fields inherited from class org.apache.jena.cmd.CmdLineArgs

    argMap, args, positionals
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Executes the HTTP SPARQL query command.
    protected void
    exec(String serverURI, org.apache.jena.query.Query query, PrintStream out)
    Executes a SPARQL query against a remote SPARQL endpoint using HTTP.
    protected String
    Returns the command name used to invoke the tool.
    protected org.apache.jena.query.Query
    Returns the SPARQL query to be executed.
    protected String
    Returns the usage summary string of the command, showing the required arguments.
    static void
    main(String[] argv)
     
    protected static String
    prepareQuery(org.apache.jena.query.Query query)
    Prepares a SPARQL query for HTTP transmission by ensuring that any base URI defined in the query prologue is explicitly included in the serialized query.
    protected void
    printPlans(org.apache.jena.atlas.json.JsonObject obj)
    Prints any query planning and execution artifacts contained in the given response object using the printers configured in the plan printing module.
    protected void
    Registers HeFQUIN-specific integrations with the Jena framework.

    Methods inherited from class org.apache.jena.cmd.CmdGeneral

    add, addModule, getUsage, help, isDebug, isQuiet, isVerbose, printHelp, processModulesAndArgs, usage, usage

    Methods inherited from class org.apache.jena.cmd.CmdArgModule

    process

    Methods inherited from class org.apache.jena.cmd.CmdMain

    cmdError, cmdError, mainAndExit, mainMethod, mainRun, mainRun, mainRun

    Methods inherited from class org.apache.jena.cmd.CmdLineArgs

    add, add, add, addArg, addArg, addPositional, clear, contains, contains, containsMultiple, containsMultiple, getArg, getArg, getNumPositional, getPositional, getPositionalArg, getPositionalOrStdin, getValue, getValue, getValues, getValues, handleUnrecognizedArg, hasArg, hasArg, hasArgs, hasPositional, hasValueOfFalse, hasValueOfTrue, indirect, indirect, matchesIndirect, matchesIndirect, removeArg, removeArg, removeArgAll, reset, toString

    Methods inherited from class org.apache.jena.cmd.CommandLineBase

    apply, getArg, getArgList, setArgs

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • modTime

      protected final arq.cmdline.ModTime modTime
    • modPlanPrinting

      protected final ModPlanPrinting modPlanPrinting
    • modQuery

      protected final ModQuery modQuery
    • modResultsExt

      protected final ModResultsOutExt modResultsExt
    • argServerAddress

      protected final org.apache.jena.cmd.ArgDecl argServerAddress
    • BASE_PATTERN

      protected static final Pattern BASE_PATTERN
  • Constructor Details

    • RunHttpQuery

      public RunHttpQuery(String[] argv)
  • Method Details

    • main

      public static void main(String[] argv)
    • getSummary

      protected String getSummary()
      Returns the usage summary string of the command, showing the required arguments.
      Specified by:
      getSummary in class org.apache.jena.cmd.CmdGeneral
      Returns:
      A string that describes the usage of the command.
    • getCommandName

      protected String getCommandName()
      Returns the command name used to invoke the tool.
      Specified by:
      getCommandName in class org.apache.jena.cmd.CmdMain
      Returns:
      The name of the command.
    • exec

      protected void exec()
      Executes the HTTP SPARQL query command. This method parses command-line arguments, prepares the output stream (either standard output or a file if specified) and delegates query execution to the HTTP request handler. It ensures that any file-based output streams are properly closed after execution, even if an error occurs during query processing.
      Specified by:
      exec in class org.apache.jena.cmd.CmdMain
    • exec

      protected void exec(String serverURI, org.apache.jena.query.Query query, PrintStream out)
      Executes a SPARQL query against a remote SPARQL endpoint using HTTP. The query is sent using the SPARQL Protocol over HTTP and the results are expected to be returned in SPARQL JSON Results format. This method handles HTTP request creation, response validation, error handling and conversion of the result set into a printable format. Successful results are written to the provided output stream.
    • registerHeFQUINJenaIntegration

      protected void registerHeFQUINJenaIntegration()
      Registers HeFQUIN-specific integrations with the Jena framework. This method ensures that queries written in the HeFQUIN syntax are correctly parsed into Jena's internal query representation and that query serialization correctly falls back to standard SPARQL 1.2 behaviour when needed.
    • getQuery

      protected org.apache.jena.query.Query getQuery()
      Returns the SPARQL query to be executed.
      Returns:
      the Query object
      Throws:
      org.apache.jena.cmd.TerminationException - if the query file could not be found
    • prepareQuery

      protected static String prepareQuery(org.apache.jena.query.Query query)
      Prepares a SPARQL query for HTTP transmission by ensuring that any base URI defined in the query prologue is explicitly included in the serialized query.

      If the query already contains an explicit BASE <...> declaration, it is left unchanged. Otherwise, if a base URI is present in the query prologue (e.g., provided via the --base argument), it is injected as a leading BASE clause.

    • printPlans

      protected void printPlans(org.apache.jena.atlas.json.JsonObject obj)
      Prints any query planning and execution artifacts contained in the given response object using the printers configured in the plan printing module.
      Parameters:
      obj - JSON response object returned by the HeFQUIN service