package com.codingbingo.fastreader.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;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "BOOK".
*/
public class BookDao extends AbstractDao<Book, Long> {
public static final String TABLENAME = "BOOK";
/**
* Properties of entity Book.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property BookName = new Property(1, String.class, "bookName", false, "BOOK_NAME");
public final static Property BookImagePath = new Property(2, String.class, "bookImagePath", false, "BOOK_IMAGE_PATH");
public final static Property Description = new Property(3, String.class, "description", false, "DESCRIPTION");
public final static Property Tags = new Property(4, String.class, "tags", false, "TAGS");
public final static Property Writer = new Property(5, String.class, "writer", false, "WRITER");
public final static Property CharSet = new Property(6, String.class, "charSet", false, "CHAR_SET");
public final static Property BookPath = new Property(7, String.class, "bookPath", false, "BOOK_PATH");
public final static Property CurrentChapter = new Property(8, Integer.class, "currentChapter", false, "CURRENT_CHAPTER");
public final static Property CurrentPosition = new Property(9, Integer.class, "currentPosition", false, "CURRENT_POSITION");
public final static Property ProcessStatus = new Property(10, int.class, "processStatus", false, "PROCESS_STATUS");
}
public BookDao(DaoConfig config) {
super(config);
}
public BookDao(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 + "\"BOOK\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"BOOK_NAME\" TEXT NOT NULL ," + // 1: bookName
"\"BOOK_IMAGE_PATH\" TEXT," + // 2: bookImagePath
"\"DESCRIPTION\" TEXT," + // 3: description
"\"TAGS\" TEXT," + // 4: tags
"\"WRITER\" TEXT," + // 5: writer
"\"CHAR_SET\" TEXT," + // 6: charSet
"\"BOOK_PATH\" TEXT," + // 7: bookPath
"\"CURRENT_CHAPTER\" INTEGER," + // 8: currentChapter
"\"CURRENT_POSITION\" INTEGER," + // 9: currentPosition
"\"PROCESS_STATUS\" INTEGER NOT NULL );"); // 10: processStatus
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"BOOK\"";
db.execSQL(sql);
}
@Override
protected final void bindValues(DatabaseStatement stmt, Book entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindString(2, entity.getBookName());
String bookImagePath = entity.getBookImagePath();
if (bookImagePath != null) {
stmt.bindString(3, bookImagePath);
}
String description = entity.getDescription();
if (description != null) {
stmt.bindString(4, description);
}
String tags = entity.getTags();
if (tags != null) {
stmt.bindString(5, tags);
}
String writer = entity.getWriter();
if (writer != null) {
stmt.bindString(6, writer);
}
String charSet = entity.getCharSet();
if (charSet != null) {
stmt.bindString(7, charSet);
}
String bookPath = entity.getBookPath();
if (bookPath != null) {
stmt.bindString(8, bookPath);
}
Integer currentChapter = entity.getCurrentChapter();
if (currentChapter != null) {
stmt.bindLong(9, currentChapter);
}
Integer currentPosition = entity.getCurrentPosition();
if (currentPosition != null) {
stmt.bindLong(10, currentPosition);
}
stmt.bindLong(11, entity.getProcessStatus());
}
@Override
protected final void bindValues(SQLiteStatement stmt, Book entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindString(2, entity.getBookName());
String bookImagePath = entity.getBookImagePath();
if (bookImagePath != null) {
stmt.bindString(3, bookImagePath);
}
String description = entity.getDescription();
if (description != null) {
stmt.bindString(4, description);
}
String tags = entity.getTags();
if (tags != null) {
stmt.bindString(5, tags);
}
String writer = entity.getWriter();
if (writer != null) {
stmt.bindString(6, writer);
}
String charSet = entity.getCharSet();
if (charSet != null) {
stmt.bindString(7, charSet);
}
String bookPath = entity.getBookPath();
if (bookPath != null) {
stmt.bindString(8, bookPath);
}
Integer currentChapter = entity.getCurrentChapter();
if (currentChapter != null) {
stmt.bindLong(9, currentChapter);
}
Integer currentPosition = entity.getCurrentPosition();
if (currentPosition != null) {
stmt.bindLong(10, currentPosition);
}
stmt.bindLong(11, entity.getProcessStatus());
}
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
@Override
public Book readEntity(Cursor cursor, int offset) {
Book entity = new Book( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.getString(offset + 1), // bookName
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // bookImagePath
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // description
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // tags
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // writer
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // charSet
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // bookPath
cursor.isNull(offset + 8) ? null : cursor.getInt(offset + 8), // currentChapter
cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9), // currentPosition
cursor.getInt(offset + 10) // processStatus
);
return entity;
}
@Override
public void readEntity(Cursor cursor, Book entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setBookName(cursor.getString(offset + 1));
entity.setBookImagePath(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setDescription(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setTags(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setWriter(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
entity.setCharSet(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
entity.setBookPath(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
entity.setCurrentChapter(cursor.isNull(offset + 8) ? null : cursor.getInt(offset + 8));
entity.setCurrentPosition(cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9));
entity.setProcessStatus(cursor.getInt(offset + 10));
}
@Override
protected final Long updateKeyAfterInsert(Book entity, long rowId) {
entity.setId(rowId);
return rowId;
}
@Override
public Long getKey(Book entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
@Override
public boolean hasKey(Book entity) {
return entity.getId() != null;
}
@Override
protected final boolean isEntityUpdateable() {
return true;
}
}