<commit_before>package ec327.caffiene;


/**
 * Created by nmd1 on 12/6/2016.
 */
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;


public class StoredData {

    public static String caffineListTableName;
    public static String caffineConsumedTableName;
    public static SQLiteDatabase myDB;

    //creates the tables that store data for this program. This function should only be called once.
    //Test Input -->(coffeeData, "CoffeeListTable", "CoffeeConsumedTable")
    public static void createTables(SQLiteDatabase inputDataBase, String caffineOffered, String caffineTaken) {
        /* Create a Table in the Database. */
        //creates the types of caffine offered table
        caffineListTableName = caffineOffered;
        caffineConsumedTableName = caffineTaken;
        myDB = inputDataBase;
        //DELETE TABLE DROP ONCE TESTING IS DONE
        //myDB.execSQL("DROP TABLE IF EXISTS "+caffineConsumedTableName+";");
        //myDB.execSQL("DROP TABLE IF EXISTS "+caffineListTableName+";");

        myDB.execSQL("CREATE TABLE IF NOT EXISTS "
                + caffineOffered+"(ID INTEGER PRIMARY KEY AUTOINCREMENT, Name CHAR(50), caffineContent INT);");
        //this creates the caffineconsumed table in the database. int index can be whatever number: it was used so that the function can be overrided
        myDB.execSQL("CREATE TABLE IF NOT EXISTS "
                + caffineTaken+"(ID INTEGER PRIMARY KEY AUTOINCREMENT, Name CHAR(50), Caffine INT, TimeConsumed FLOAT);");
        StoredData.addDefaultCaffineList();
        database.addDrinktoDB(6,HomePage.now);
        //"id" is the index value
    }


    public static void addData(String name, int caffineContent) {
        /* Insert data to a Table*/
        myDB.execSQL("INSERT INTO "
                + caffineListTableName
                + " (Name, caffineContent)"
                + " VALUES ('"+name+"', "+caffineContent+");");
    }

    public static void addData(String name, int CaffineAmount, double timeOfConsumtion) {
        /* Insert data to a Table*/
        myDB.execSQL("INSERT INTO "
                + caffineConsumedTableName
                + " (Name, Caffine, TimeConsumed)"
                + " VALUES ('"+name+"', "+CaffineAmount+", "+timeOfConsumtion+");");
    }


    //helper function: gets called through addDrinktoDB(int drinkindex, float time) in the database file
    public static void selectCaffine(int index, double time) {

        //I want this row from caffine list table
        int id = index + 1;
        Cursor c = myDB.rawQuery("SELECT * FROM " + caffineListTableName + " WHERE ID="+id+";", null);
        int Column1 = c.getColumnIndex("Name");<commit_msg>Removed initial drink<commit_after>package ec327.caffiene;


/**
 * Created by nmd1 on 12/6/2016.
 */
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;


public class StoredData {

    public static String caffineListTableName;
    public static String caffineConsumedTableName;
    public static SQLiteDatabase myDB;

    //creates the tables that store data for this program. This function should only be called once.
    //Test Input -->(coffeeData, "CoffeeListTable", "CoffeeConsumedTable")
    public static void createTables(SQLiteDatabase inputDataBase, String caffineOffered, String caffineTaken) {
        /* Create a Table in the Database. */
        //creates the types of caffine offered table
        caffineListTableName = caffineOffered;
        caffineConsumedTableName = caffineTaken;
        myDB = inputDataBase;
        //DELETE TABLE DROP ONCE TESTING IS DONE
        //myDB.execSQL("DROP TABLE IF EXISTS "+caffineConsumedTableName+";");
        //myDB.execSQL("DROP TABLE IF EXISTS "+caffineListTableName+";");

        myDB.execSQL("CREATE TABLE IF NOT EXISTS "
                + caffineOffered+"(ID INTEGER PRIMARY KEY AUTOINCREMENT, Name CHAR(50), caffineContent INT);");
        //this creates the caffineconsumed table in the database. int index can be whatever number: it was used so that the function can be overrided
        myDB.execSQL("CREATE TABLE IF NOT EXISTS "
                + caffineTaken+"(ID INTEGER PRIMARY KEY AUTOINCREMENT, Name CHAR(50), Caffine INT, TimeConsumed FLOAT);");
        StoredData.addDefaultCaffineList();
        //database.addDrinktoDB(6,HomePage.now);
        //"id" is the index value
    }


    public static void addData(String name, int caffineContent) {
        /* Insert data to a Table*/
        myDB.execSQL("INSERT INTO "
                + caffineListTableName
                + " (Name, caffineContent)"
                + " VALUES ('"+name+"', "+caffineContent+");");
    }

    public static void addData(String name, int CaffineAmount, double timeOfConsumtion) {
        /* Insert data to a Table*/
        myDB.execSQL("INSERT INTO "
                + caffineConsumedTableName
                + " (Name, Caffine, TimeConsumed)"
                + " VALUES ('"+name+"', "+CaffineAmount+", "+timeOfConsumtion+");");
    }


    //helper function: gets called through addDrinktoDB(int drinkindex, float time) in the database file
    public static void selectCaffine(int index, double time) {

        //I want this row from caffine list table
        int id = index + 1;
        Cursor c = myDB.rawQuery("SELECT * FROM " + caffineListTableName + " WHERE ID="+id+";", null);
        int Column1 = c.getColumnIndex("Name");
{'fraction_non_alphanumeric': 0.0991615020051039, 'fraction_numerical': 0.006562158220925993, 'mean_word_length': 2.8451296426068677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5625699', 'n_tokens_mistral': 1669, 'n_tokens_neox': 1572, 'n_words': 485}