Skip to content

Package: QueryFactory

QueryFactory

Coverage

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