Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
OQLQuery |
|
| 1.0;1 |
1 | package org.odmg; | |
2 | ||
3 | ||
4 | ||
5 | /** | |
6 | ||
7 | * The interface to an OQL query object. | |
8 | ||
9 | * @author David Jordan (as Java Editor of the Object Data Management Group) | |
10 | ||
11 | * @version ODMG 3.0 | |
12 | ||
13 | */ | |
14 | ||
15 | ||
16 | ||
17 | public interface OQLQuery | |
18 | ||
19 | { | |
20 | ||
21 | ||
22 | ||
23 | /** | |
24 | ||
25 | * Create an OQL query from the string parameter. | |
26 | ||
27 | * In order to execute a query, an <code>OQLQuery</code> object must be created | |
28 | ||
29 | * by calling <code>Implementation.newOQLQuery</code>, then calling the | |
30 | ||
31 | * <code>create</code> method with the query string. | |
32 | ||
33 | * The <code>create</code> method might throw <code>QueryInvalidException</code> | |
34 | ||
35 | * if the query could not be compiled properly. Some implementations may not want | |
36 | ||
37 | * to compile the query before <code>execute</code> is called. In this case | |
38 | ||
39 | * <code>QueryInvalidException</code> is thrown when <code>execute</code> is called. | |
40 | ||
41 | * @param query An OQL query. | |
42 | ||
43 | * @exception QueryInvalidException The query syntax is invalid. | |
44 | ||
45 | */ | |
46 | ||
47 | public void create(String query) throws QueryInvalidException; | |
48 | ||
49 | ||
50 | ||
51 | /** | |
52 | ||
53 | * Bind a parameter to the query. | |
54 | ||
55 | * A parameter is denoted in the query string passed to <code>create</code> by <i>$i</i>, | |
56 | ||
57 | * where <i>i</i> is the rank of the parameter, beginning with 1. | |
58 | ||
59 | * The parameters are set consecutively by calling this method <code>bind</code>. | |
60 | ||
61 | * The <i>ith</i> variable is set by the <i>ith</i> call to the <code>bind</code> method. | |
62 | ||
63 | * If any of the <i>$i</i> are not set by a call to <code>bind</code> at the point | |
64 | ||
65 | * <code>execute</code> is called, <code>QueryParameterCountInvalidException</code> is thrown. | |
66 | ||
67 | * The parameters must be objects, and the result is an <code>Object</code>. | |
68 | ||
69 | * Objects must be used instead of primitive types (<code>Integer</code> instead | |
70 | ||
71 | * of <code>int</code>) for passing the parameters. | |
72 | ||
73 | * <p> | |
74 | ||
75 | * If the parameter is of the wrong type, | |
76 | ||
77 | * <code>QueryParameterTypeInvalidException</code> is thrown. | |
78 | ||
79 | * After executing a query, the parameter list is reset. | |
80 | ||
81 | * @parameter A value to be substituted for a query parameter. | |
82 | ||
83 | * @exception QueryParameterCountInvalidException The number of calls to | |
84 | ||
85 | * <code>bind</code> has exceeded the number of parameters in the query. | |
86 | ||
87 | * @exception QueryParameterTypeInvalidException The type of the parameter does | |
88 | ||
89 | * not correspond with the type of the parameter in the query. | |
90 | ||
91 | */ | |
92 | ||
93 | public void bind(Object parameter) throws QueryParameterCountInvalidException, | |
94 | ||
95 | QueryParameterTypeInvalidException; | |
96 | ||
97 | ||
98 | ||
99 | /** | |
100 | ||
101 | * Execute the query. | |
102 | ||
103 | * After executing a query, the parameter list is reset. | |
104 | ||
105 | * Some implementations may throw additional exceptions that are also derived | |
106 | ||
107 | * from <code>ODMGException</code>. | |
108 | ||
109 | * @return The object that represents the result of the query. | |
110 | ||
111 | * The returned data, whatever its OQL type, is encapsulated into an object. | |
112 | ||
113 | * For instance, when OQL returns an integer, the result is put into an | |
114 | ||
115 | * <code>Integer</code> object. When OQL returns a collection (literal or object), | |
116 | ||
117 | * the result is always a Java collection object of the same kind | |
118 | ||
119 | * (for instance, a <code>DList</code>). | |
120 | ||
121 | * @exception QueryException An exception has occurred while executing the query. | |
122 | ||
123 | */ | |
124 | ||
125 | public Object execute() throws QueryException; | |
126 | ||
127 | } | |
128 |