Package cz.cvut.kbss.jopa.query.sparql
Class SparqlQueryHolder
java.lang.Object
cz.cvut.kbss.jopa.query.sparql.SparqlQueryHolder
- All Implemented Interfaces:
QueryHolder
-
Constructor Summary
ConstructorsConstructorDescriptionSparqlQueryHolder
(String query, List<String> parts, List<QueryParameter<?>> parameters) -
Method Summary
Modifier and TypeMethodDescriptionAssembles the query, using any parameter values specified, and returns it as a string.void
clearParameter
(Parameter<?> parameter) Clears any previously set value of the specified parameter.void
Clears any previously set parameter values in this query.int
Gets the currently set first result position.int
Gets the currently set maximum number of results to retrieveParameter<?>
getParameter
(int position) Gets a parameter with the specified position.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.getQuery()
Gets the original query string.boolean
hasParameter
(int position) Checks whether the query has a parameter at the specified position.boolean
hasParameter
(String name) Checks whether the query has a parameter with the specified name.void
setFirstResult
(int startPosition) Sets the position of the first result to retrieve.void
setMaxResults
(int maxResults) Sets the maximum number of results the query should retrieve.<T> void
setParameter
(Parameter<T> parameter, Object value) Sets value of the specified parameter in the query.<T> void
setParameter
(Parameter<T> parameter, String value, String language) Sets value of the specified parameter in the query.<T> void
setUntypedParameter
(Parameter<T> parameter, Object value) Sets value of the specified parameter in the query.toString()
-
Constructor Details
-
SparqlQueryHolder
-
-
Method Details
-
getQuery
Description copied from interface:QueryHolder
Gets the original query string.- Specified by:
getQuery
in interfaceQueryHolder
- Returns:
- Gets the original unparsed query
-
getParameters
Description copied from interface:QueryHolder
Gets a collection of parameters in the query.- Specified by:
getParameters
in interfaceQueryHolder
- Returns:
- Parameter names
-
hasParameter
Description copied from interface:QueryHolder
Checks whether the query has a parameter with the specified name.- Specified by:
hasParameter
in interfaceQueryHolder
- 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 interfaceQueryHolder
- Parameters:
position
- Parameter position- Returns:
true
if the query has a matching parameter,false
otherwise
-
getParameter
Description copied from interface:QueryHolder
Gets a parameter with the specified name.- Specified by:
getParameter
in interfaceQueryHolder
- Parameters:
name
- Parameter name- Returns:
- Parameter object
-
getParameter
Description copied from interface:QueryHolder
Gets a parameter with the specified position.- Specified by:
getParameter
in interfaceQueryHolder
- Parameters:
position
- Parameter position- Returns:
- Parameter object
-
getParameterValue
Description copied from interface:QueryHolder
Gets value bound to the specified parameter.- Specified by:
getParameterValue
in interfaceQueryHolder
- Parameters:
parameter
- Parameter- Returns:
- parameter value
-
setParameter
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 interfaceQueryHolder
- Type Parameters:
T
- Type of the parameter- Parameters:
parameter
- Parameter objectvalue
- Value to use- See Also:
-
setParameter
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 interfaceQueryHolder
- Type Parameters:
T
- Type of the parameter- Parameters:
parameter
- Parameter objectvalue
- String value to uselanguage
- Parameter language
-
setUntypedParameter
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 interfaceQueryHolder
- Parameters:
parameter
- Parameter objectvalue
- 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 interfaceQueryHolder
- 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 interfaceQueryHolder
- 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 interfaceQueryHolder
- 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 interfaceQueryHolder
- Returns:
- Maximum results value,
Integer.MAX_VALUE
when none was set
-
clearParameter
Description copied from interface:QueryHolder
Clears any previously set value of the specified parameter.- Specified by:
clearParameter
in interfaceQueryHolder
- 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 interfaceQueryHolder
-
assembleQuery
Description copied from interface:QueryHolder
Assembles the query, using any parameter values specified, and returns it as a string.- Specified by:
assembleQuery
in interfaceQueryHolder
- Returns:
- Assembled query
-
toString
-