Class SparqlBuilder

java.lang.Object
org.eclipse.rdf4j.sparqlbuilder.core.SparqlBuilder

public class SparqlBuilder extends Object
A class to with static methods to create SPARQL query elements.
  • Method Details

    • var

      public static Variable var(String varName)
      Create a SPARQL variable with a specific alias.
      Parameters:
      varName - the alias of the variable
      Returns:
      a new SPARQL variable
    • as

      public static Assignment as(Assignable exp, Variable var)
      Create a SPARQL assignment
      Parameters:
      exp - the expression to evaluate
      var - the variable to bind the expression value to
      Returns:
      an Assignment object
    • base

      public static Base base(Iri iri)
      Create a SPARQL Base declaration
      Parameters:
      iri - the base iri
      Returns:
      a Base object
    • base

      public static Base base(IRI iri)
      Create a SPARQL Base declaration
      Parameters:
      iri - the base iri
      Returns:
      a Base object
    • prefix

      public static Prefix prefix(String alias, Iri iri)
      Create a SPARQL Prefix declaration
      Parameters:
      alias - the alias of the prefix
      iri - the iri the alias refers to
      Returns:
      a Prefix object
    • prefix

      public static Prefix prefix(String alias, IRI iri)
      Create a SPARQL Prefix declaration
      Parameters:
      alias - the alias of the prefix
      iri - the iri the alias refers to
      Returns:
      a Prefix object
    • prefix

      public static Prefix prefix(Iri iri)
      Create a SPARQL default Prefix declaration
      Parameters:
      iri - the default iri prefix
      Returns:
      a Prefix object
    • prefix

      public static Prefix prefix(IRI iri)
      Create a SPARQL default Prefix declaration
      Parameters:
      iri - the default iri prefix as an IRI.
      Returns:
      a Prefix object
    • prefix

      public static Prefix prefix(Namespace namespace)
      Create SPARQL Prefix declaration from the given Namespace.
      Parameters:
      namespace - the Namespace to convert to a prefix declaration.
      Returns:
      a Prefix object.
    • prefixes

      public static PrefixDeclarations prefixes(Prefix... prefixes)
      Create a SPARQL Prefix clause
      Parameters:
      prefixes - prefix declarations to add to this Prefix clause
      Returns:
      a new
    • from

      public static From from(Iri iri)
      Create a default graph reference
      Parameters:
      iri - the source of the graph
      Returns:
      a From clause
      See Also:
      RDF Datasets
    • from

      public static From from(IRI iri)
      Create a default graph reference
      Parameters:
      iri - the source of the graph
      Returns:
      a From clause
      See Also:
      RDF Datasets
    • fromNamed

      public static From fromNamed(Iri iri)
      Create a named graph reference
      Parameters:
      iri - the source of the graph
      Returns:
      a named From clause
      See Also:
      RDF Datasets
    • fromNamed

      public static From fromNamed(IRI iri)
      Create a named graph reference
      Parameters:
      iri - the source of the graph
      Returns:
      a named From clause
      See Also:
      RDF Datasets
    • dataset

      public static Dataset dataset(From... graphs)
      Create a dataset declaration
      Parameters:
      graphs -
      Returns:
      a new dataset clause
      See Also:
      RDF Datasets
    • select

      public static Projection select(Projectable... projectables)
      Create a SPARQL projection
      Parameters:
      projectables - projectable elements to add to the projection
      Returns:
      a Projection
    • construct

      public static GraphTemplate construct(TriplePattern... triples)
      Create a SPARQL graph template
      Parameters:
      triples - triples to add to the template
      Returns:
      a new SPARQL graph template
    • where

      public static QueryPattern where(GraphPattern... patterns)
      Create a SPARQL query pattern
      Parameters:
      patterns - graph patterns to add to the query pattern
      Returns:
      a new Query Pattern
    • groupBy

      public static GroupBy groupBy(Groupable... groupables)
      Create a SPARQL Group By clause
      Parameters:
      groupables - the group conditions
      Returns:
      a Group By clause
    • orderBy

      public static OrderBy orderBy(Orderable... conditions)
      Create a SPARQL Order clause
      Parameters:
      conditions - the order conditions
      Returns:
      an Order By clause
    • having

      public static Having having(Expression<?>... expressions)
      Create a SPARQL Having clause
      Parameters:
      expressions - the having conditions
      Returns:
      a Having clause
    • asc

      public static OrderCondition asc(Orderable orderOn)
      Create an ascending SPARQL order condition
      Parameters:
      orderOn - the order comparator
      Returns:
      an ASC() order condition
    • desc

      public static OrderCondition desc(Orderable orderOn)
      Create a descending SPARQL order condition
      Parameters:
      orderOn - the order comparator
      Returns:
      a DESC() order condition
    • triplesTemplate

      public static TriplesTemplate triplesTemplate(TriplePattern... triples)
      Create a TriplesTemplate instance, for use with Construct and Update queries
      Parameters:
      triples - the triples to include in the triples template
      Returns:
      a TriplesTemplate of the given triples