Android Open Source - android-orm-benchmark Message






From Project

Back to project page android-orm-benchmark.

License

The source code is released under:

Apache License

If you think the Android project android-orm-benchmark listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.littleinc.orm_benchmark.sqlite;
/*from w  w  w. java 2  s.  co m*/
import java.util.List;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.provider.BaseColumns;

public class Message {

    public static final String TABLE_NAME = "message";

    public static final String CONTENT = "content";

    public static final String READERS = "readers";

    public static final String SORTED_BY = "sorted_by";

    public static final String CLIENT_ID = "client_id";

    public static final String SENDER_ID = "sender_id";

    public static final String CHANNEL_ID = "channel_id";

    public static final String COMMAND_ID = "command_id";

    public static final String CREATED_AT = "created_at";

    private long mId;

    private long mClientId;

    private long mCommandId;

    private double mSortedBy;

    private int mCreatedAt;

    private String mContent;

    private long mSenderId;

    private long mChannelId;

    private List<User> mReaders;

    public static final String[] PROJECTION = new String[] { CONTENT,
            SORTED_BY, CLIENT_ID, SENDER_ID, CHANNEL_ID, COMMAND_ID, CREATED_AT };

    public static void createTable(DataBaseHelper helper) {
        SQLiteDatabase db = helper.getWritableDatabase();

        db.execSQL(new StringBuilder("CREATE TABLE '").append(TABLE_NAME)
                .append("' ('").append(BaseColumns._ID)
                .append("' INTEGER PRIMARY KEY AUTOINCREMENT, '")
                .append(CLIENT_ID).append("' INTEGER, '").append(SORTED_BY)
                .append("' REAL, '").append(CREATED_AT).append("' INTEGER, '")
                .append(CONTENT).append("' TEXT, '").append(SENDER_ID)
                .append("' INTEGER NOT NULL, '").append(CHANNEL_ID)
                .append("' INTEGER NOT NULL, '").append(COMMAND_ID)
                .append("' INTEGER);").toString());

        db.execSQL(new StringBuilder("CREATE INDEX IDX_MESSAGE_COMMAND_ID ON ")
                .append(TABLE_NAME).append(" (").append(COMMAND_ID)
                .append(");").toString());
    }

    public static void dropTable(DataBaseHelper helper) {
        SQLiteDatabase db = helper.getWritableDatabase();

        db.execSQL(new StringBuilder("DROP TABLE '").append(TABLE_NAME)
                .append("';").toString());
    }

    public long getId() {
        return mId;
    }

    public void setId(long id) {
        this.mId = id;
    }

    public long getClientId() {
        return mClientId;
    }

    public void setClientId(long clientId) {
        this.mClientId = clientId;
    }

    public long getCommandId() {
        return mCommandId;
    }

    public void setCommandId(long commandId) {
        this.mCommandId = commandId;
    }

    public double getSortedBy() {
        return mSortedBy;
    }

    public void setSortedBy(double sortedBy) {
        this.mSortedBy = sortedBy;
    }

    public int getCreatedAt() {
        return mCreatedAt;
    }

    public void setCreatedAt(int createdAt) {
        this.mCreatedAt = createdAt;
    }

    public String getContent() {
        return mContent;
    }

    public void setContent(String content) {
        this.mContent = content;
    }

    public long getSenderId() {
        return mSenderId;
    }

    public void setSenderId(long senderId) {
        this.mSenderId = senderId;
    }

    public long getChannelId() {
        return mChannelId;
    }

    public void setChannelId(long channelId) {
        this.mChannelId = channelId;
    }

    public void setReaders(List<User> readers) {
        mReaders = readers;
    }

    public List<User> getReaders() {
        return mReaders;
    }

    public boolean hasReaders() {
        return mReaders != null && !mReaders.isEmpty();
    }

    public ContentValues prepareForInsert() {
        ContentValues contentValues = new ContentValues();
        contentValues.put(CONTENT, mContent);
        contentValues.put(SORTED_BY, mSortedBy);
        contentValues.put(CLIENT_ID, mClientId);
        contentValues.put(SENDER_ID, mSenderId);
        contentValues.put(CHANNEL_ID, mChannelId);
        contentValues.put(COMMAND_ID, mCommandId);
        contentValues.put(CREATED_AT, mCreatedAt);
        return contentValues;
    }
}




Java Source Code List

com.littleinc.orm_benchmark.Application.java
com.littleinc.orm_benchmark.BenchmarkExecutable.java
com.littleinc.orm_benchmark.MainActivity.java
com.littleinc.orm_benchmark.greendao.DaoMaster.java
com.littleinc.orm_benchmark.greendao.DaoSession.java
com.littleinc.orm_benchmark.greendao.DataBaseHelper.java
com.littleinc.orm_benchmark.greendao.Generator.java
com.littleinc.orm_benchmark.greendao.GreenDaoExecutor.java
com.littleinc.orm_benchmark.greendao.MessageDao.java
com.littleinc.orm_benchmark.greendao.Message.java
com.littleinc.orm_benchmark.greendao.UserDao.java
com.littleinc.orm_benchmark.greendao.User.java
com.littleinc.orm_benchmark.ormlite.Contact.java
com.littleinc.orm_benchmark.ormlite.DataBaseHelper.java
com.littleinc.orm_benchmark.ormlite.Message.java
com.littleinc.orm_benchmark.ormlite.ORMLiteExecutor.java
com.littleinc.orm_benchmark.ormlite.User.java
com.littleinc.orm_benchmark.ormlite.config.DBConfigUtil.java
com.littleinc.orm_benchmark.sqlite.DataBaseHelper.java
com.littleinc.orm_benchmark.sqlite.Message.java
com.littleinc.orm_benchmark.sqlite.SQLiteExecutor.java
com.littleinc.orm_benchmark.sqlite.User.java
com.littleinc.orm_benchmark.util.Util.java