public static class DataAbilityOperation.Builder extends Object
DataAbilityOperation.SystemCapability.Aafwk#ABILITY| 限定符和类型 | 方法 | 说明 |
|---|---|---|
DataAbilityOperation |
build() |
Creates a
DataAbilityOperation object. |
DataAbilityOperation.Builder |
withExpectedCount(int count) |
Sets the expected number of rows to update ,delete or assert query.
|
DataAbilityOperation.Builder |
withInterruptionAllowed(boolean interrupted) |
Sets an interrupt flag bit for a batch operation, which can be insert, update, delete, or assert.
|
DataAbilityOperation.Builder |
withPredicates(DataAbilityPredicates predicates) |
Sets filter criteria used for deleting updating or assert query data.
|
DataAbilityOperation.Builder |
withPredicatesBackReference(int requestArgIndex,
int previousResult) |
Adds a back reference to be used as a filter criterion in
withPredicates(ohos.data.dataability.DataAbilityPredicates). |
DataAbilityOperation.Builder |
withValueBackReferences(ValuesBucket backReferences) |
Adds a back reference to be used in
withValuesBucket(ohos.data.rdb.ValuesBucket). |
DataAbilityOperation.Builder |
withValuesBucket(ValuesBucket values) |
Sets the data records to be inserted or updated.
|
public DataAbilityOperation build()
DataAbilityOperation object.DataAbilityOperation object.IllegalArgumentException - Throws this exception if mType or mValuesBucket is invalid.public DataAbilityOperation.Builder withValuesBucket(ValuesBucket values)
This method can be called only by the insert or update operation.
values - Indicates the data values to be set.DataAbilityOperation.Builder object containing the given values
parameter.IllegalArgumentException - Throws this exception if mType is invalid.public DataAbilityOperation.Builder withPredicates(DataAbilityPredicates predicates)
This method can be called only by the update or delete operation.
predicates - Indicates the filter criteria to set. If this parameter is null, all data records
will be operated by default.IllegalArgumentException - Throws this exception if mType is invalid.public DataAbilityOperation.Builder withExpectedCount(int count)
This method can be called only by the update or delete operation.
count - Indicates the expected number of rows to update or delete.DataAbilityOperation.Builder object containing the given count parameter.IllegalArgumentException - Throws this exception if mType is invalid.public DataAbilityOperation.Builder withPredicatesBackReference(int requestArgIndex, int previousResult)
withPredicates(ohos.data.dataability.DataAbilityPredicates).
This method can be used only for update, delete, and assert operations.
This method will replace specific data in the predicate parameter array specified in
withPredicates(ohos.data.dataability.DataAbilityPredicates) based on the values of requestArgIndex
and previousResult in this method. The data will be replaced by
a DataAbilityResult obtained after an operation created by
DataAbilityOperation.Builder is complete.
requestArgIndex - Indicates the index referencing the predicate parameter whose value is to be replaced.previousResult - Indicates the index referencing the historical
DataAbilityResult used to replace
the value of the specified predicate parameter.DataAbilityOperation.Builder object containing the given
requestArgIndex and previousResult parameters.IllegalArgumentException - Throws this exception if mType is invalid.public DataAbilityOperation.Builder withValueBackReferences(ValuesBucket backReferences)
withValuesBucket(ohos.data.rdb.ValuesBucket).
This method can be used only for insert, update, and assert operations.
This method will replace specific values specified in withValuesBucket(ohos.data.rdb.ValuesBucket)
using the specified DataAbilityResult obtained after an operation
created by DataAbilityOperation.Builder is complete.
backReferences - Indicates the ValuesBucket object containing
a set of key-value pairs. In each pair, the key specifies the value to be updated
and the value specifies the index referencing the
DataAbilityResult used to replace
the specified value. This parameter cannot be null.DataAbilityOperation.Builder object containing
the given backReferences parameter.IllegalArgumentException - Throws this exception if mType is invalid.public DataAbilityOperation.Builder withInterruptionAllowed(boolean interrupted)
You can override the Ability#executeBatch(ArrayList) method in your Data ability class to
check whether the interrupted flag bit allows operation interruption.
If operation interruption is allowed, you can then call the
RdbStore.giveConnectionTemporarily(long) method to release the connection to
the database, thereby allowing other operations to access the database.
interrupted - Specifies whether a batch operation can be interrupted. The value true
indicates that the operation can be interrupted, and false indicates the opposite.DataAbilityOperation.Builder object containing
the given interrupted parameter.IllegalArgumentException - Throws this exception if mType is invalid.