public class SQLiteHouseRelay
extends android.content.BroadcastReceiver
SQLiteHouseKeeper
.
This class fills the role of a ContentResolver
without implementing
that class's API, since the prototypes of the ContentResolver
's
methods don't fit with the workflow of a SQLiteHouse
.
If an app uses an implementation of SQLiteHouse
to marshal data
to/from a SQLite database, then it should provide a library which includes
the schematic classes and an implementation of this class. Since the
implementation class is expected to be provided in a library that is separate
from the SQLiteHouse
implementation, its declaration must not
depend on the ability to import that implementation (e.g. as part of
a generic template parameter on the class).Modifier and Type | Class and Description |
---|---|
static interface |
SQLiteHouseRelay.Listener
Methods that must be implemented by any class that wants to process the
information received in signals from a
SQLiteHouseKeeper . |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LOG_TAG |
protected SQLiteHouseSignalAPI |
m_api
A reference for the contract under which the relay is registered.
|
protected android.content.Context |
m_ctx
The context in which the relay will operate.
|
protected java.util.Vector<SQLiteHouseRelay.Listener> |
m_vListeners
The set of active listeners.
|
Constructor and Description |
---|
SQLiteHouseRelay(android.content.Context ctx)
Constructs an instance, but does not register it.
|
Modifier and Type | Method and Description |
---|---|
SQLiteHouseRelay |
addListener(SQLiteHouseRelay.Listener l)
Registers a listener.
|
protected <SC extends SQLightable> |
buildDeleteSignal(SC o)
Constructs the
Intent to be sent by delete(SC) . |
protected <SC extends SQLightable> |
buildInsertSignal(SC o)
Constructs the
Intent to be sent by insert(SC) . |
protected <SC extends SQLightable> |
buildSelectionSignal(java.lang.Class<SC> cls,
SelectionBuilder q)
Constructs the
Intent to be sent by select(java.lang.Class<SC>, net.zer0bandwidth.android.lib.content.querybuilder.SelectionBuilder) . |
protected <SC extends SQLightable> |
buildUpdateSignal(SC o)
Constructs the
Intent to be sent by update(SC) . |
<SC extends SQLightable> |
delete(SC o)
Requests deletion of a particular row in the keeper's database,
corresponding to the schematic class instance supplied.
|
protected void |
handleCustomAction(android.content.Context ctx,
android.content.Intent sig,
java.lang.String sToken)
Override this method to handle custom actions not covered by the standard
set defined in
SQLiteHouseSignalAPI . |
<SC extends SQLightable> |
insert(SC o)
Requests insertion of a schematic class instance into the keeper's
database.
|
protected void |
onDeleteFailed(android.content.Intent sig)
Handles a signal from the keeper that a row deletion failed.
|
protected void |
onInsertFailed(android.content.Intent sig)
Handles a signal from the keeper that a row insertion has failed.
|
void |
onReceive(android.content.Context ctx,
android.content.Intent sig) |
protected void |
onRowInserted(android.content.Intent sig)
Handles a signal from the keeper that a row was inserted.
|
protected void |
onRowsDeleted(android.content.Intent sig)
Handles a signal from the keeper that some rows were deleted.
|
protected <SC extends SQLightable> |
onRowsSelected(android.content.Intent sig)
Handles a signal payload from the keeper, containing a set of selected
rows from the database.
|
protected void |
onRowsUpdated(android.content.Intent sig)
Handles a signal from the keeper that some rows were updated.
|
protected void |
onSelectFailed(android.content.Intent sig)
Handles a signal from the keeper that a row selection failed.
|
protected void |
onUpdateFailed(android.content.Intent sig)
Handles a signal from the keeper that a table update has failed.
|
SQLiteHouseRelay |
register(SQLiteHouseSignalAPI api)
Registers the relay instance as a
BroadcastReceiver in its
context. |
SQLiteHouseRelay |
removeListener(SQLiteHouseRelay.Listener l)
Unregisters a listener.
|
<SC extends SQLightable> |
select(java.lang.Class<SC> cls,
SelectionBuilder q)
Requests the selection of a set of rows from the keeper's database.
|
SQLiteHouseRelay |
unregister()
Unregisters the relay in its context.
|
<SC extends SQLightable> |
update(SC o)
Requests an update of a particular row in the keeper's database,
corresponding to the schematic class instance supplied.
|
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getResultCode, getResultData, getResultExtras, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, peekService, setDebugUnregister, setOrderedHint, setResult, setResultCode, setResultData, setResultExtras
public static final java.lang.String LOG_TAG
protected android.content.Context m_ctx
protected SQLiteHouseSignalAPI m_api
protected java.util.Vector<SQLiteHouseRelay.Listener> m_vListeners
public SQLiteHouseRelay(android.content.Context ctx)
ctx
- the context in which the relay will operatepublic SQLiteHouseRelay register(SQLiteHouseSignalAPI api)
BroadcastReceiver
in its
context.api
- the signal contract between the keeper and the relay; if
null
, then the relay will be unregistered insteadpublic SQLiteHouseRelay unregister()
public final void onReceive(android.content.Context ctx, android.content.Intent sig)
onReceive
in class android.content.BroadcastReceiver
public SQLiteHouseRelay addListener(SQLiteHouseRelay.Listener l)
l
- the listener to be registeredpublic SQLiteHouseRelay removeListener(SQLiteHouseRelay.Listener l)
l
- the listener to be removedprotected void handleCustomAction(android.content.Context ctx, android.content.Intent sig, java.lang.String sToken)
SQLiteHouseSignalAPI
. The default implementation
writes an information log stating that the action is unrecognized.ctx
- the context from which the signal originatedsig
- the received signalsToken
- the action token parsed from the signalprotected void onRowInserted(android.content.Intent sig)
sig
- the received signalprotected void onInsertFailed(android.content.Intent sig)
sig
- the received signalprotected void onRowsUpdated(android.content.Intent sig)
sig
- the received signalprotected void onUpdateFailed(android.content.Intent sig)
sig
- the received signalprotected void onRowsDeleted(android.content.Intent sig)
sig
- the received signalprotected void onDeleteFailed(android.content.Intent sig)
sig
- the received signalprotected <SC extends SQLightable> void onRowsSelected(android.content.Intent sig)
SC
- the schematic classsig
- the received signalprotected void onSelectFailed(android.content.Intent sig)
sig
- the received signalpublic <SC extends SQLightable> SQLiteHouseRelay insert(SC o)
SC
- the schematic classo
- an instance of the schematic classprotected <SC extends SQLightable> android.content.Intent buildInsertSignal(SC o)
Intent
to be sent by insert(SC)
.
This is a separate method only so that it can be unit-tested.SC
- the schematic classo
- an instance of the schematic class to be inserted@insert
public <SC extends SQLightable> SQLiteHouseRelay update(SC o)
SC
- the schematic classo
- an instance of the schematic classprotected <SC extends SQLightable> android.content.Intent buildUpdateSignal(SC o)
Intent
to be sent by update(SC)
.
This is a separate method only so that it can be unit-tested.SC
- the schematic classo
- an instance of the schematic class to be used as update inputupdate(SC)
public <SC extends SQLightable> SQLiteHouseRelay delete(SC o)
SC
- the schematic classo
- an instance of the schematic classprotected <SC extends SQLightable> android.content.Intent buildDeleteSignal(SC o)
Intent
to be sent by delete(SC)
.
This is a separate method only so that it can be unit-tested.SC
- the schematic classo
- an instance of the schematic class to be deleteddelete(SC)
public <SC extends SQLightable> SQLiteHouseRelay select(java.lang.Class<SC> cls, SelectionBuilder q)
SC
- the schematic classcls
- the schematic class that would contain the rowsq
- a query against that data setprotected <SC extends SQLightable> android.content.Intent buildSelectionSignal(java.lang.Class<SC> cls, SelectionBuilder q)
Intent
to be sent by select(java.lang.Class<SC>, net.zer0bandwidth.android.lib.content.querybuilder.SelectionBuilder)
.
This is a separate method only so that it can be unit-tested.SC
- the schematic classcls
- the schematic class that would contain the rowsq
- a query against that data setselect(java.lang.Class<SC>, net.zer0bandwidth.android.lib.content.querybuilder.SelectionBuilder)