package com.yahoo.squidb.data;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;

import com.yahoo.squidb.data.SqlValidatorFactory.SqlValidator;

/*package*/ class SqlValidatorFactory {

    interface SqlValidator {

        void compileStatement(SQLiteDatabase db, String sql);
    }

    private static final SqlValidator INSTANCE;

    static {
        int version = VERSION.SDK_INT;
        if (version >= VERSION_CODES.JELLY_BEAN) {
            INSTANCE = new DefaultSqlValidator();
        } else if (version >= VERSION_CODES.ICE_CREAM_SANDWICH) {
            INSTANCE = new ReflectiveSqlValidator();
        } else {
            // included for forks that reduce minSdk below 14
            INSTANCE = new DefaultSqlValidator();
        }
    }

    private SqlValidatorFactory() {
        //no instance
    }

    static SqlValidator getValidator() {
        return INSTANCE;
    }
}

/*package*/ class DefaultSqlValidator implements SqlValidator {

    @Override
    public void compileStatement(SQLiteDatabase db, String sql) {
        db.compileStatement(sql);
    }
}

/*package*/ class ReflectiveSqlValidator implements SqlValidator {

    @Override
    public void compileStatement(SQLiteDatabase db, String sql) {
        Cursor c = db.rawQuery(sql, null);
        if (c != null) {
            c.close();
        }
    }
}

@@ -676,26 +676,19 @@
 E = new 
-Reflective
+Ics
 SqlValid
@@ -1191,18 +1191,11 @@
 ass 
-Reflective
+Ics
 SqlV

Rename to IcsSqlValidator