Merge "fix bugs introduced by I3ef1bcdb2eb1c45f68e829ccb6e3ecde28076591"
This commit is contained in:
@@ -224,8 +224,6 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
|
||||
return getType(row, col) == Cursor.FIELD_TYPE_NULL;
|
||||
}
|
||||
|
||||
private native boolean isNull_native(int row, int col);
|
||||
|
||||
/**
|
||||
* Returns a byte array for the given field.
|
||||
*
|
||||
@@ -280,7 +278,8 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isBlob(int row, int col) {
|
||||
return getType(row, col) == Cursor.FIELD_TYPE_BLOB;
|
||||
int type = getType(row, col);
|
||||
return type == Cursor.FIELD_TYPE_BLOB || type == Cursor.FIELD_TYPE_NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,13 +318,10 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isString(int row, int col) {
|
||||
return getType(row, col) == Cursor.FIELD_TYPE_STRING;
|
||||
int type = getType(row, col);
|
||||
return type == Cursor.FIELD_TYPE_STRING || type == Cursor.FIELD_TYPE_NULL;
|
||||
}
|
||||
|
||||
private native boolean isBlob_native(int row, int col);
|
||||
private native boolean isString_native(int row, int col);
|
||||
private native boolean isInteger_native(int row, int col);
|
||||
private native boolean isFloat_native(int row, int col);
|
||||
private native int getType_native(int row, int col);
|
||||
|
||||
/**
|
||||
|
||||
@@ -225,70 +225,6 @@ LOG_WINDOW("Getting blob for %d,%d from %p", row, column, window);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static jboolean isBlob_native(JNIEnv* env, jobject object, jint row, jint column)
|
||||
{
|
||||
int32_t err;
|
||||
CursorWindow * window = GET_WINDOW(env, object);
|
||||
LOG_WINDOW("Checking if column is a blob or null for %d,%d from %p", row, column, window);
|
||||
|
||||
field_slot_t field;
|
||||
err = window->read_field_slot(row, column, &field);
|
||||
if (err != 0) {
|
||||
throwExceptionWithRowCol(env, row, column);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return field.type == FIELD_TYPE_BLOB || field.type == FIELD_TYPE_NULL;
|
||||
}
|
||||
|
||||
static jboolean isString_native(JNIEnv* env, jobject object, jint row, jint column)
|
||||
{
|
||||
int32_t err;
|
||||
CursorWindow * window = GET_WINDOW(env, object);
|
||||
LOG_WINDOW("Checking if column is a string or null for %d,%d from %p", row, column, window);
|
||||
|
||||
field_slot_t field;
|
||||
err = window->read_field_slot(row, column, &field);
|
||||
if (err != 0) {
|
||||
throwExceptionWithRowCol(env, row, column);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return field.type == FIELD_TYPE_STRING || field.type == FIELD_TYPE_NULL;
|
||||
}
|
||||
|
||||
static jboolean isInteger_native(JNIEnv* env, jobject object, jint row, jint column)
|
||||
{
|
||||
int32_t err;
|
||||
CursorWindow * window = GET_WINDOW(env, object);
|
||||
LOG_WINDOW("Checking if column is an integer for %d,%d from %p", row, column, window);
|
||||
|
||||
field_slot_t field;
|
||||
err = window->read_field_slot(row, column, &field);
|
||||
if (err != 0) {
|
||||
throwExceptionWithRowCol(env, row, column);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return field.type == FIELD_TYPE_INTEGER;
|
||||
}
|
||||
|
||||
static jboolean isFloat_native(JNIEnv* env, jobject object, jint row, jint column)
|
||||
{
|
||||
int32_t err;
|
||||
CursorWindow * window = GET_WINDOW(env, object);
|
||||
LOG_WINDOW("Checking if column is a float for %d,%d from %p", row, column, window);
|
||||
|
||||
field_slot_t field;
|
||||
err = window->read_field_slot(row, column, &field);
|
||||
if (err != 0) {
|
||||
throwExceptionWithRowCol(env, row, column);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return field.type == FIELD_TYPE_FLOAT;
|
||||
}
|
||||
|
||||
static jstring getString_native(JNIEnv* env, jobject object, jint row, jint column)
|
||||
{
|
||||
int32_t err;
|
||||
@@ -487,10 +423,9 @@ LOG_WINDOW("Getting double for %d,%d from %p", row, column, window);
|
||||
}
|
||||
}
|
||||
|
||||
static jboolean isNull_native(JNIEnv* env, jobject object, jint row, jint column)
|
||||
bool isNull_native(CursorWindow *window, jint row, jint column)
|
||||
{
|
||||
CursorWindow * window = GET_WINDOW(env, object);
|
||||
LOG_WINDOW("Checking for NULL at %d,%d from %p", row, column, window);
|
||||
LOG_WINDOW("Checking for NULL at %d,%d from %p", row, column, window);
|
||||
|
||||
bool isNull;
|
||||
if (window->getNull(row, column, &isNull)) {
|
||||
@@ -658,6 +593,10 @@ static jint getType_native(JNIEnv* env, jobject object, jint row, jint column)
|
||||
CursorWindow * window = GET_WINDOW(env, object);
|
||||
LOG_WINDOW("returning column type affinity for %d,%d from %p", row, column, window);
|
||||
|
||||
if (isNull_native(window, row, column)) {
|
||||
return FIELD_TYPE_NULL;
|
||||
}
|
||||
|
||||
field_slot_t field;
|
||||
err = window->read_field_slot(row, column, &field);
|
||||
if (err != 0) {
|
||||
@@ -678,11 +617,9 @@ static JNINativeMethod sMethods[] =
|
||||
{"close_native", "()V", (void *)native_close},
|
||||
{"getLong_native", "(II)J", (void *)getLong_native},
|
||||
{"getBlob_native", "(II)[B", (void *)getBlob_native},
|
||||
{"isBlob_native", "(II)Z", (void *)isBlob_native},
|
||||
{"getString_native", "(II)Ljava/lang/String;", (void *)getString_native},
|
||||
{"copyStringToBuffer_native", "(IIILandroid/database/CharArrayBuffer;)[C", (void *)copyStringToBuffer_native},
|
||||
{"getDouble_native", "(II)D", (void *)getDouble_native},
|
||||
{"isNull_native", "(II)Z", (void *)isNull_native},
|
||||
{"getNumRows_native", "()I", (void *)getNumRows},
|
||||
{"setNumColumns_native", "(I)Z", (void *)setNumColumns},
|
||||
{"allocRow_native", "()Z", (void *)allocRow},
|
||||
@@ -692,9 +629,6 @@ static JNINativeMethod sMethods[] =
|
||||
{"putDouble_native", "(DII)Z", (void *)putDouble_native},
|
||||
{"freeLastRow_native", "()V", (void *)freeLastRow},
|
||||
{"putNull_native", "(II)Z", (void *)putNull_native},
|
||||
{"isString_native", "(II)Z", (void *)isString_native},
|
||||
{"isFloat_native", "(II)Z", (void *)isFloat_native},
|
||||
{"isInteger_native", "(II)Z", (void *)isInteger_native},
|
||||
{"getType_native", "(II)I", (void *)getType_native},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user