org.eclipse.rdf4j.sparqlbuilder.core.query

## Class Query<T extends Query<T>>

- java.lang.Object
- - org.eclipse.rdf4j.sparqlbuilder.core.query.Query<T>

- Type Parameters:
    `T` - They type of query. Used to support fluency.
  All Implemented Interfaces:
    QueryElement
  Direct Known Subclasses:
    OuterQuery, SubSelect

      public abstract class Query<T extends Query<T>>
      extends Object
      implements QueryElement

  The base class for all SPARQL Queries. Contains elements and methods common to all queries.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `bnodeCount`
    `protected Optional<Dataset>` | `from`
    `protected Optional<GroupBy>` | `groupBy`
    `protected Optional<Having>` | `having`
    `protected int` | `limit`
    `protected static String` | `LIMIT`
    `protected int` | `offset`
    `protected static String` | `OFFSET`
    `protected Optional<OrderBy>` | `orderBy`
    `protected int` | `varCount`
    `protected QueryPattern` | `where`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Query()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `RdfBlankNode.LabeledBlankNode` | `bNode()` A shortcut.
    `T` | `from(Dataset from)` Set the Dataset clause for this query
    `T` | `from(From... graphs)` Add datasets to this query
    `protected abstract String` | `getQueryActionString()`
    `String` | `getQueryString()`
    `T` | `groupBy(Groupable... groupables)` Add grouping specifiers for the query results.
    `T` | `groupBy(GroupBy groupBy)` Set this query's Group By clause
    `T` | `having(Expression<?>... constraints)` Specify constraints for this query's Having clause.
    `T` | `having(Having having)` Set this query's Having clause
    `T` | `limit(int limit)` Set a limit on the number of results returned by this query.
    `T` | `offset(int offset)` Specify an offset in query results.
    `T` | `orderBy(Orderable... conditions)` Specify orderings for the query results
    `T` | `orderBy(OrderBy orderBy)` Set this query's Order By clause
    `Variable` | `var()` A shortcut.
    `T` | `where(GraphPattern... queryPatterns)` Add graph patterns to this query's query pattern
    `T` | `where(QueryPattern where)` Set the query pattern of this query

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LIMIT

          protected static final String LIMIT

      See Also:
        Constant Field Values

    - #### OFFSET

          protected static final String OFFSET

      See Also:
        Constant Field Values

    - #### from

          protected Optional<Dataset> from

    - #### where

          protected QueryPattern where

    - #### groupBy

          protected Optional<GroupBy> groupBy

    - #### orderBy

          protected Optional<OrderBy> orderBy

    - #### having

          protected Optional<Having> having

    - #### limit

          protected int limit

    - #### offset

          protected int offset

    - #### varCount

          protected int varCount

    - #### bnodeCount

          protected int bnodeCount

  - ### Constructor Detail

    - #### Query

          public Query()

  - ### Method Detail

    - #### from

          public T from(From... graphs)

      Add datasets to this query
      Parameters:
        `graphs` - the graph specifiers to add
      Returns:
        this

    - #### from

          public T from(Dataset from)

      Set the Dataset clause for this query
      Parameters:
        `from` - the `Dataset` clause to set
      Returns:
        this

    - #### where

          public T where(GraphPattern... queryPatterns)

      Add graph patterns to this query's query pattern
      Parameters:
        `queryPatterns` - the patterns to add
      Returns:
        this
      See Also:
        `QueryPattern`

    - #### where

          public T where(QueryPattern where)

      Set the query pattern of this query
      Parameters:
        `where` - the query pattern to set
      Returns:
        this

    - #### groupBy

          public T groupBy(Groupable... groupables)

      Add grouping specifiers for the query results.
      Parameters:
        `groupables` - the objects to group on, in order (appended to the end of any existing grouping specifiers)
      Returns:
        this
      See Also:
        `GroupBy`

    - #### groupBy

          public T groupBy(GroupBy groupBy)

      Set this query's Group By clause
      Parameters:
        `groupBy` - the `GroupBy` clause to set
      Returns:
        this

    - #### orderBy

          public T orderBy(Orderable... conditions)

      Specify orderings for the query results
      Parameters:
        `conditions` - the objects to order on, in order
      Returns:
        this
      See Also:
        `OrderBy`

    - #### orderBy

          public T orderBy(OrderBy orderBy)

      Set this query's Order By clause
      Parameters:
        `orderBy` - the `OrderBy` clause to set
      Returns:
        this

    - #### having

          public T having(Expression<?>... constraints)

      Specify constraints for this query's Having clause.
      Parameters:
        `constraints` - the constraints to add to the clause
      Returns:
        this
      See Also:
        `Having`

    - #### having

          public T having(Having having)

      Set this query's Having clause
      Parameters:
        `having` - the Having clause to set
      Returns:
        this

    - #### limit

          public T limit(int limit)

      Set a limit on the number of results returned by this query.
      Parameters:
        `limit` -
      Returns:
        this
      See Also:
        Limits in SPARQL Queries

    - #### offset

          public T offset(int offset)

      Specify an offset in query results.
      Parameters:
        `offset` -
      Returns:
        this
      See Also:
        Offsets in SPARQL Queries

    - #### var

          public Variable var()

      A shortcut. Each call to this method returns a new `Variable` that is unique (i.e., has a unique alias) to this query instance.
      Returns:
        a `Variable` object that is unique to this query instance

    - #### bNode

          public RdfBlankNode.LabeledBlankNode bNode()

      A shortcut. Each call to this method returns a new `RdfBlankNode.LabeledBlankNode` that is unique (i.e., has a unique alias) to this query instance.
      Returns:
        a `RdfBlankNode.LabeledBlankNode` object that is unique to this query instance

    - #### getQueryActionString

          protected abstract String getQueryActionString()

    - #### getQueryString

          public String getQueryString()

      Specified by:
        `getQueryString` in interface `QueryElement`
      Returns:
        the String representing the SPARQL syntax of this element

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