package com.tofly.data.sql.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.tofly.ghrq_route.module.sketch.domain.SketchBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "DB_MY_SKETCH_BEAN".
*/
public class SketchBeanDao extends AbstractDao<SketchBean, String> {

    public static final String TABLENAME = "DB_MY_SKETCH_BEAN";

    /**
     * Properties of entity SketchBean.<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 Caption = new Property(1, String.class, "caption", false, "CAPTION");
        public final static Property Content = new Property(2, String.class, "content", false, "CONTENT");
        public final static Property Createdate = new Property(3, String.class, "createdate", false, "CREATEDATE");
        public final static Property Handledate = new Property(4, String.class, "handledate", false, "HANDLEDATE");
        public final static Property Address = new Property(5, String.class, "address", false, "ADDRESS");
        public final static Property Longitude = new Property(6, double.class, "longitude", false, "LONGITUDE");
        public final static Property Latitude = new Property(7, double.class, "latitude", false, "LATITUDE");
        public final static Property X = new Property(8, double.class, "x", false, "X");
        public final static Property Y = new Property(9, double.class, "y", false, "Y");
        public final static Property Wkid = new Property(10, int.class, "wkid", false, "WKID");
        public final static Property Scale = new Property(11, double.class, "scale", false, "SCALE");
        public final static Property Status = new Property(12, int.class, "status", false, "STATUS");
        public final static Property Filepath = new Property(13, String.class, "filepath", false, "FILEPATH");
        public final static Property Fileid = new Property(14, String.class, "fileid", false, "FILEID");
        public final static Property Userid = new Property(15, String.class, "userid", false, "USERID");
        public final static Property Commit_status = new Property(16, int.class, "commit_status", false, "COMMIT_STATUS");
    }


    public SketchBeanDao(DaoConfig config) {
        super(config);
    }
    
    public SketchBeanDao(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 + "\"DB_MY_SKETCH_BEAN\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"CAPTION\" TEXT," + // 1: caption
                "\"CONTENT\" TEXT," + // 2: content
                "\"CREATEDATE\" TEXT," + // 3: createdate
                "\"HANDLEDATE\" TEXT," + // 4: handledate
                "\"ADDRESS\" TEXT," + // 5: address
                "\"LONGITUDE\" REAL NOT NULL ," + // 6: longitude
                "\"LATITUDE\" REAL NOT NULL ," + // 7: latitude
                "\"X\" REAL NOT NULL ," + // 8: x
                "\"Y\" REAL NOT NULL ," + // 9: y
                "\"WKID\" INTEGER NOT NULL ," + // 10: wkid
                "\"SCALE\" REAL NOT NULL ," + // 11: scale
                "\"STATUS\" INTEGER NOT NULL ," + // 12: status
                "\"FILEPATH\" TEXT," + // 13: filepath
                "\"FILEID\" TEXT," + // 14: fileid
                "\"USERID\" TEXT," + // 15: userid
                "\"COMMIT_STATUS\" INTEGER NOT NULL );"); // 16: commit_status
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, SketchBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String caption = entity.getCaption();
        if (caption != null) {
            stmt.bindString(2, caption);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(3, content);
        }
 
        String createdate = entity.getCreatedate();
        if (createdate != null) {
            stmt.bindString(4, createdate);
        }
 
        String handledate = entity.getHandledate();
        if (handledate != null) {
            stmt.bindString(5, handledate);
        }
 
        String address = entity.getAddress();
        if (address != null) {
            stmt.bindString(6, address);
        }
        stmt.bindDouble(7, entity.getLongitude());
        stmt.bindDouble(8, entity.getLatitude());
        stmt.bindDouble(9, entity.getX());
        stmt.bindDouble(10, entity.getY());
        stmt.bindLong(11, entity.getWkid());
        stmt.bindDouble(12, entity.getScale());
        stmt.bindLong(13, entity.getStatus());
 
        String filepath = entity.getFilepath();
        if (filepath != null) {
            stmt.bindString(14, filepath);
        }
 
        String fileid = entity.getFileid();
        if (fileid != null) {
            stmt.bindString(15, fileid);
        }
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(16, userid);
        }
        stmt.bindLong(17, entity.getCommit_status());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, SketchBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String caption = entity.getCaption();
        if (caption != null) {
            stmt.bindString(2, caption);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(3, content);
        }
 
        String createdate = entity.getCreatedate();
        if (createdate != null) {
            stmt.bindString(4, createdate);
        }
 
        String handledate = entity.getHandledate();
        if (handledate != null) {
            stmt.bindString(5, handledate);
        }
 
        String address = entity.getAddress();
        if (address != null) {
            stmt.bindString(6, address);
        }
        stmt.bindDouble(7, entity.getLongitude());
        stmt.bindDouble(8, entity.getLatitude());
        stmt.bindDouble(9, entity.getX());
        stmt.bindDouble(10, entity.getY());
        stmt.bindLong(11, entity.getWkid());
        stmt.bindDouble(12, entity.getScale());
        stmt.bindLong(13, entity.getStatus());
 
        String filepath = entity.getFilepath();
        if (filepath != null) {
            stmt.bindString(14, filepath);
        }
 
        String fileid = entity.getFileid();
        if (fileid != null) {
            stmt.bindString(15, fileid);
        }
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(16, userid);
        }
        stmt.bindLong(17, entity.getCommit_status());
    }

    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.getString(offset + 0);
    }    

    @Override
    public SketchBean readEntity(Cursor cursor, int offset) {
        SketchBean entity = new SketchBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // caption
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // content
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createdate
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // handledate
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // address
            cursor.getDouble(offset + 6), // longitude
            cursor.getDouble(offset + 7), // latitude
            cursor.getDouble(offset + 8), // x
            cursor.getDouble(offset + 9), // y
            cursor.getInt(offset + 10), // wkid
            cursor.getDouble(offset + 11), // scale
            cursor.getInt(offset + 12), // status
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // filepath
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // fileid
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // userid
            cursor.getInt(offset + 16) // commit_status
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, SketchBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setCaption(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setContent(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCreatedate(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setHandledate(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setAddress(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setLongitude(cursor.getDouble(offset + 6));
        entity.setLatitude(cursor.getDouble(offset + 7));
        entity.setX(cursor.getDouble(offset + 8));
        entity.setY(cursor.getDouble(offset + 9));
        entity.setWkid(cursor.getInt(offset + 10));
        entity.setScale(cursor.getDouble(offset + 11));
        entity.setStatus(cursor.getInt(offset + 12));
        entity.setFilepath(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setFileid(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setUserid(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setCommit_status(cursor.getInt(offset + 16));
     }
    
    @Override
    protected final String updateKeyAfterInsert(SketchBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(SketchBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(SketchBean entity) {
        throw new UnsupportedOperationException("Unsupported for entities with a non-null key");
    }

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