package net.zetetic.database;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
public class CursorWindow extends net.zetetic.database.sqlcipher.SQLiteClosable {
    public static int f = 16384;
    private final int b;
    public long c;
    private int d;
    private final java.lang.String e;

    public CursorWindow(java.lang.String str) {
        this(str, okhttp3.internal.http2.Http2.INITIAL_MAX_FRAME_SIZE);
    }

    private void k() {
        long j = this.c;
        if (j != 0) {
            nativeDispose(j);
            this.c = 0L;
        }
    }

    private static native boolean nativeAllocRow(long j);

    private static native void nativeClear(long j);

    private static native long nativeCreate(java.lang.String str, int i);

    private static native void nativeDispose(long j);

    private static native void nativeFreeLastRow(long j);

    private static native byte[] nativeGetBlob(long j, int i, int i2);

    private static native double nativeGetDouble(long j, int i, int i2);

    private static native long nativeGetLong(long j, int i, int i2);

    private static native java.lang.String nativeGetName(long j);

    private static native int nativeGetNumRows(long j);

    private static native java.lang.String nativeGetString(long j, int i, int i2);

    private static native int nativeGetType(long j, int i, int i2);

    private static native boolean nativePutBlob(long j, byte[] bArr, int i, int i2);

    private static native boolean nativePutDouble(long j, double d, int i, int i2);

    private static native boolean nativePutLong(long j, long j2, int i, int i2);

    private static native boolean nativePutNull(long j, int i, int i2);

    private static native boolean nativePutString(long j, java.lang.String str, int i, int i2);

    private static native boolean nativeSetNumColumns(long j, int i);

    public long C(int i, int i2) {
        return nativeGetLong(this.c, i - this.d, i2);
    }

    public java.lang.String E() {
        return this.e;
    }

    public int G() {
        return nativeGetNumRows(this.c);
    }

    public short O(int i, int i2) {
        return (short) C(i, i2);
    }

    public int R() {
        return this.d;
    }

    public java.lang.String X(int i, int i2) {
        return nativeGetString(this.c, i - this.d, i2);
    }

    public int Y(int i, int i2) {
        return nativeGetType(this.c, i - this.d, i2);
    }

    public void a0(int i) {
        this.d = i;
    }

    public void clear() {
        this.d = 0;
        nativeClear(this.c);
    }

    @Override // net.zetetic.database.sqlcipher.SQLiteClosable
    protected void d() {
        k();
    }

    protected void finalize() throws java.lang.Throwable {
        try {
            k();
        } finally {
            super.finalize();
        }
    }

    public void i(int i, int i2, android.database.CharArrayBuffer charArrayBuffer) {
        if (charArrayBuffer == null) {
            throw new java.lang.IllegalArgumentException("CharArrayBuffer should not be null");
        }
        char[] charArray = X(i, i2).toCharArray();
        charArrayBuffer.data = charArray;
        charArrayBuffer.sizeCopied = charArray.length;
    }

    public byte[] r(int i, int i2) {
        return nativeGetBlob(this.c, i - this.d, i2);
    }

    public java.lang.String toString() {
        return E() + " {" + java.lang.Long.toHexString(this.c) + "}";
    }

    public double u(int i, int i2) {
        return nativeGetDouble(this.c, i - this.d, i2);
    }

    public float v(int i, int i2) {
        return (float) u(i, i2);
    }

    public int y(int i, int i2) {
        return (int) C(i, i2);
    }

    public CursorWindow(java.lang.String str, int i) {
        this.d = 0;
        this.b = i;
        str = (str == null || str.length() == 0) ? "<unnamed>" : str;
        this.e = str;
        long jNativeCreate = nativeCreate(str, i);
        this.c = jNativeCreate;
        if (jNativeCreate != 0) {
            return;
        }
        throw new net.zetetic.database.CursorWindowAllocationException("Cursor window allocation of " + (i / 1024) + " kb failed. ");
    }
}
