1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file The result set of database queries.
18 * @kit ArkData
19 */
20
21import { AsyncCallback } from '../../@ohos.base';
22
23/**
24 * Provides methods for accessing a database result set generated by querying the database.
25 *
26 * @interface ResultSet
27 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
28 * @since 7
29 * @deprecated since 9
30 * @useinstead ohos.data.relationalStore.ResultSet
31 */
32export interface ResultSet {
33  /**
34   * Obtains the names of all columns in a result set.
35   * The column names are returned as a string array, in which the strings are in the same order
36   * as the columns in the result set.
37   *
38   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
39   * @since 7
40   * @deprecated since 9
41   * @useinstead ohos.data.relationalStore.ResultSet.columnNames
42   */
43  columnNames: Array<string>;
44
45  /**
46   * Obtains the number of columns in the result set.
47   * The returned number is equal to the length of the string array returned by the
48   * columnCount method.
49   *
50   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
51   * @since 7
52   * @deprecated since 9
53   * @useinstead ohos.data.relationalStore.ResultSet.columnCount
54   */
55  columnCount: number;
56
57  /**
58   * Obtains the number of rows in the result set.
59   *
60   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
61   * @since 7
62   * @deprecated since 9
63   * @useinstead ohos.data.relationalStore.ResultSet.rowCount
64   */
65  rowCount: number;
66
67  /**
68   * Obtains the current index of the result set.
69   * The result set index starts from 0.
70   *
71   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
72   * @since 7
73   * @deprecated since 9
74   * @useinstead ohos.data.relationalStore.ResultSet.rowIndex
75   */
76  rowIndex: number;
77
78  /**
79   * Checks whether the result set is positioned at the first row.
80   *
81   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
82   * @since 7
83   * @deprecated since 9
84   * @useinstead ohos.data.relationalStore.ResultSet.isAtFirstRow
85   */
86  isAtFirstRow: boolean;
87
88  /**
89   * Checks whether the result set is positioned at the last row.
90   *
91   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
92   * @since 7
93   * @deprecated since 9
94   * @useinstead ohos.data.relationalStore.ResultSet.isAtLastRow
95   */
96  isAtLastRow: boolean;
97
98  /**
99   * Checks whether the result set is positioned after the last row.
100   *
101   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
102   * @since 7
103   * @deprecated since 9
104   * @useinstead ohos.data.relationalStore.ResultSet.isEnded
105   */
106  isEnded: boolean;
107
108  /**
109   * returns whether the cursor is pointing to the position before the first
110   * row.
111   *
112   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
113   * @since 7
114   * @deprecated since 9
115   * @useinstead ohos.data.relationalStore.ResultSet.isStarted
116   */
117  isStarted: boolean;
118
119  /**
120   * Checks whether the current result set is closed.
121   * If the result set is closed by calling the close method, true will be returned.
122   *
123   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
124   * @since 7
125   * @deprecated since 9
126   * @useinstead ohos.data.relationalStore.ResultSet.isClosed
127   */
128  isClosed: boolean;
129
130  /**
131   * Obtains the column index based on the specified column name.
132   * The column name is passed as an input parameter.
133   *
134   * @param { string } columnName - Indicates the name of the specified column in the result set.
135   * @returns { number } return the index of the specified column.
136   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
137   * @since 7
138   * @deprecated since 9
139   * @useinstead ohos.data.relationalStore.ResultSet.getColumnIndex
140   */
141  getColumnIndex(columnName: string): number;
142
143  /**
144   * Obtains the column name based on the specified column index.
145   * The column index is passed as an input parameter.
146   *
147   * @param { number } columnIndex - Indicates the index of the specified column in the result set.
148   * @returns { string } returns the name of the specified column.
149   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
150   * @since 7
151   * @deprecated since 9
152   * @useinstead ohos.data.relationalStore.ResultSet.getColumnName
153   */
154  getColumnName(columnIndex: number): string;
155
156  /**
157   * Go to the specified row of the result set forwards or backwards by an offset relative to its current position.
158   * A positive offset indicates moving backwards, and a negative offset indicates moving forwards.
159   *
160   * @param { number } offset - Indicates the offset relative to the current position.
161   * @returns { boolean } returns true if the result set is moved successfully and does not go beyond the range;
162   *                   returns false otherwise.
163   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
164   * @since 7
165   * @deprecated since 9
166   * @useinstead ohos.data.relationalStore.ResultSet.goTo
167   */
168  goTo(offset: number): boolean;
169
170  /**
171   * Go to the specified row of the result set.
172   *
173   * @param { number } position - Indicates the index of the specified row, which starts from 0.
174   * @returns { boolean } returns true if the result set is moved successfully; returns false otherwise.
175   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
176   * @since 7
177   * @deprecated since 9
178   * @useinstead ohos.data.relationalStore.ResultSet.goToRow
179   */
180  goToRow(position: number): boolean;
181
182  /**
183   * Go to the first row of the result set.
184   *
185   * @returns { boolean } returns true if the result set is moved successfully;
186   *                    returns false otherwise, for example, if the result set is empty.
187   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
188   * @since 7
189   * @deprecated since 9
190   * @useinstead ohos.data.relationalStore.ResultSet.goToFirstRow
191   */
192  goToFirstRow(): boolean;
193
194  /**
195   * Go to the last row of the result set.
196   *
197   * @returns { boolean } returns true if the result set is moved successfully;
198   *                    returns false otherwise, for example, if the result set is empty.
199   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
200   * @since 7
201   * @deprecated since 9
202   * @useinstead ohos.data.relationalStore.ResultSet.goToLastRow
203   */
204  goToLastRow(): boolean;
205
206  /**
207   * Go to the next row of the result set.
208   *
209   * @returns { boolean } returns true if the result set is moved successfully;
210   *                    returns false otherwise, for example, if the result set is already in the last row.
211   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
212   * @since 7
213   * @deprecated since 9
214   * @useinstead ohos.data.relationalStore.ResultSet.goToNextRow
215   */
216  goToNextRow(): boolean;
217
218  /**
219   * Go to the previous row of the result set.
220   *
221   * @returns { boolean } returns true if the result set is moved successfully;
222   *                    returns false otherwise, for example, if the result set is already in the first row.
223   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
224   * @since 7
225   * @deprecated since 9
226   * @useinstead ohos.data.relationalStore.ResultSet.goToPreviousRow
227   */
228  goToPreviousRow(): boolean;
229
230  /**
231   * Obtains the value of the specified column in the current row as a byte array.
232   * The implementation class determines whether to throw an exception if the value of the specified column
233   * in the current row is null or the specified column is not of the Blob type.
234   *
235   * @param { number } columnIndex - Indicates the specified column index, which starts from 0.
236   * @returns { Uint8Array } returns the value of the specified column as a byte array.
237   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
238   * @since 7
239   * @deprecated since 9
240   * @useinstead ohos.data.relationalStore.ResultSet.getBlob
241   */
242  getBlob(columnIndex: number): Uint8Array;
243
244  /**
245   * Obtains the value of the specified column in the current row as string.
246   * The implementation class determines whether to throw an exception if the value of the specified column
247   * in the current row is null or the specified column is not of the string type.
248   *
249   * @param { number } columnIndex - Indicates the specified column index, which starts from 0.
250   * @returns { string } returns the value of the specified column as a string.
251   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
252   * @since 7
253   * @deprecated since 9
254   * @useinstead ohos.data.relationalStore.ResultSet.getString
255   */
256  getString(columnIndex: number): string;
257
258  /**
259   * Obtains the value of the specified column in the current row as long.
260   * The implementation class determines whether to throw an exception if the value of the specified column
261   * in the current row is null, the specified column is not of the integer type.
262   *
263   * @param { number } columnIndex - Indicates the specified column index, which starts from 0.
264   * @returns { number } returns the value of the specified column as a long.
265   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
266   * @since 7
267   * @deprecated since 9
268   * @useinstead ohos.data.relationalStore.ResultSet.getLong
269   */
270  getLong(columnIndex: number): number;
271
272  /**
273   * Obtains the value of the specified column in the current row as double.
274   * The implementation class determines whether to throw an exception if the value of the specified column
275   * in the current row is null, the specified column is not of the double type.
276   *
277   * @param { number } columnIndex - Indicates the specified column index, which starts from 0.
278   * @returns { number } returns the value of the specified column as a double.
279   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
280   * @since 7
281   * @deprecated since 9
282   * @useinstead ohos.data.relationalStore.ResultSet.getDouble
283   */
284  getDouble(columnIndex: number): number;
285
286  /**
287   * Checks whether the value of the specified column in the current row is null.
288   *
289   * @param { number } columnIndex - Indicates the specified column index, which starts from 0.
290   * @returns { boolean } returns true if the value of the specified column in the current row is null;
291   *                    returns false otherwise.
292   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
293   * @since 7
294   * @deprecated since 9
295   * @useinstead ohos.data.relationalStore.ResultSet.isColumnNull
296   */
297  isColumnNull(columnIndex: number): boolean;
298
299  /**
300   * Closes the result set.
301   * Calling this method on the result set will release all of its resources and makes it ineffective.
302   *
303   * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
304   * @since 7
305   * @deprecated since 9
306   * @useinstead ohos.data.relationalStore.ResultSet.close
307   */
308  close(): void;
309}
310