LiveAlertDao.java 6.5 KB
package com.cmcc.migutvtwo.dao;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;

import com.cmcc.migutvtwo.dao.LiveAlert;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table LIVE_ALERT.
*/
public class LiveAlertDao extends AbstractDao<LiveAlert, String> {

    public static final String TABLENAME = "LIVE_ALERT";

    /**
     * Properties of entity LiveAlert.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Id = new Property(0, String.class, "id", true, "ID");
        public final static Property Num = new Property(1, String.class, "num", false, "NUM");
        public final static Property Date = new Property(2, String.class, "date", false, "DATE");
        public final static Property Time = new Property(3, String.class, "time", false, "TIME");
        public final static Property Title = new Property(4, String.class, "title", false, "TITLE");
        public final static Property Contid = new Property(5, String.class, "contid", false, "CONTID");
        public final static Property LiveName = new Property(6, String.class, "liveName", false, "LIVE_NAME");
        public final static Property Extend1 = new Property(7, String.class, "extend1", false, "EXTEND1");
        public final static Property Alert_time = new Property(8, java.util.Date.class, "alert_time", false, "ALERT_TIME");
    };


    public LiveAlertDao(DaoConfig config) {
        super(config);
    }
    
    public LiveAlertDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "'LIVE_ALERT' (" + //
                "'ID' TEXT PRIMARY KEY NOT NULL ," + // 0: id
                "'NUM' TEXT," + // 1: num
                "'DATE' TEXT," + // 2: date
                "'TIME' TEXT," + // 3: time
                "'TITLE' TEXT," + // 4: title
                "'CONTID' TEXT," + // 5: contid
                "'LIVE_NAME' TEXT," + // 6: liveName
                "'EXTEND1' TEXT," + // 7: extend1
                "'ALERT_TIME' INTEGER);"); // 8: alert_time
    }

    /** Drops the underlying database table. */
    public static void dropTable(SQLiteDatabase db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'LIVE_ALERT'";
        db.execSQL(sql);
    }

    /** @inheritdoc */
    @Override
    protected void bindValues(SQLiteStatement stmt, LiveAlert entity) {
        stmt.clearBindings();
 
        String id = entity.getId();
        if (id != null) {
            stmt.bindString(1, id);
        }
 
        String num = entity.getNum();
        if (num != null) {
            stmt.bindString(2, num);
        }
 
        String date = entity.getDate();
        if (date != null) {
            stmt.bindString(3, date);
        }
 
        String time = entity.getTime();
        if (time != null) {
            stmt.bindString(4, time);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(5, title);
        }
 
        String contid = entity.getContid();
        if (contid != null) {
            stmt.bindString(6, contid);
        }
 
        String liveName = entity.getLiveName();
        if (liveName != null) {
            stmt.bindString(7, liveName);
        }
 
        String extend1 = entity.getExtend1();
        if (extend1 != null) {
            stmt.bindString(8, extend1);
        }
 
        java.util.Date alert_time = entity.getAlert_time();
        if (alert_time != null) {
            stmt.bindLong(9, alert_time.getTime());
        }
    }

    /** @inheritdoc */
    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0);
    }    

    /** @inheritdoc */
    @Override
    public LiveAlert readEntity(Cursor cursor, int offset) {
        LiveAlert entity = new LiveAlert( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // num
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // date
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // time
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // title
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // contid
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // liveName
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // extend1
            cursor.isNull(offset + 8) ? null : new java.util.Date(cursor.getLong(offset + 8)) // alert_time
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, LiveAlert entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setNum(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setTitle(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setContid(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setLiveName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setExtend1(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setAlert_time(cursor.isNull(offset + 8) ? null : new java.util.Date(cursor.getLong(offset + 8)));
     }
    
    /** @inheritdoc */
    @Override
    protected String updateKeyAfterInsert(LiveAlert entity, long rowId) {
        return entity.getId();
    }
    
    /** @inheritdoc */
    @Override
    public String getKey(LiveAlert entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    /** @inheritdoc */
    @Override    
    protected boolean isEntityUpdateable() {
        return true;
    }
    
}