summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.xml14
-rw-r--r--core/java/android/database/AbstractCursor.java40
-rw-r--r--core/java/android/database/AbstractWindowedCursor.java130
3 files changed, 50 insertions, 134 deletions
diff --git a/api/current.xml b/api/current.xml
index dbb68f8a8eb9..55421095a9cc 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -56529,7 +56529,7 @@
synchronized="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="protected"
>
<parameter name="columnIndex" type="int">
@@ -56597,7 +56597,7 @@
synchronized="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="protected"
>
<parameter name="columnIndex" type="int">
@@ -56883,7 +56883,7 @@
volatile="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="protected"
>
</field>
@@ -57019,7 +57019,7 @@
synchronized="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<parameter name="columnIndex" type="int">
@@ -57032,7 +57032,7 @@
synchronized="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<parameter name="columnIndex" type="int">
@@ -57045,7 +57045,7 @@
synchronized="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<parameter name="columnIndex" type="int">
@@ -57071,7 +57071,7 @@
synchronized="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<parameter name="columnIndex" type="int">
diff --git a/core/java/android/database/AbstractCursor.java b/core/java/android/database/AbstractCursor.java
index 80eb18b15d8e..8434ca5c5c81 100644
--- a/core/java/android/database/AbstractCursor.java
+++ b/core/java/android/database/AbstractCursor.java
@@ -330,9 +330,9 @@ public abstract class AbstractCursor implements CrossProcessCursor {
return mDataSetObservable;
}
+
public void registerDataSetObserver(DataSetObserver observer) {
mDataSetObservable.registerObserver(observer);
-
}
public void unregisterDataSetObserver(DataSetObserver observer) {
@@ -387,36 +387,19 @@ public abstract class AbstractCursor implements CrossProcessCursor {
}
/**
- * This function returns true if the field has been updated and is
- * used in conjunction with {@link #getUpdatedField} to allow subclasses to
- * support reading uncommitted updates. NOTE: This function and
- * {@link #getUpdatedField} should be called together inside of a
- * block synchronized on mUpdatedRows.
- *
- * @param columnIndex the column index of the field to check
- * @return true if the field has been updated, false otherwise
+ * @deprecated Always returns false since Cursors do not support updating rows
*/
+ @Deprecated
protected boolean isFieldUpdated(int columnIndex) {
- if (mRowIdColumnIndex != -1 && mUpdatedRows.size() > 0) {
- Map<String, Object> updates = mUpdatedRows.get(mCurrentRowID);
- if (updates != null && updates.containsKey(getColumnNames()[columnIndex])) {
- return true;
- }
- }
return false;
}
/**
- * This function returns the uncommitted updated value for the field
- * at columnIndex. NOTE: This function and {@link #isFieldUpdated} should
- * be called together inside of a block synchronized on mUpdatedRows.
- *
- * @param columnIndex the column index of the field to retrieve
- * @return the updated value
+ * @deprecated Always returns null since Cursors do not support updating rows
*/
+ @Deprecated
protected Object getUpdatedField(int columnIndex) {
- Map<String, Object> updates = mUpdatedRows.get(mCurrentRowID);
- return updates.get(getColumnNames()[columnIndex]);
+ return null;
}
/**
@@ -466,11 +449,9 @@ public abstract class AbstractCursor implements CrossProcessCursor {
}
/**
- * This HashMap contains a mapping from Long rowIDs to another Map
- * that maps from String column names to new values. A NULL value means to
- * remove an existing value, and all numeric values are in their class
- * forms, i.e. Integer, Long, Float, etc.
+ * @deprecated This is never updated by this class and should not be used
*/
+ @Deprecated
protected HashMap<Long, Map<String, Object>> mUpdatedRows;
/**
@@ -480,6 +461,11 @@ public abstract class AbstractCursor implements CrossProcessCursor {
protected int mRowIdColumnIndex;
protected int mPos;
+ /**
+ * If {@link mRowIdColumnIndex} is not -1 this contains contains the value of
+ * the column at {@link mRowIdColumnIndex} for the current row this cursor is
+ * pointing at.
+ */
protected Long mCurrentRowID;
protected ContentResolver mContentResolver;
protected boolean mClosed = false;
diff --git a/core/java/android/database/AbstractWindowedCursor.java b/core/java/android/database/AbstractWindowedCursor.java
index e47d9ce18a24..8addaa83d090 100644
--- a/core/java/android/database/AbstractWindowedCursor.java
+++ b/core/java/android/database/AbstractWindowedCursor.java
@@ -19,175 +19,105 @@ package android.database;
/**
* A base class for Cursors that store their data in {@link CursorWindow}s.
*/
-public abstract class AbstractWindowedCursor extends AbstractCursor
-{
+public abstract class AbstractWindowedCursor extends AbstractCursor {
@Override
- public byte[] getBlob(int columnIndex)
- {
+ public byte[] getBlob(int columnIndex) {
checkPosition();
-
- synchronized(mUpdatedRows) {
- if (isFieldUpdated(columnIndex)) {
- return (byte[])getUpdatedField(columnIndex);
- }
- }
-
return mWindow.getBlob(mPos, columnIndex);
}
@Override
- public String getString(int columnIndex)
- {
+ public String getString(int columnIndex) {
checkPosition();
-
- synchronized(mUpdatedRows) {
- if (isFieldUpdated(columnIndex)) {
- return (String)getUpdatedField(columnIndex);
- }
- }
-
return mWindow.getString(mPos, columnIndex);
}
-
+
@Override
- public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer)
- {
+ public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {
checkPosition();
-
- synchronized(mUpdatedRows) {
- if (isFieldUpdated(columnIndex)) {
- super.copyStringToBuffer(columnIndex, buffer);
- }
- }
-
mWindow.copyStringToBuffer(mPos, columnIndex, buffer);
}
@Override
- public short getShort(int columnIndex)
- {
+ public short getShort(int columnIndex) {
checkPosition();
-
- synchronized(mUpdatedRows) {
- if (isFieldUpdated(columnIndex)) {
- Number value = (Number)getUpdatedField(columnIndex);
- return value.shortValue();
- }
- }
-
return mWindow.getShort(mPos, columnIndex);
}
@Override
- public int getInt(int columnIndex)
- {
+ public int getInt(int columnIndex) {
checkPosition();
-
- synchronized(mUpdatedRows) {
- if (isFieldUpdated(columnIndex)) {
- Number value = (Number)getUpdatedField(columnIndex);
- return value.intValue();
- }
- }
-
return mWindow.getInt(mPos, columnIndex);
}
@Override
- public long getLong(int columnIndex)
- {
+ public long getLong(int columnIndex) {
checkPosition();
-
- synchronized(mUpdatedRows) {
- if (isFieldUpdated(columnIndex)) {
- Number value = (Number)getUpdatedField(columnIndex);
- return value.longValue();
- }
- }
-
return mWindow.getLong(mPos, columnIndex);
}
@Override
- public float getFloat(int columnIndex)
- {
+ public float getFloat(int columnIndex) {
checkPosition();
-
- synchronized(mUpdatedRows) {
- if (isFieldUpdated(columnIndex)) {
- Number value = (Number)getUpdatedField(columnIndex);
- return value.floatValue();
- }
- }
-
return mWindow.getFloat(mPos, columnIndex);
}
@Override
- public double getDouble(int columnIndex)
- {
+ public double getDouble(int columnIndex) {
checkPosition();
-
- synchronized(mUpdatedRows) {
- if (isFieldUpdated(columnIndex)) {
- Number value = (Number)getUpdatedField(columnIndex);
- return value.doubleValue();
- }
- }
-
return mWindow.getDouble(mPos, columnIndex);
}
@Override
- public boolean isNull(int columnIndex)
- {
+ public boolean isNull(int columnIndex) {
checkPosition();
-
- synchronized(mUpdatedRows) {
- if (isFieldUpdated(columnIndex)) {
- return getUpdatedField(columnIndex) == null;
- }
- }
-
return mWindow.getType(mPos, columnIndex) == Cursor.FIELD_TYPE_NULL;
}
+ /**
+ * @deprecated Use {@link #getType}
+ */
+ @Deprecated
public boolean isBlob(int columnIndex) {
return getType(columnIndex) == Cursor.FIELD_TYPE_BLOB;
}
+ /**
+ * @deprecated Use {@link #getType}
+ */
+ @Deprecated
public boolean isString(int columnIndex) {
return getType(columnIndex) == Cursor.FIELD_TYPE_STRING;
}
+ /**
+ * @deprecated Use {@link #getType}
+ */
+ @Deprecated
public boolean isLong(int columnIndex) {
return getType(columnIndex) == Cursor.FIELD_TYPE_INTEGER;
}
+ /**
+ * @deprecated Use {@link #getType}
+ */
+ @Deprecated
public boolean isFloat(int columnIndex) {
return getType(columnIndex) == Cursor.FIELD_TYPE_FLOAT;
}
@Override
- public int getType(int columnIndex)
- {
+ public int getType(int columnIndex) {
checkPosition();
- synchronized(mUpdatedRows) {
- if (isFieldUpdated(columnIndex)) {
- return DatabaseUtils.getTypeOfObject(getUpdatedField(columnIndex));
- }
- }
-
return mWindow.getType(mPos, columnIndex);
}
@Override
- protected void checkPosition()
- {
+ protected void checkPosition() {
super.checkPosition();
if (mWindow == null) {
- throw new StaleDataException("Access closed cursor");
+ throw new StaleDataException("Attempting to access a closed cursor");
}
}