Class SparqlQueryHolder

java.lang.Object
cz.cvut.kbss.jopa.query.sparql.SparqlQueryHolder
All Implemented Interfaces:
QueryHolder

public class SparqlQueryHolder extends Object implements QueryHolder
  • Constructor Details

  • Method Details

    • getQuery

      public String getQuery()
      Description copied from interface: QueryHolder
      Gets the original query string.
      Specified by:
      getQuery in interface QueryHolder
      Returns:
      Gets the original unparsed query
    • getParameters

      public Set<Parameter<?>> getParameters()
      Description copied from interface: QueryHolder
      Gets a collection of parameters in the query.
      Specified by:
      getParameters in interface QueryHolder
      Returns:
      Parameter names
    • hasParameter

      public boolean hasParameter(String name)
      Description copied from interface: QueryHolder
      Checks whether the query has a parameter with the specified name.
      Specified by:
      hasParameter in interface QueryHolder
      Parameters:
      name - Parameter name
      Returns:
      true if the query has a matching parameter, false otherwise
    • hasParameter

      public boolean hasParameter(int position)
      Description copied from interface: QueryHolder
      Checks whether the query has a parameter at the specified position.
      Specified by:
      hasParameter in interface QueryHolder
      Parameters:
      position - Parameter position
      Returns:
      true if the query has a matching parameter, false otherwise
    • getParameter

      public QueryParameter<?> getParameter(String name)
      Description copied from interface: QueryHolder
      Gets a parameter with the specified name.
      Specified by:
      getParameter in interface QueryHolder
      Parameters:
      name - Parameter name
      Returns:
      Parameter object
    • getParameter

      public Parameter<?> getParameter(int position)
      Description copied from interface: QueryHolder
      Gets a parameter with the specified position.
      Specified by:
      getParameter in interface QueryHolder
      Parameters:
      position - Parameter position
      Returns:
      Parameter object
    • getParameterValue

      public Object getParameterValue(Parameter<?> parameter)
      Description copied from interface: QueryHolder
      Gets value bound to the specified parameter.
      Specified by:
      getParameterValue in interface QueryHolder
      Parameters:
      parameter - Parameter
      Returns:
      parameter value
    • setParameter

      public <T> void setParameter(Parameter<T> parameter, Object value)
      Description copied from interface: QueryHolder
      Sets value of the specified parameter in the query.

      If a value was already specified for the parameter, it is overwritten by the new one. This version expresses the value type information using XSD datatype in the query string.

      Specified by:
      setParameter in interface QueryHolder
      Type Parameters:
      T - Type of the parameter
      Parameters:
      parameter - Parameter object
      value - Value to use
      See Also:
    • setParameter

      public <T> void setParameter(Parameter<T> parameter, String value, String language)
      Description copied from interface: QueryHolder
      Sets value of the specified parameter in the query.

      If a value was already specified for the parameter, it is overwritten by the new one.

      Specified by:
      setParameter in interface QueryHolder
      Type Parameters:
      T - Type of the parameter
      Parameters:
      parameter - Parameter object
      value - String value to use
      language - Parameter language
    • setUntypedParameter

      public <T> void setUntypedParameter(Parameter<T> parameter, Object value)
      Description copied from interface: QueryHolder
      Sets value of the specified parameter in the query.

      If a value was already specified for the parameter, it is overwritten by the new one. This version inserts the string representation of the value directly into the query, without any type information.

      Specified by:
      setUntypedParameter in interface QueryHolder
      Parameters:
      parameter - Parameter object
      value - Value to use
      See Also:
    • setFirstResult

      public void setFirstResult(int startPosition)
      Description copied from interface: QueryHolder
      Sets the position of the first result to retrieve.
      Specified by:
      setFirstResult in interface QueryHolder
      Parameters:
      startPosition - The position to set, starting at 0
    • getFirstResult

      public int getFirstResult()
      Description copied from interface: QueryHolder
      Gets the currently set first result position.
      Specified by:
      getFirstResult in interface QueryHolder
      Returns:
      the first result position, 0 if none was set
    • setMaxResults

      public void setMaxResults(int maxResults)
      Description copied from interface: QueryHolder
      Sets the maximum number of results the query should retrieve.
      Specified by:
      setMaxResults in interface QueryHolder
      Parameters:
      maxResults - The maximum number of results
    • getMaxResults

      public int getMaxResults()
      Description copied from interface: QueryHolder
      Gets the currently set maximum number of results to retrieve
      Specified by:
      getMaxResults in interface QueryHolder
      Returns:
      Maximum results value, Integer.MAX_VALUE when none was set
    • clearParameter

      public void clearParameter(Parameter<?> parameter)
      Description copied from interface: QueryHolder
      Clears any previously set value of the specified parameter.
      Specified by:
      clearParameter in interface QueryHolder
      Parameters:
      parameter - Parameter object
    • clearParameters

      public void clearParameters()
      Description copied from interface: QueryHolder
      Clears any previously set parameter values in this query.
      Specified by:
      clearParameters in interface QueryHolder
    • assembleQuery

      public String assembleQuery()
      Description copied from interface: QueryHolder
      Assembles the query, using any parameter values specified, and returns it as a string.
      Specified by:
      assembleQuery in interface QueryHolder
      Returns:
      Assembled query
    • toString

      public String toString()
      Overrides:
      toString in class Object