161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit ArkData
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ci/**
2261847f8eSopenharmony_ci * Indicates the {@code DataType}.
2361847f8eSopenharmony_ci * <p>{@code DataType} is obtained based on the value.
2461847f8eSopenharmony_ci *
2561847f8eSopenharmony_ci * @enum { number }
2661847f8eSopenharmony_ci * @syscap SystemCapability.DistributedDataManager.DataShare.Core
2761847f8eSopenharmony_ci * @systemapi
2861847f8eSopenharmony_ci * @StageModelOnly
2961847f8eSopenharmony_ci * @since 9
3061847f8eSopenharmony_ci */
3161847f8eSopenharmony_ciexport enum DataType {
3261847f8eSopenharmony_ci  /**
3361847f8eSopenharmony_ci   * Indicates that the data type is null.
3461847f8eSopenharmony_ci   *
3561847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
3661847f8eSopenharmony_ci   * @systemapi
3761847f8eSopenharmony_ci   * @StageModelOnly
3861847f8eSopenharmony_ci   * @since 9
3961847f8eSopenharmony_ci   */
4061847f8eSopenharmony_ci  TYPE_NULL = 0,
4161847f8eSopenharmony_ci
4261847f8eSopenharmony_ci  /**
4361847f8eSopenharmony_ci   * Indicates that the data type is long.
4461847f8eSopenharmony_ci   *
4561847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
4661847f8eSopenharmony_ci   * @systemapi
4761847f8eSopenharmony_ci   * @StageModelOnly
4861847f8eSopenharmony_ci   * @since 9
4961847f8eSopenharmony_ci   */
5061847f8eSopenharmony_ci  TYPE_LONG = 1,
5161847f8eSopenharmony_ci
5261847f8eSopenharmony_ci  /**
5361847f8eSopenharmony_ci   * Indicates that the data type is double.
5461847f8eSopenharmony_ci   *
5561847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
5661847f8eSopenharmony_ci   * @systemapi
5761847f8eSopenharmony_ci   * @StageModelOnly
5861847f8eSopenharmony_ci   * @since 9
5961847f8eSopenharmony_ci   */
6061847f8eSopenharmony_ci  TYPE_DOUBLE = 2,
6161847f8eSopenharmony_ci
6261847f8eSopenharmony_ci  /**
6361847f8eSopenharmony_ci   * Indicates that the data type is byte string.
6461847f8eSopenharmony_ci   *
6561847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
6661847f8eSopenharmony_ci   * @systemapi
6761847f8eSopenharmony_ci   * @StageModelOnly
6861847f8eSopenharmony_ci   * @since 9
6961847f8eSopenharmony_ci   */
7061847f8eSopenharmony_ci  TYPE_STRING = 3,
7161847f8eSopenharmony_ci
7261847f8eSopenharmony_ci  /**
7361847f8eSopenharmony_ci   * Indicates that the data type is blob.
7461847f8eSopenharmony_ci   *
7561847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
7661847f8eSopenharmony_ci   * @systemapi
7761847f8eSopenharmony_ci   * @StageModelOnly
7861847f8eSopenharmony_ci   * @since 9
7961847f8eSopenharmony_ci   */
8061847f8eSopenharmony_ci  TYPE_BLOB = 4
8161847f8eSopenharmony_ci}
8261847f8eSopenharmony_ci
8361847f8eSopenharmony_ci/**
8461847f8eSopenharmony_ci * Provides methods for accessing a datashare result set generated by querying the database.
8561847f8eSopenharmony_ci *
8661847f8eSopenharmony_ci * @interface DataShareResultSet
8761847f8eSopenharmony_ci * @syscap SystemCapability.DistributedDataManager.DataShare.Core
8861847f8eSopenharmony_ci * @systemapi
8961847f8eSopenharmony_ci * @StageModelOnly
9061847f8eSopenharmony_ci * @since 9
9161847f8eSopenharmony_ci */
9261847f8eSopenharmony_ciexport default interface DataShareResultSet {
9361847f8eSopenharmony_ci  /**
9461847f8eSopenharmony_ci   * Obtains the names of all columns or keys in a result set.
9561847f8eSopenharmony_ci   * The column or key names are returned as a string array, in which the strings are in the same order
9661847f8eSopenharmony_ci   * as the columns or keys in the result set.
9761847f8eSopenharmony_ci   *
9861847f8eSopenharmony_ci   * @type { Array<string> }
9961847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
10061847f8eSopenharmony_ci   * @systemapi
10161847f8eSopenharmony_ci   * @StageModelOnly
10261847f8eSopenharmony_ci   * @since 9
10361847f8eSopenharmony_ci   */
10461847f8eSopenharmony_ci  columnNames: Array<string>;
10561847f8eSopenharmony_ci
10661847f8eSopenharmony_ci  /**
10761847f8eSopenharmony_ci   * Obtains the number of columns or keys in the result set.
10861847f8eSopenharmony_ci   * The returned number is equal to the length of the string array returned by the columnCount method.
10961847f8eSopenharmony_ci   *
11061847f8eSopenharmony_ci   * @type { number }
11161847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
11261847f8eSopenharmony_ci   * @systemapi
11361847f8eSopenharmony_ci   * @StageModelOnly
11461847f8eSopenharmony_ci   * @since 9
11561847f8eSopenharmony_ci   */
11661847f8eSopenharmony_ci  columnCount: number;
11761847f8eSopenharmony_ci
11861847f8eSopenharmony_ci  /**
11961847f8eSopenharmony_ci   * Obtains the number of rows in the result set.
12061847f8eSopenharmony_ci   *
12161847f8eSopenharmony_ci   * @type { number }
12261847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
12361847f8eSopenharmony_ci   * @systemapi
12461847f8eSopenharmony_ci   * @StageModelOnly
12561847f8eSopenharmony_ci   * @since 9
12661847f8eSopenharmony_ci   */
12761847f8eSopenharmony_ci  rowCount: number;
12861847f8eSopenharmony_ci
12961847f8eSopenharmony_ci  /**
13061847f8eSopenharmony_ci   * Checks whether the current result set is closed.
13161847f8eSopenharmony_ci   * If the result set is closed by calling the close method, true will be returned.
13261847f8eSopenharmony_ci   *
13361847f8eSopenharmony_ci   * @type { boolean }
13461847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
13561847f8eSopenharmony_ci   * @systemapi
13661847f8eSopenharmony_ci   * @StageModelOnly
13761847f8eSopenharmony_ci   * @since 9
13861847f8eSopenharmony_ci   */
13961847f8eSopenharmony_ci  isClosed: boolean;
14061847f8eSopenharmony_ci
14161847f8eSopenharmony_ci  /**
14261847f8eSopenharmony_ci   * Go to the first row of the result set.
14361847f8eSopenharmony_ci   *
14461847f8eSopenharmony_ci   * @returns { boolean } Returns true if the result set is moved successfully;
14561847f8eSopenharmony_ci   * returns false otherwise, for example, if the result set is empty.
14661847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
14761847f8eSopenharmony_ci   * @systemapi
14861847f8eSopenharmony_ci   * @StageModelOnly
14961847f8eSopenharmony_ci   * @since 9
15061847f8eSopenharmony_ci   */
15161847f8eSopenharmony_ci  goToFirstRow(): boolean;
15261847f8eSopenharmony_ci
15361847f8eSopenharmony_ci  /**
15461847f8eSopenharmony_ci   * Go to the last row of the result set.
15561847f8eSopenharmony_ci   *
15661847f8eSopenharmony_ci   * @returns { boolean } Returns true if the result set is moved successfully;
15761847f8eSopenharmony_ci   * returns false otherwise, for example, if the result set is empty.
15861847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
15961847f8eSopenharmony_ci   * @systemapi
16061847f8eSopenharmony_ci   * @StageModelOnly
16161847f8eSopenharmony_ci   * @since 9
16261847f8eSopenharmony_ci   */
16361847f8eSopenharmony_ci  goToLastRow(): boolean;
16461847f8eSopenharmony_ci
16561847f8eSopenharmony_ci  /**
16661847f8eSopenharmony_ci   * Go to the next row of the result set.
16761847f8eSopenharmony_ci   *
16861847f8eSopenharmony_ci   * @returns { boolean } Returns true if the result set is moved successfully;
16961847f8eSopenharmony_ci   * returns false otherwise, for example, if the result set is already in the last row.
17061847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
17161847f8eSopenharmony_ci   * @systemapi
17261847f8eSopenharmony_ci   * @StageModelOnly
17361847f8eSopenharmony_ci   * @since 9
17461847f8eSopenharmony_ci   */
17561847f8eSopenharmony_ci  goToNextRow(): boolean;
17661847f8eSopenharmony_ci
17761847f8eSopenharmony_ci  /**
17861847f8eSopenharmony_ci   * Go to the previous row of the result set.
17961847f8eSopenharmony_ci   *
18061847f8eSopenharmony_ci   * @returns { boolean } Returns true if the result set is moved successfully;
18161847f8eSopenharmony_ci   * returns false otherwise, for example, if the result set is already in the first row.
18261847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
18361847f8eSopenharmony_ci   * @systemapi
18461847f8eSopenharmony_ci   * @StageModelOnly
18561847f8eSopenharmony_ci   * @since 9
18661847f8eSopenharmony_ci   */
18761847f8eSopenharmony_ci  goToPreviousRow(): boolean;
18861847f8eSopenharmony_ci
18961847f8eSopenharmony_ci  /**
19061847f8eSopenharmony_ci   * Go to the specified row of the result set forwards or backwards by an offset relative to its current position.
19161847f8eSopenharmony_ci   * A positive offset indicates moving backwards, and a negative offset indicates moving forwards.
19261847f8eSopenharmony_ci   *
19361847f8eSopenharmony_ci   * @param { number } offset - Indicates the offset relative to the current position.
19461847f8eSopenharmony_ci   * @returns { boolean } Returns true if the result set is moved successfully and does not go beyond the range;
19561847f8eSopenharmony_ci   * returns false otherwise.
19661847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
19761847f8eSopenharmony_ci   * @systemapi
19861847f8eSopenharmony_ci   * @StageModelOnly
19961847f8eSopenharmony_ci   * @since 9
20061847f8eSopenharmony_ci   */
20161847f8eSopenharmony_ci  goTo(offset: number): boolean;
20261847f8eSopenharmony_ci
20361847f8eSopenharmony_ci  /**
20461847f8eSopenharmony_ci   * Go to the specified row of the result set.
20561847f8eSopenharmony_ci   *
20661847f8eSopenharmony_ci   * @param { number } position - Indicates the index of the specified row, which starts from 0.
20761847f8eSopenharmony_ci   * @returns { boolean } Returns true if the result set is moved successfully; returns false otherwise.
20861847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
20961847f8eSopenharmony_ci   * @systemapi
21061847f8eSopenharmony_ci   * @StageModelOnly
21161847f8eSopenharmony_ci   * @since 9
21261847f8eSopenharmony_ci   */
21361847f8eSopenharmony_ci  goToRow(position: number): boolean;
21461847f8eSopenharmony_ci
21561847f8eSopenharmony_ci  /**
21661847f8eSopenharmony_ci   * Obtains the value of the specified column or key in the current row as a byte array.
21761847f8eSopenharmony_ci   * The implementation class determines whether to throw an exception if the value of the specified
21861847f8eSopenharmony_ci   * column or key in the current row is null or the specified column or key is not of the Blob type.
21961847f8eSopenharmony_ci   *
22061847f8eSopenharmony_ci   * @param { number } columnIndex - Indicates the specified column index or key index, which starts from 0.
22161847f8eSopenharmony_ci   * @returns { Uint8Array } Returns the value of the specified column or key as a byte array.
22261847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
22361847f8eSopenharmony_ci   * @systemapi
22461847f8eSopenharmony_ci   * @StageModelOnly
22561847f8eSopenharmony_ci   * @since 9
22661847f8eSopenharmony_ci   */
22761847f8eSopenharmony_ci  getBlob(columnIndex: number): Uint8Array;
22861847f8eSopenharmony_ci
22961847f8eSopenharmony_ci  /**
23061847f8eSopenharmony_ci   * Obtains the value of the specified column or key in the current row as string.
23161847f8eSopenharmony_ci   * The implementation class determines whether to throw an exception if the value of the specified
23261847f8eSopenharmony_ci   * column or key in the current row is null or the specified column or key is not of the string type.
23361847f8eSopenharmony_ci   *
23461847f8eSopenharmony_ci   * @param { number } columnIndex - Indicates the specified column index or key index, which starts from 0.
23561847f8eSopenharmony_ci   * @returns { string } Returns the value of the specified column or key as a string.
23661847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
23761847f8eSopenharmony_ci   * @systemapi
23861847f8eSopenharmony_ci   * @StageModelOnly
23961847f8eSopenharmony_ci   * @since 9
24061847f8eSopenharmony_ci   */
24161847f8eSopenharmony_ci  getString(columnIndex: number): string;
24261847f8eSopenharmony_ci
24361847f8eSopenharmony_ci  /**
24461847f8eSopenharmony_ci   * Obtains the value of the specified column or key in the current row as long.
24561847f8eSopenharmony_ci   * The implementation class determines whether to throw an exception if the value of the specified
24661847f8eSopenharmony_ci   * column or key in the current row is null, the specified column or key is not of the long type.
24761847f8eSopenharmony_ci   *
24861847f8eSopenharmony_ci   * @param { number } columnIndex - Indicates the specified column index or key index, which starts from 0.
24961847f8eSopenharmony_ci   * @returns { number } Returns the value of the specified column or key as a long.
25061847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
25161847f8eSopenharmony_ci   * @systemapi
25261847f8eSopenharmony_ci   * @StageModelOnly
25361847f8eSopenharmony_ci   * @since 9
25461847f8eSopenharmony_ci   */
25561847f8eSopenharmony_ci  getLong(columnIndex: number): number;
25661847f8eSopenharmony_ci
25761847f8eSopenharmony_ci  /**
25861847f8eSopenharmony_ci   * Obtains the value of the specified column or key in the current row as double.
25961847f8eSopenharmony_ci   * The implementation class determines whether to throw an exception if the value of the specified
26061847f8eSopenharmony_ci   * column or key in the current row is null, the specified column or key is not of the double type.
26161847f8eSopenharmony_ci   *
26261847f8eSopenharmony_ci   * @param { number } columnIndex - Indicates the specified column index or key index, which starts from 0.
26361847f8eSopenharmony_ci   * @returns { number } Returns the value of the specified column or key as a double.
26461847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
26561847f8eSopenharmony_ci   * @systemapi
26661847f8eSopenharmony_ci   * @StageModelOnly
26761847f8eSopenharmony_ci   * @since 9
26861847f8eSopenharmony_ci   */
26961847f8eSopenharmony_ci  getDouble(columnIndex: number): number;
27061847f8eSopenharmony_ci
27161847f8eSopenharmony_ci  /**
27261847f8eSopenharmony_ci   * Closes the result set.
27361847f8eSopenharmony_ci   * Calling this method on the result set will release all of its resources and makes it ineffective.
27461847f8eSopenharmony_ci   *
27561847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
27661847f8eSopenharmony_ci   * @systemapi
27761847f8eSopenharmony_ci   * @StageModelOnly
27861847f8eSopenharmony_ci   * @since 9
27961847f8eSopenharmony_ci   */
28061847f8eSopenharmony_ci  close(): void;
28161847f8eSopenharmony_ci
28261847f8eSopenharmony_ci  /**
28361847f8eSopenharmony_ci   * Obtains the column index or key index based on the specified column name or key name.
28461847f8eSopenharmony_ci   * The column name or key name is passed as an input parameter.
28561847f8eSopenharmony_ci   *
28661847f8eSopenharmony_ci   * @param { string } columnName - Indicates the name of the specified column or key in the result set.
28761847f8eSopenharmony_ci   * @returns { number } Returns the index of the specified column or key.
28861847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
28961847f8eSopenharmony_ci   * @systemapi
29061847f8eSopenharmony_ci   * @StageModelOnly
29161847f8eSopenharmony_ci   * @since 9
29261847f8eSopenharmony_ci   */
29361847f8eSopenharmony_ci  getColumnIndex(columnName: string): number;
29461847f8eSopenharmony_ci
29561847f8eSopenharmony_ci  /**
29661847f8eSopenharmony_ci   * Obtains the column name or key name based on the specified column index or key index.
29761847f8eSopenharmony_ci   * The column index or key index is passed as an input parameter.
29861847f8eSopenharmony_ci   *
29961847f8eSopenharmony_ci   * @param { number } columnIndex - Indicates the index of the specified column or key in the result set.
30061847f8eSopenharmony_ci   * @returns { string } Returns the name of the specified column or key.
30161847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
30261847f8eSopenharmony_ci   * @systemapi
30361847f8eSopenharmony_ci   * @StageModelOnly
30461847f8eSopenharmony_ci   * @since 9
30561847f8eSopenharmony_ci   */
30661847f8eSopenharmony_ci  getColumnName(columnIndex: number): string;
30761847f8eSopenharmony_ci
30861847f8eSopenharmony_ci  /**
30961847f8eSopenharmony_ci   * Obtains the dataType of the specified column or key.
31061847f8eSopenharmony_ci   * The implementation class determines whether to throw an exception if the value of the specified
31161847f8eSopenharmony_ci   * column or key in the current row is null, the specified column or key is not in the data type.
31261847f8eSopenharmony_ci   *
31361847f8eSopenharmony_ci   * @param { number } columnIndex - Indicates the specified column index or key index, which starts from 0.
31461847f8eSopenharmony_ci   * @returns { DataType } Returns the dataType of the specified column or key.
31561847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
31661847f8eSopenharmony_ci   * @systemapi
31761847f8eSopenharmony_ci   * @StageModelOnly
31861847f8eSopenharmony_ci   * @since 9
31961847f8eSopenharmony_ci   */
32061847f8eSopenharmony_ci  getDataType(columnIndex: number): DataType;
32161847f8eSopenharmony_ci}
322