H
- the SQLiteHouse
implementation to which this provider is
boundpublic class SQLiteHouseKeeper<H extends SQLiteHouse>
extends android.content.BroadcastReceiver
SQLiteHouse
implementation and receives
intents that request queries from the underlying database.
This class fills the role of a ContentProvider
without implementing
that class's API, since the prototypes of the ContentProvider
's
methods don't fit with the workflow of a SQLiteHouse
.Modifier and Type | Class and Description |
---|---|
class |
SQLiteHouseKeeper.DefaultSignals
A default implementation of
SQLiteHouseSignalAPI for this keeper
class. |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LOG_TAG |
protected SQLiteHouseSignalAPI |
m_api
A reference for the contract under which the keeper was registered.
|
protected java.lang.Class<H> |
m_cls
A persistent handle on the
SQLiteHouse implementation class. |
protected android.content.Context |
m_ctx
The context in which the keeper will operate.
|
protected H |
m_house
A persistent reference to the database helper instance.
|
Constructor and Description |
---|
SQLiteHouseKeeper(android.content.Context ctx,
java.lang.Class<H> cls,
H dbh)
Constructs an instance, but does not register it.
|
Modifier and Type | Method and Description |
---|---|
protected <SC extends SQLightable> |
buildResultBroadcast(java.lang.Class<SC> cls,
java.util.List<SC> aoResults)
Builds the intent that would be sent by
sendSelectionResults(java.lang.Class<SC>, java.util.List<SC>) . |
protected <SC extends SQLightable> |
delete(android.content.Intent sig)
Handles a request to delete a record in the underlying database.
|
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 . |
protected <SC extends SQLightable> |
insert(android.content.Intent sig)
Handles a request to insert data into the underlying database.
|
protected <SC extends SQLightable> |
notifyDeleted(java.lang.Class<SC> cls,
int nRows)
Notifies the relay that rows have been deleted.
|
protected void |
notifyDeleteFailed(java.lang.String sClass)
Notifies the relay that a deletion failed.
|
protected <SC extends SQLightable> |
notifyInserted(long nRowID,
java.lang.Class<SC> cls,
SC row)
Notifies the relay that an insertion succeeded.
|
protected void |
notifyInsertFailed(java.lang.String sClass)
Notifies the relay that an insertion failed.
|
protected void |
notifySelectionFailed(java.lang.String sClass)
Notifies the relay that a selection failed.
|
protected <SC extends SQLightable> |
notifyUpdated(java.lang.Class<SC> cls,
int nRows)
Notifies the relay that an update operation succeeded.
|
protected void |
notifyUpdateFailed(java.lang.String sClass)
Notifies the relay that an update failed.
|
void |
onReceive(android.content.Context ctx,
android.content.Intent sig) |
protected <SC extends SQLightable> |
parseSelectionSpec(java.lang.Class<SC> cls,
android.os.Bundle bndl)
Prepares a
SelectionBuilder with query specifications received in
a signal from the relay. |
SQLiteHouseKeeper<H> |
register()
Registers the keeper instance as a
BroadcastReceiver in its
context, using the canonical name of the underlying SQLiteHouse
implementation class as the contractual "authority". |
SQLiteHouseKeeper<H> |
register(SQLiteHouseSignalAPI api)
Registers the keeper instance as a
BroadcastReceiver in its
context. |
protected <SC extends SQLightable> |
select(android.content.Intent sig)
Handles a request to select records from the underlying database.
|
protected <SC extends SQLightable> |
sendSelectionResults(java.lang.Class<SC> cls,
java.util.List<SC> aoResults)
Broadcasts a result set to the relay.
|
SQLiteHouseKeeper<H> |
unregister()
Unregisters the keeper in its context.
|
protected <SC extends SQLightable> |
update(android.content.Intent sig)
Handles a request to update a record in the underlying database.
|
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 java.lang.Class<H extends SQLiteHouse> m_cls
SQLiteHouse
implementation class.protected H extends SQLiteHouse m_house
protected SQLiteHouseSignalAPI m_api
public SQLiteHouseKeeper(android.content.Context ctx, java.lang.Class<H> cls, H dbh)
ctx
- the context in which the keeper will operatecls
- the SQLiteHouse
implementation classdbh
- the SQLiteHouse
implementation instance to which the
keeper is boundpublic SQLiteHouseKeeper<H> register()
BroadcastReceiver
in its
context, using the canonical name of the underlying SQLiteHouse
implementation class as the contractual "authority".SQLiteHouseKeeper.DefaultSignals
,
SQLiteHouseSignalAPI
public SQLiteHouseKeeper<H> register(SQLiteHouseSignalAPI api)
BroadcastReceiver
in its
context.api
- the signal contract between the keeper and its relays; if
null
, then the keeper will be unregistered instead!public SQLiteHouseKeeper<H> unregister()
public final void onReceive(android.content.Context ctx, android.content.Intent sig)
onReceive
in class android.content.BroadcastReceiver
protected 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 <SC extends SQLightable> long insert(android.content.Intent sig)
SC
- the schematic class that is discovered along the waysig
- the received signalprotected <SC extends SQLightable> int update(android.content.Intent sig)
SC
- the schematic class of the row to be updatedsig
- the received signalprotected <SC extends SQLightable> int delete(android.content.Intent sig)
SC
- the schematic class of the row to be deletedsig
- the received signalprotected <SC extends SQLightable> void select(android.content.Intent sig)
SC
- the schematic class of the rows to be selectedsig
- the received signalprotected <SC extends SQLightable> SelectionBuilder parseSelectionSpec(java.lang.Class<SC> cls, android.os.Bundle bndl)
SelectionBuilder
with query specifications received in
a signal from the relay.SC
- the schematic classcls
- the schematic class that would contain the rowsbndl
- a selection query specificationSelectionBuilder.toBundle()
protected <SC extends SQLightable> void notifyInserted(long nRowID, java.lang.Class<SC> cls, SC row)
SC
- the schematic class of the inserted datacls
- the schematic class of the inserted datanRowID
- the ID of the inserted rowprotected void notifyInsertFailed(java.lang.String sClass)
sClass
- the name of the class that would have been insertedprotected <SC extends SQLightable> void notifyUpdated(java.lang.Class<SC> cls, int nRows)
SC
- the schematic class of the updated datacls
- the schematic class of the updated datanRows
- the number of rows that were updatedprotected void notifyUpdateFailed(java.lang.String sClass)
sClass
- the name of the class that would have been updatedprotected <SC extends SQLightable> void notifyDeleted(java.lang.Class<SC> cls, int nRows)
SC
- the schematic class of the updated datacls
- the schematic class of the deleted datanRows
- the number of rows that were updatedprotected void notifyDeleteFailed(java.lang.String sClass)
sClass
- the name of the class that would have had rows deletedprotected <SC extends SQLightable> void sendSelectionResults(java.lang.Class<SC> cls, java.util.List<SC> aoResults)
SC
- the schematic classcls
- the schematic class that would contain the rowsaoResults
- the result setprotected <SC extends SQLightable> android.content.Intent buildResultBroadcast(java.lang.Class<SC> cls, java.util.List<SC> aoResults)
sendSelectionResults(java.lang.Class<SC>, java.util.List<SC>)
.SC
- the schematic classcls
- the schematic class that would contain the rowsaoResults
- the result setsendSelectionResults(java.lang.Class<SC>, java.util.List<SC>)
protected void notifySelectionFailed(java.lang.String sClass)
sClass
- the name of the class that would have had rows selected