Class AGQuery

All Implemented Interfaces:
Operation, Query
Direct Known Subclasses:
AGBooleanQuery, AGGraphQuery, AGTupleQuery, AGUpdate

public abstract class AGQuery extends AbstractQuery
An abstract query class common to Boolean, Graph and Tuple Queries.
  • Field Details

    • SPARQL_COVERAGE_PLANNER

      public static final String SPARQL_COVERAGE_PLANNER
      The default query planner for SPARQL.
      See Also:
    • SPARQL_IDENTITY_PLANNER

      public static final String SPARQL_IDENTITY_PLANNER
      A query planner for SPARQL that processes queries without doing any reordering of clauses or optimization, useful if the user knows the best order for processing the query.
      See Also:
    • RDFS_PLUS_PLUS

      public static final String RDFS_PLUS_PLUS
      The default entailment regime to use when inferences are included.
      See Also:
    • RESTRICTION

      public static final String RESTRICTION
      An entailment regime that includes hasValue, someValuesFrom and allValuesFrom reasoning in addition to RDFS++ entailment.
      See Also:
  • Constructor Details

  • Method Details

    • getFranzOptionPrefixString

      public static String getFranzOptionPrefixString(String option, String value)
      Returns a String of the form "PREFIX franzOption_OPTION: <franz:VALUE> " suitable for appending to a SPARQL query. VALUE is encoded per the rules for percent-encoding the query part of a URI (namely that the space char ' ' encoded as '%20' instead of '+'.
      Parameters:
      option - the name of a valid AllegroGraph SPARQL Query Option
      value - String value to be encoded as the value of the prefixOption
      Returns:
      String the generated prefix.
      See Also:
    • setIncludeInferred

      public void setIncludeInferred(boolean includeInferred)
      Determine whether evaluation results of this query should include inferred statements (if any inferred statements are present in the repository). The default setting is 'false'.
      Specified by:
      setIncludeInferred in interface Operation
      Overrides:
      setIncludeInferred in class AbstractOperation
      Parameters:
      includeInferred - indicates whether inferred statements should included in the result.
      See Also:
    • getEntailmentRegime

      public String getEntailmentRegime()
      Gets the entailment regime being used when including inferences with this query.
      Returns:
      String the name of the entailment regime
    • setEntailmentRegime

      public void setEntailmentRegime(String entailmentRegime)
      Sets the entailment regime to use when including inferences with this query. Default is 'rdfs++'.
      Parameters:
      entailmentRegime - indicates the entailment regime to use when reasoning
      See Also:
    • getLanguage

      public QueryLanguage getLanguage()
      Gets the query language for this query.
      Returns:
      the query language
    • getQueryString

      public String getQueryString()
      Gets the query string for this query.
      Returns:
      the query string
    • isLoggingEnabled

      public boolean isLoggingEnabled()
      Gets the loggingEnabled setting for this query.
      Returns:
      Boolean true if logging is enabled, else false
    • setLoggingEnabled

      public void setLoggingEnabled(boolean loggingEnabled)
      Sets the loggingEnabled parameter for this query.

      Default is false.

      Parameters:
      loggingEnabled - boolean indicating whether logging is enabled
    • getBaseURI

      public String getBaseURI()
      Gets the baseURI for this query.
      Returns:
      the base URI
    • getPlanner

      public String getPlanner()
      Gets the query planner that processes the query.
      Returns:
      the planner name
    • setPlanner

      public void setPlanner(String planner)
      Sets the query planner to use when processing the query.
      Parameters:
      planner - the planner name
    • getEngine

      @Deprecated public String getEngine()
      Deprecated.
      internal use only
      Returns:
      String the name of the engine used to perform this query
    • setEngine

      @Deprecated public void setEngine(String engine)
      Deprecated.
      internal use only
      This method is not for general use - configure server agraph.cfg QueryEngine instead.
      Parameters:
      engine - the name of the query engine to use for this query
      See Also:
    • setSaveName

      public void setSaveName(String name)
      Sets the name to use when saving this query with the server's saved query service.
      Parameters:
      name - the saved name
    • getName

      public String getName()
      Gets the savedName for the query.
      Returns:
      the saved name
    • isPrepared

      public boolean isPrepared()
      Gets the prepared flag for the query.
      Returns:
      the prepared flag
    • setPrepared

      public void setPrepared(boolean prepared)
      Sets the prepared flag for the query.
      Parameters:
      prepared - the prepared flag
    • download

      public void download(File file) throws QueryEvaluationException
      Evaluates the query and saves the results to a file.

      Output format is determined by the server.

      Parameters:
      file - Output path.
      Throws:
      QueryEvaluationException - if there is an error while evaluating query
    • download

      public void download(String file) throws QueryEvaluationException
      Evaluates the query and saves the results to a file.

      Output format is determined by the server.

      Parameters:
      file - Output path.
      Throws:
      QueryEvaluationException - if there is an error while evaluating query
    • download

      public void download(File file, String mimeType) throws QueryEvaluationException
      Evaluates the query and saves the results to a file.
      Parameters:
      file - Output path.
      mimeType - MIME type that will be requested from the server (i.e. output format).
      Throws:
      QueryEvaluationException - if there is an error while evaluating query
    • download

      public void download(String file, String mimeType) throws QueryEvaluationException
      Evaluates the query and saves the results to a file.
      Parameters:
      file - Output path.
      mimeType - MIME type that will be requested from the server (i.e. output format).
      Throws:
      QueryEvaluationException - if there is an error while evaluating query
    • stream

      public InputStream stream(String mimeType) throws QueryEvaluationException
      Evaluates the query and returns the result as an input stream.

      Note that it is important to close the returned stream, to avoid resource leaks.

      Parameters:
      mimeType - MIME type that will be requested from the server (i.e. output format).
      Returns:
      An input stream containing response data. The caller MUST close this stream to release connection resources.
      Throws:
      QueryEvaluationException - if there is an error while evaluating query
    • stream

      public InputStream stream() throws QueryEvaluationException
      Evaluates the query and returns the result as an input stream.

      The output format will be chosen by the server.

      Returns:
      An input stream containing response data. The caller MUST close this stream to release connection resources.
      Throws:
      QueryEvaluationException - if there is an error while evaluating query
    • analyze

      public String analyze() throws QueryEvaluationException
      Returns the query analysis for the query.

      The query is not evaluated.

      Returns:
      the query analysis as a string
      Throws:
      QueryEvaluationException - if there is an error while evaluating query
    • isCheckVariables

      public boolean isCheckVariables()
      Gets the flag for checkVariables.
      Returns:
      the checkVariables flag
    • setCheckVariables

      public void setCheckVariables(boolean checkVariables)
      A boolean that defaults to false, indicating whether an error should be raised when a SPARQL query selects variables that are not mentioned in the query body.
      Parameters:
      checkVariables - the checkVariables flag
    • getBindingsArray

      public Binding[] getBindingsArray()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getLimit

      public int getLimit()
      Gets the limit on the number of solutions for this query.
      Returns:
      limit
    • setLimit

      public void setLimit(int limit)
      Sets the limit.

      By default, the value is -1, meaning no constraint is imposed.

      Parameters:
      limit - the max number of solutions to collect for this query
    • getOffset

      public int getOffset()
      Gets the offset, the number of solutions to skip for this query.
      Returns:
      offset
    • setOffset

      public void setOffset(int offset)
      Sets the offset.
      Parameters:
      offset - the number of solutions to skip for this query

      By default, the value is -1, meaning no constraint is imposed.

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object