package com.zlm.hp.db.dao;

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

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.zlm.hp.entity.VideoInfo;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "VIDEO_INFO".
*/
public class VideoInfoDao extends AbstractDao<VideoInfo, Void> {

    public static final String TABLENAME = "VIDEO_INFO";

    /**
     * Properties of entity VideoInfo.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Hash = new Property(0, String.class, "hash", false, "HASH");
        public final static Property FileExt = new Property(1, String.class, "fileExt", false, "FILE_EXT");
        public final static Property FileSize = new Property(2, long.class, "fileSize", false, "FILE_SIZE");
        public final static Property FileSizeText = new Property(3, String.class, "fileSizeText", false, "FILE_SIZE_TEXT");
        public final static Property FilePath = new Property(4, String.class, "filePath", false, "FILE_PATH");
        public final static Property Duration = new Property(5, long.class, "duration", false, "DURATION");
        public final static Property DurationText = new Property(6, String.class, "durationText", false, "DURATION_TEXT");
        public final static Property MvName = new Property(7, String.class, "mvName", false, "MV_NAME");
        public final static Property SingerName = new Property(8, String.class, "singerName", false, "SINGER_NAME");
        public final static Property ImageUrl = new Property(9, String.class, "imageUrl", false, "IMAGE_URL");
        public final static Property DownloadUrl = new Property(10, String.class, "downloadUrl", false, "DOWNLOAD_URL");
        public final static Property Status = new Property(11, int.class, "status", false, "STATUS");
    }


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

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"VIDEO_INFO\" (" + //
                "\"HASH\" TEXT," + // 0: hash
                "\"FILE_EXT\" TEXT," + // 1: fileExt
                "\"FILE_SIZE\" INTEGER NOT NULL ," + // 2: fileSize
                "\"FILE_SIZE_TEXT\" TEXT," + // 3: fileSizeText
                "\"FILE_PATH\" TEXT," + // 4: filePath
                "\"DURATION\" INTEGER NOT NULL ," + // 5: duration
                "\"DURATION_TEXT\" TEXT," + // 6: durationText
                "\"MV_NAME\" TEXT," + // 7: mvName
                "\"SINGER_NAME\" TEXT," + // 8: singerName
                "\"IMAGE_URL\" TEXT," + // 9: imageUrl
                "\"DOWNLOAD_URL\" TEXT," + // 10: downloadUrl
                "\"STATUS\" INTEGER NOT NULL );"); // 11: status
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, VideoInfo entity) {
        stmt.clearBindings();
 
        String hash = entity.getHash();
        if (hash != null) {
            stmt.bindString(1, hash);
        }
 
        String fileExt = entity.getFileExt();
        if (fileExt != null) {
            stmt.bindString(2, fileExt);
        }
        stmt.bindLong(3, entity.getFileSize());
 
        String fileSizeText = entity.getFileSizeText();
        if (fileSizeText != null) {
            stmt.bindString(4, fileSizeText);
        }
 
        String filePath = entity.getFilePath();
        if (filePath != null) {
            stmt.bindString(5, filePath);
        }
        stmt.bindLong(6, entity.getDuration());
 
        String durationText = entity.getDurationText();
        if (durationText != null) {
            stmt.bindString(7, durationText);
        }
 
        String mvName = entity.getMvName();
        if (mvName != null) {
            stmt.bindString(8, mvName);
        }
 
        String singerName = entity.getSingerName();
        if (singerName != null) {
            stmt.bindString(9, singerName);
        }
 
        String imageUrl = entity.getImageUrl();
        if (imageUrl != null) {
            stmt.bindString(10, imageUrl);
        }
 
        String downloadUrl = entity.getDownloadUrl();
        if (downloadUrl != null) {
            stmt.bindString(11, downloadUrl);
        }
        stmt.bindLong(12, entity.getStatus());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, VideoInfo entity) {
        stmt.clearBindings();
 
        String hash = entity.getHash();
        if (hash != null) {
            stmt.bindString(1, hash);
        }
 
        String fileExt = entity.getFileExt();
        if (fileExt != null) {
            stmt.bindString(2, fileExt);
        }
        stmt.bindLong(3, entity.getFileSize());
 
        String fileSizeText = entity.getFileSizeText();
        if (fileSizeText != null) {
            stmt.bindString(4, fileSizeText);
        }
 
        String filePath = entity.getFilePath();
        if (filePath != null) {
            stmt.bindString(5, filePath);
        }
        stmt.bindLong(6, entity.getDuration());
 
        String durationText = entity.getDurationText();
        if (durationText != null) {
            stmt.bindString(7, durationText);
        }
 
        String mvName = entity.getMvName();
        if (mvName != null) {
            stmt.bindString(8, mvName);
        }
 
        String singerName = entity.getSingerName();
        if (singerName != null) {
            stmt.bindString(9, singerName);
        }
 
        String imageUrl = entity.getImageUrl();
        if (imageUrl != null) {
            stmt.bindString(10, imageUrl);
        }
 
        String downloadUrl = entity.getDownloadUrl();
        if (downloadUrl != null) {
            stmt.bindString(11, downloadUrl);
        }
        stmt.bindLong(12, entity.getStatus());
    }

    @Override
    public Void readKey(Cursor cursor, int offset) {
        return null;
    }    

    @Override
    public VideoInfo readEntity(Cursor cursor, int offset) {
        VideoInfo entity = new VideoInfo();
        readEntity(cursor, entity, offset);
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, VideoInfo entity, int offset) {
        entity.setHash(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setFileExt(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setFileSize(cursor.getLong(offset + 2));
        entity.setFileSizeText(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setFilePath(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setDuration(cursor.getLong(offset + 5));
        entity.setDurationText(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setMvName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setSingerName(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setImageUrl(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setDownloadUrl(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setStatus(cursor.getInt(offset + 11));
     }
    
    @Override
    protected final Void updateKeyAfterInsert(VideoInfo entity, long rowId) {
        // Unsupported or missing PK type
        return null;
    }
    
    @Override
    public Void getKey(VideoInfo entity) {
        return null;
    }

    @Override
    public boolean hasKey(VideoInfo entity) {
        // TODO
        return false;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
