public static class SQLiteHouse.Factory
extends java.lang.Object
SQLiteHouse
. Because we have to have all
our ducks in a row before the SQLiteHouse
calls its ancestor's
constructor, the factory needs to parse the SQLiteDatabaseSpec
in
advance, and feed that information into the constructor as parameters.
Given a Context ctx
and SQLiteDatabase.CursorFactory cf
(which may be null):
MyDatabaseClass dbh = SQLiteHouse.Factory.init().getInstance( MyDatabaseClass.class, ctx, cf ) ;
See SQLiteHouse
for detailed information regarding how this
fits into the overall lifecycle of the object instance.
Modifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<java.lang.Class<? extends SQLightable>> |
m_aclsSchema
The array of classes which, in aggregate, define the schema for the
database.
|
protected android.database.sqlite.SQLiteDatabase.CursorFactory |
m_cf
The cursor factory to be used with the
SQLiteHouse instance,
if any. |
protected android.content.Context |
m_ctx
The context in which the
SQLiteHouse will operate. |
protected int |
m_nSchemaVersion
The current schema version of the database.
|
protected java.lang.String |
m_sDatabaseName
The name of the database to be created.
|
Constructor and Description |
---|
Factory() |
Modifier and Type | Method and Description |
---|---|
<FDSC extends SQLiteHouse> |
getInstance(java.lang.Class<FDSC> cls,
android.content.Context ctx)
Uses annotations found in a
SQLiteHouse descendant to
construct an instance of the database class. |
<FDSC extends SQLiteHouse> |
getInstance(java.lang.Class<FDSC> cls,
android.content.Context ctx,
android.database.sqlite.SQLiteDatabase.CursorFactory cf)
Uses annotations found in a
SQLiteHouse descendant to
construct an instance of the database class. |
static SQLiteHouse.Factory |
init()
Simply an alias for the default constructor, to allow for a cleaner
grammar when creating a factory instance to obtain a reference to a
database.
|
protected android.content.Context m_ctx
SQLiteHouse
will operate.protected java.lang.String m_sDatabaseName
SQLiteDatabaseSpec
annotation of the class that is
passed into the getInstance(java.lang.Class<FDSC>, android.content.Context)
method.
The SQLiteHouse.SQLiteHouse(Factory)
constructor retrieves
this value from the factory to pass it to the parent class's
constructor, SQLitePortal.SQLitePortal(android.content.Context, java.lang.String, android.database.sqlite.SQLiteDatabase.CursorFactory, int)
.protected android.database.sqlite.SQLiteDatabase.CursorFactory m_cf
SQLiteHouse
instance,
if any. This is passed as an argument to getInstance(java.lang.Class<FDSC>, android.content.Context)
.
The SQLiteHouse.SQLiteHouse(Factory)
constructor retrieves
this value from the factory to pass it to the parent class's
constructor, SQLitePortal.SQLitePortal(android.content.Context, java.lang.String, android.database.sqlite.SQLiteDatabase.CursorFactory, int)
.protected int m_nSchemaVersion
SQLiteDatabaseSpec
annotation of the class that
is passed into the getInstance(java.lang.Class<FDSC>, android.content.Context)
method.
The SQLiteHouse.SQLiteHouse(Factory)
constructor retrieves
this value from the factory to pass it to the parent class's
constructor, SQLitePortal.SQLitePortal(android.content.Context, java.lang.String, android.database.sqlite.SQLiteDatabase.CursorFactory, int)
.protected java.util.ArrayList<java.lang.Class<? extends SQLightable>> m_aclsSchema
SQLiteDatabaseSpec
annotation of the class that is passed to
the getInstance(java.lang.Class<FDSC>, android.content.Context)
method.
The SQLiteHouse.SQLiteHouse(Factory)
constructor uses this
list to construct the schema; see
SQLiteHouse.setSchemaClasses(List)
.public static SQLiteHouse.Factory init()
public <FDSC extends SQLiteHouse> FDSC getInstance(java.lang.Class<FDSC> cls, android.content.Context ctx) throws IntrospectionException
SQLiteHouse
descendant to
construct an instance of the database class.
Since this method is templatized on the class that is being
instantiated, there is no need for the SQLiteHouse
descendant
to provide its own extension of SQLiteHouse.Factory
; this
method will return an instance of the descendant class.FDSC
- the SQLiteHouse
descendant being created; this
matches the class sent in the cls
argument.cls
- the SQLiteHouse
descendant class being createdctx
- the context in which the object will operateSQLiteHouse
descendant,
initialized with the database attributes found in the class's
SQLiteDatabaseSpec
annotationIntrospectionException
- if something goes wrong while
processing the descendant class. When invoking the descendant's
constructor, there are several possible failure states; use
.getCause()
to determine which one applies.public <FDSC extends SQLiteHouse> FDSC getInstance(java.lang.Class<FDSC> cls, android.content.Context ctx, android.database.sqlite.SQLiteDatabase.CursorFactory cf) throws IntrospectionException
SQLiteHouse
descendant to
construct an instance of the database class.
Since this method is templatized on the class that is being
instantiated, there is no need for the SQLiteHouse
descendant
to provide its own extension of SQLiteHouse.Factory
; this
method will return an instance of the descendant class.FDSC
- the SQLiteHouse
descendant being created; this
matches the class sent in the cls
argument.cls
- the SQLiteHouse
descendant class being createdctx
- the context in which the object will operatecf
- a cursor factory as allowed by the
SQLiteOpenHelper
constructor (may be
null)SQLiteHouse
descendant,
initialized with the database attributes found in the class's
SQLiteDatabaseSpec
annotationIntrospectionException
- if something goes wrong while
processing the descendant class. When invoking the descendant's
constructor, there are several possible failure states; use
.getCause()
to determine which one applies.