Skip to content

Package: QueryFactory

QueryFactory

Coverage

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.sessions;
16:
17: import cz.cvut.kbss.jopa.model.query.Query;
18: import cz.cvut.kbss.jopa.model.query.TypedQuery;
19:
20: public interface QueryFactory {
21:
22: /**
23: * Creates query object representing a native SPARQL query.
24: *
25: * @param sparql The query
26: * @return Query object
27: * @throws NullPointerException If {@code sparql} is {@code null}
28: */
29: Query createNativeQuery(String sparql);
30:
31: /**
32: * Creates typed query object representing a native SPARQL query.
33: *
34: * @param sparql The query
35: * @param resultClass Type of the results
36: * @return Query object
37: * @throws NullPointerException If {@code sparql} or {@code resultClass} is {@code null}
38: */
39: <T> TypedQuery<T> createNativeQuery(String sparql, Class<T> resultClass);
40:
41: /**
42: * Creates a query object representing a native SPARQL query.
43: * @param sparql The query
44: * @param resultSetMapping Name of the result set mapping to apply
45: * @return Query object
46: * * @throws NullPointerException If {@code sparql} or {@code resultSetMapping} is {@code null}
47: */
48: Query createNativeQuery(String sparql, String resultSetMapping);
49:
50: /**
51: * Creates query object representing a native SPARQL query.
52: *
53: * @param query The query
54: * @return Query object
55: * @throws NullPointerException If {@code sparql} is {@code null}
56: */
57: Query createQuery(String query);
58:
59: /**
60: * Creates typed query object representing a native SPARQL query.
61: *
62: * @param query The query
63: * @param resultClass Type of the results param URI of the ontology context against which the query will be
64: * evaluated
65: * @return Query object
66: * @throws NullPointerException If {@code sparql} or {@code resultClass} is {@code null}
67: */
68: <T> TypedQuery<T> createQuery(String query, Class<T> resultClass);
69:
70: /**
71: * Creates a query object representing a native SPARQL query.
72: *
73: * @param name The name of the query defined in metadata
74: * @return Query object
75: * @throws IllegalArgumentException If a query has not been defined with the given name
76: */
77: Query createNamedQuery(String name);
78:
79: /**
80: * Creates a typed query object representing a native SPARQL query.
81: *
82: * @param name The name of the query defined in metadata
83: * @param resultClass Type of the results param URI of the ontology context against which the query will be
84: * evaluated
85: * @return Query object
86: * @throws IllegalArgumentException If a query has not been defined with the given name
87: */
88: <T> TypedQuery<T> createNamedQuery(String name, Class<T> resultClass);
89: }