Package cz.cvut.kbss.jopa.query
Interface QueryHolder
- All Known Implementing Classes:
- TokenStreamSparqlQueryHolder
public interface QueryHolder
Represents a caretaker of a query, enabling parameter setting and final assembly of the query.
- 
Method SummaryModifier and TypeMethodDescriptionAssembles the query, using any parameter values specified, and returns it as a string.voidclearParameter(Parameter<?> parameter) Clears any previously set value of the specified parameter.voidClears any previously set parameter values in this query.intGets the currently set first result position.intGets the currently set maximum number of results to retrieveParameter<?>getParameter(int position) Gets a parameter with the specified position.Parameter<?>getParameter(String name) Gets a parameter with the specified name.Gets a collection of parameters in the query.getParameterValue(Parameter<?> parameter) Gets value bound to the specified parameter.default List<? extends QueryParameter<?>>Gets the list of query parameters that appear in the SELECT projection clause (in the order in which they are declared).getQuery()Gets the original query string.Set<? extends QueryParameter<?>>Gets a collection of parameters in the query.Gets the type of this query.booleanhasParameter(int position) Checks whether the query has a parameter at the specified position.booleanhasParameter(String name) Checks whether the query has a parameter with the specified name.voidsetFirstResult(int startPosition) Sets the position of the first result to retrieve.voidsetMaxResults(int maxResults) Sets the maximum number of results the query should retrieve.<T> voidsetParameter(Parameter<T> parameter, Object value) Sets value of the specified parameter in the query.<T> voidsetParameter(Parameter<T> parameter, String value, String language) Sets value of the specified parameter in the query.<T> voidsetUntypedParameter(Parameter<T> parameter, Object value) Sets value of the specified parameter in the query.
- 
Method Details- 
getQueryString getQuery()Gets the original query string.- Returns:
- Gets the original unparsed query
 
- 
getParametersGets a collection of parameters in the query.- Returns:
- Parameter objects
 
- 
getQueryParametersSet<? extends QueryParameter<?>> getQueryParameters()Gets a collection of parameters in the query.This returns the same set as getParameters(), but it returns more specific typeQueryParameter.- Returns:
- Parameter objects
 
- 
getProjectedQueryParametersGets the list of query parameters that appear in the SELECT projection clause (in the order in which they are declared).- Returns:
- Projected query parameters
 
- 
hasParameterChecks whether the query has a parameter with the specified name.- Parameters:
- name- Parameter name
- Returns:
- trueif the query has a matching parameter,- falseotherwise
 
- 
hasParameterboolean hasParameter(int position) Checks whether the query has a parameter at the specified position.- Parameters:
- position- Parameter position
- Returns:
- trueif the query has a matching parameter,- falseotherwise
 
- 
getParameterGets a parameter with the specified name.- Parameters:
- name- Parameter name
- Returns:
- Parameter object
- Throws:
- IllegalArgumentException- If the parameter of the specified name does not exist
 
- 
getParameterGets a parameter with the specified position.- Parameters:
- position- Parameter position
- Returns:
- Parameter object
- Throws:
- IllegalArgumentException- If the parameter at the specified position does not exist
 
- 
getParameterValueGets value bound to the specified parameter.- Parameters:
- parameter- Parameter
- Returns:
- parameter value
- Throws:
- IllegalArgumentException- If there is no parameter with the specified name
 
- 
setParameterSets 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. - Type Parameters:
- T- Type of the parameter
- Parameters:
- parameter- Parameter object
- value- Value to use
- Throws:
- IllegalArgumentException- If there is no such parameter in the query
- See Also:
 
- 
setParameterSets value of the specified parameter in the query.If a value was already specified for the parameter, it is overwritten by the new one. - Type Parameters:
- T- Type of the parameter
- Parameters:
- parameter- Parameter object
- value- String value to use
- language- Parameter language
- Throws:
- IllegalArgumentException- If there is no such parameter in the query
 
- 
setUntypedParameterSets 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. - Parameters:
- parameter- Parameter object
- value- Value to use
- Throws:
- IllegalArgumentException- If there is no such parameter in the query
- See Also:
 
- 
setFirstResultvoid setFirstResult(int startPosition) Sets the position of the first result to retrieve.- Parameters:
- startPosition- The position to set, starting at 0
 
- 
getFirstResultint getFirstResult()Gets the currently set first result position.- Returns:
- the first result position, 0 if none was set
 
- 
setMaxResultsvoid setMaxResults(int maxResults) Sets the maximum number of results the query should retrieve.- Parameters:
- maxResults- The maximum number of results
 
- 
getMaxResultsint getMaxResults()Gets the currently set maximum number of results to retrieve- Returns:
- Maximum results value, Integer.MAX_VALUEwhen none was set
 
- 
clearParameterClears any previously set value of the specified parameter.- Parameters:
- parameter- Parameter object
- Throws:
- IllegalArgumentException- If there is no such parameter in the query
 
- 
clearParametersvoid clearParameters()Clears any previously set parameter values in this query.
- 
assembleQueryString assembleQuery()Assembles the query, using any parameter values specified, and returns it as a string.- Returns:
- Assembled query
 
- 
getQueryTypeQueryType getQueryType()Gets the type of this query.- Returns:
- Query type
 
 
-