public class ContentProviderOperation extends Object implements Parcelable
ContentProvider.applyBatch(ArrayList)
Modifier and Type | Class and Description |
---|---|
static class |
ContentProviderOperation.Builder
Used to add parameters to a
ContentProviderOperation . |
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<ContentProviderOperation> |
CREATOR |
static int |
TYPE_ASSERT |
static int |
TYPE_DELETE |
static int |
TYPE_INSERT |
static int |
TYPE_UPDATE |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
ContentProviderOperation(ContentProviderOperation cpo,
boolean removeUserIdFromUri) |
Modifier and Type | Method and Description |
---|---|
ContentProviderResult |
apply(ContentProvider provider,
ContentProviderResult[] backRefs,
int numBackRefs)
Applies this operation using the given provider.
|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
int |
getType() |
Uri |
getUri()
Gets the Uri for the target of the operation.
|
ContentProviderOperation |
getWithoutUserIdInUri() |
boolean |
isAssertQuery()
Returns true if the operation represents an assert query.
|
boolean |
isDelete()
Returns true if the operation represents a deletion.
|
boolean |
isInsert()
Returns true if the operation represents an insertion.
|
boolean |
isReadOperation()
Returns true if the operation represents an assert query.
|
boolean |
isUpdate()
Returns true if the operation represents an update.
|
boolean |
isWriteOperation()
Returns true if the operation represents an insertion, deletion, or update.
|
boolean |
isYieldAllowed()
Returns true if the operation allows yielding the database to other transactions
if the database is contended.
|
static ContentProviderOperation.Builder |
newAssertQuery(Uri uri)
Create a
ContentProviderOperation.Builder suitable for building a
ContentProviderOperation to assert a set of values as provided
through ContentProviderOperation.Builder.withValues(ContentValues) . |
static ContentProviderOperation.Builder |
newDelete(Uri uri)
Create a
ContentProviderOperation.Builder suitable for building a delete ContentProviderOperation . |
static ContentProviderOperation.Builder |
newInsert(Uri uri)
Create a
ContentProviderOperation.Builder suitable for building an insert ContentProviderOperation . |
static ContentProviderOperation.Builder |
newUpdate(Uri uri)
Create a
ContentProviderOperation.Builder suitable for building an update ContentProviderOperation . |
String[] |
resolveSelectionArgsBackReferences(ContentProviderResult[] backRefs,
int numBackRefs)
The Selection Arguments back references are represented as a Map of Integer->Integer where
the key is an index into the selection argument array (see
ContentProviderOperation.Builder.withSelection(java.lang.String, java.lang.String[]) )
and the value is the index of the previous result that should be used for that selection
argument array slot. |
ContentValues |
resolveValueBackReferences(ContentProviderResult[] backRefs,
int numBackRefs)
The ContentValues back references are represented as a ContentValues object where the
key refers to a column and the value is an index of the back reference whose
valued should be associated with the column.
|
String |
toString()
Returns a string representation of the object.
|
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object in to a Parcel.
|
public static final int TYPE_INSERT
public static final int TYPE_UPDATE
public static final int TYPE_DELETE
public static final int TYPE_ASSERT
public static final Parcelable.Creator<ContentProviderOperation> CREATOR
public ContentProviderOperation(ContentProviderOperation cpo, boolean removeUserIdFromUri)
public ContentProviderOperation getWithoutUserIdInUri()
public void writeToParcel(Parcel dest, int flags)
Parcelable
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public static ContentProviderOperation.Builder newInsert(Uri uri)
ContentProviderOperation.Builder
suitable for building an insert ContentProviderOperation
.uri
- The Uri
that is the target of the insert.ContentProviderOperation.Builder
public static ContentProviderOperation.Builder newUpdate(Uri uri)
ContentProviderOperation.Builder
suitable for building an update ContentProviderOperation
.uri
- The Uri
that is the target of the update.ContentProviderOperation.Builder
public static ContentProviderOperation.Builder newDelete(Uri uri)
ContentProviderOperation.Builder
suitable for building a delete ContentProviderOperation
.uri
- The Uri
that is the target of the delete.ContentProviderOperation.Builder
public static ContentProviderOperation.Builder newAssertQuery(Uri uri)
ContentProviderOperation.Builder
suitable for building a
ContentProviderOperation
to assert a set of values as provided
through ContentProviderOperation.Builder.withValues(ContentValues)
.public Uri getUri()
public boolean isYieldAllowed()
SQLiteDatabase.yieldIfContendedSafely()
public int getType()
public boolean isInsert()
newInsert(android.net.Uri)
public boolean isDelete()
newDelete(android.net.Uri)
public boolean isUpdate()
newUpdate(android.net.Uri)
public boolean isAssertQuery()
newAssertQuery(android.net.Uri)
public boolean isWriteOperation()
isInsert()
,
isDelete()
,
isUpdate()
public boolean isReadOperation()
isAssertQuery()
public ContentProviderResult apply(ContentProvider provider, ContentProviderResult[] backRefs, int numBackRefs) throws OperationApplicationException
ContentProviderOperation.Builder.withValueBackReferences(ContentValues)
and
ContentProviderOperation.Builder.withSelectionBackReference(int, int)
.provider
- the ContentProvider
on which this batch is appliedbackRefs
- a ContentProviderResult
array that will be consulted
to resolve any requested back references.numBackRefs
- the number of valid results on the backRefs array.ContentProviderResult
that contains either the Uri
of the inserted
row if this was an insert otherwise the number of rows affected.OperationApplicationException
- thrown if either the insert fails or
if the number of rows affected didn't match the expected countpublic ContentValues resolveValueBackReferences(ContentProviderResult[] backRefs, int numBackRefs)
This is intended to be a private method but it is exposed for unit testing purposes
backRefs
- an array of previous resultsnumBackRefs
- the number of valid previous results in backRefspublic String[] resolveSelectionArgsBackReferences(ContentProviderResult[] backRefs, int numBackRefs)
ContentProviderOperation.Builder.withSelection(java.lang.String, java.lang.String[])
)
and the value is the index of the previous result that should be used for that selection
argument array slot.
This is intended to be a private method but it is exposed for unit testing purposes
backRefs
- an array of previous resultsnumBackRefs
- the number of valid previous results in backRefspublic String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR