Android Open Source - simple-sqlite S Q Lite Configuration






From Project

Back to project page simple-sqlite.

License

The source code is released under:

Apache License

If you think the Android project simple-sqlite 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.aldobo.simple.sqlite;
//www.  j  av  a 2 s.  co  m
import com.aldobo.simple.sqlite.entities.Model;
import com.aldobo.simple.sqlite.entities.Schema;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class SQLiteConfiguration {

    private String mDatabaseName;
    private Integer mDatabaseVersion;
    private List<Schema> mSchemas;
    private SQLiteOpenHelperExtendable mExtension;

    private SQLiteConfiguration(Builder builder)
    {
        mDatabaseName = builder.mDatabaseName;
        mDatabaseVersion= builder.mDatabaseVersion;
        mSchemas = builder.mSchemas;
        mExtension = builder.mExtension;
    }

    public String getDatabaseName()
    {
        return this.mDatabaseName;
    }

    public Integer getDatabaseVersion()
    {
        return this.mDatabaseVersion;
    }

    public Iterator<Schema> getSchemas()
    {
        return mSchemas.iterator();
    }

    public SQLiteOpenHelperExtendable getExtension()
    {
        return mExtension;
    }

    public Boolean hasExtension()
    {
        return mExtension!=null;
    }

    public static class Builder
    {
        private String mDatabaseName;
        private Integer mDatabaseVersion;
        private List<Schema> mSchemas;
        private SQLiteOpenHelperExtendable mExtension;

        public Builder()
        {
            mSchemas = new ArrayList<Schema>();
        }

        public Builder setDatabaseName(String name)
        {
            mDatabaseName = name;
            return this;
        }
        public Builder setDatabaseVersion(Integer version)
        {
            mDatabaseVersion = version;
            return this;
        }

        public SQLiteConfiguration build()
        {
            return new SQLiteConfiguration(this);
        }
        private Builder registerTable(Schema schema)
        {
            mSchemas.add(schema);
            return this;
        }

        public<T extends Model> Builder registerTable(Class<T> model)
        {
            try {
                Schema schema= model.newInstance().getSchema();
                return registerTable(schema);
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            return null;
        }

        public Builder setExtension(SQLiteOpenHelperExtendable extension)
        {
            mExtension  = extension;
            return this;
        }




    }

}




Java Source Code List

com.aldobo.simple.sqlite.SQLiteConfiguration.java
com.aldobo.simple.sqlite.SQLiteManager.java
com.aldobo.simple.sqlite.SQLiteOpenHelperApp.java
com.aldobo.simple.sqlite.SQLiteOpenHelperExtendable.java
com.aldobo.simple.sqlite.entities.Field.java
com.aldobo.simple.sqlite.entities.Model.java
com.aldobo.simple.sqlite.entities.SQLiteDefaultValue.java
com.aldobo.simple.sqlite.entities.SQLiteType.java
com.aldobo.simple.sqlite.entities.Schema.java
com.aldobo.simple.sqlite.sample.MainActivity.java
com.aldobo.simple.sqlite.sample.MainApplication.java
com.aldobo.simple.sqlite.sample.fragments.BaseFragment.java
com.aldobo.simple.sqlite.sample.fragments.MyListFragment.java
com.aldobo.simple.sqlite.sample.models.Person.java
com.aldobo.simple.sqlite.tags.Column.java
com.aldobo.simple.sqlite.tags.Table.java
com.aldobo.simple.sqlite.utils.ModelIterable.java
com.aldobo.simple.sqlite.utils.Utils.java