|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--danger.app.Listener
|
+--danger.app.SettingsDB
Application interface to the SettingsDB class This class can be used to manage setting values, if they are key value pairs. The setting key is a string, and cannot be longer than 256 characters. The setting value can be of integer, string, byte arrays. The keys of a SettingsDB need to be unique. Each key and value pair is stored in the record field in the DataStore. The SettingsDB has a corresponding DataStore on the device. Since DataStore can be autosync'd with the service, SettingsDB can be autosync'd as well. Note that SettingsDB namespaces are local to an application, and one application cannot open another applications SettingsDB.
| Field Summary | |
protected static boolean |
DEBUG_CONFLICT_RESOLVE
|
protected static boolean |
DEBUG_CONFLICT_RESOLVE_VERBOSE
|
protected static boolean |
DEBUG_SORT
|
protected static boolean |
IS_DEBUG
|
static int |
kDataType_Bytes
|
static int |
kDataType_Integer
|
static int |
kDataType_String
|
protected static int |
kDefaultSetting
|
protected Listener |
mAutoSyncNotifyee
|
protected DataStore |
mDataStore
|
| Constructor Summary | |
SettingsDB(java.lang.String dbName)
Create or get a SettingsDB. |
|
SettingsDB(java.lang.String dbName,
boolean autoSync)
Create or get a SettingsDB. |
|
| Method Summary | |
void |
clearAll()
Remove all records in a settings database. |
void |
dump()
Dump the contents of the settings database to debug output. |
int |
find(java.lang.String inKey)
Find and return the index for a record in the database. |
protected int |
find2(java.lang.String inKey)
Find and return the index for a record in the database. |
static boolean |
findDB(java.lang.String dbName)
Find a settings database. |
static boolean |
findDB(java.lang.String dbName,
boolean absolutePath)
Find a settings database. |
byte[] |
getBytes(int i)
Get byte array specifed by index. |
byte[] |
getBytes(java.lang.String inKey)
Get byte array specifed by key. |
int |
getDataType(int i)
Get the data type of the ith entry in a settings database. |
int |
getIntValue(int i)
Get integer value specifed by index. |
int |
getIntValue(java.lang.String inKey)
Get integer value specifed by key. |
java.lang.String |
getKey(int i)
Get a specific key from a settings database. |
int |
getNumEntries()
Get the number of records in a settings database. |
void |
getObject(java.lang.String inKey,
danger.io.Storable ioObject)
Get object specifed by key. |
java.lang.String |
getStringValue(int i)
Get string value specifed by index. |
java.lang.String |
getStringValue(java.lang.String inKey)
Get string value specifed by key. |
boolean |
receiveEvent(Event e)
Receive a SettingsDB-related event. |
java.lang.String |
remove(java.lang.String inKey)
Remove the record specifed by key. |
boolean |
renameKey(int i,
java.lang.String newKey)
Rename a specific key in a settings database. |
boolean |
renameKey(java.lang.String oldKey,
java.lang.String newKey)
Rename a specific key in a settings database. |
protected void |
resolveAllRecords()
Resolves each record with every other record in the settings database. |
protected void |
resolveAutoSyncConflicts()
Resolves potential conflicts caused by auto-syncing the data from Danger service. |
void |
setAutoSyncNotifyee(Listener inNotifyee)
Set the Listener for AutoSync events. |
void |
setBytes(java.lang.String inKey,
byte[] inValue)
Set the byte array specifed by key. |
void |
setBytes(java.lang.String inKey,
byte[] inValue,
boolean isDefault)
Set the byte array specifed by key. |
void |
setIntValue(java.lang.String inKey,
int inValue)
Set the integer value specifed by key. |
void |
setIntValue(java.lang.String inKey,
int inValue,
boolean isDefault)
Set the integer value specifed by key. |
void |
setObject(java.lang.String inKey,
danger.io.Storable inObject)
Set the object specifed by key. |
void |
setObject(java.lang.String inKey,
danger.io.Storable inObject,
boolean isDefaultSetting)
Set the object specifed by key. |
void |
setStringValue(java.lang.String inKey,
java.lang.String inValue)
Set the string value specifed by key. |
void |
setStringValue(java.lang.String inKey,
java.lang.String inValue,
boolean isDefault)
Set the string value specifed by key. |
protected void |
sort()
Sort the settings database by the keys. |
| Methods inherited from class danger.app.Listener |
cancelEvents, receiveEventInternal, sendEvent, sendEvent |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected DataStore mDataStore
protected Listener mAutoSyncNotifyee
public static final int kDataType_Integer
public static final int kDataType_String
public static final int kDataType_Bytes
protected static final int kDefaultSetting
protected static final boolean IS_DEBUG
protected static final boolean DEBUG_CONFLICT_RESOLVE
protected static final boolean DEBUG_CONFLICT_RESOLVE_VERBOSE
protected static final boolean DEBUG_SORT
| Constructor Detail |
public SettingsDB(java.lang.String dbName,
boolean autoSync)
dbName - A String specifying the name of the settings database.autoSync - A boolean that is true if the database is to be backed up to the service.public SettingsDB(java.lang.String dbName)
dbName - A String specifying the name of the settings database.| Method Detail |
public boolean receiveEvent(Event e)
receiveEvent in class Listenere - An Event object containing the event type and data.public static boolean findDB(java.lang.String dbName)
dbName - A String specifying the name of the database to be found.
public static boolean findDB(java.lang.String dbName,
boolean absolutePath)
dbName - A String specifying the name of the database to be found.public int getNumEntries()
public int getDataType(int i)
i - An int specifying the index of the record to be retrieved.public java.lang.String getKey(int i)
i - An int specifying the index of the record to be retrieved.
public boolean renameKey(java.lang.String oldKey,
java.lang.String newKey)
oldKey - A String specifying the name of the key to be renamed.newKey - A String specifying the new name for the key.
public boolean renameKey(int i,
java.lang.String newKey)
i - An int specifying the index to the key to be renamed.newKey - A String specifying the new name for the key.public int find(java.lang.String inKey)
inKey - A String specifying the key for the record.protected int find2(java.lang.String inKey)
inKey - A String specifying the key for the record.protected void sort()
public void dump()
public void clearAll()
public int getIntValue(java.lang.String inKey)
throws SettingsDBException
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.
public int getIntValue(int i)
throws SettingsDBException
i - An int specifying the index to the record to be found.
public void setIntValue(java.lang.String inKey,
int inValue)
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.inValue - An int containing the value to be associated with the key.
public void setIntValue(java.lang.String inKey,
int inValue,
boolean isDefault)
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.inValue - An int containing the value to be associated with the key.isDefault - A boolean that is true if the value was not specified by the user.public java.lang.String getStringValue(java.lang.String inKey)
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.public java.lang.String getStringValue(int i)
i - An int specifying the index to the record to be found.
public void setStringValue(java.lang.String inKey,
java.lang.String inValue)
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.inValue - A String containing the value to be associated with the key.
public void setStringValue(java.lang.String inKey,
java.lang.String inValue,
boolean isDefault)
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.inValue - A String containing the value to be associated with the key.isDefault - A boolean that is true if the value was not specified by the user.
public byte[] getBytes(java.lang.String inKey)
throws SettingsDBException
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.
public byte[] getBytes(int i)
throws SettingsDBException
i - An int specifying the index to the record to be found.
public void setBytes(java.lang.String inKey,
byte[] inValue)
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.inValue - A byte array containing the value to be associated with the key.
public void setBytes(java.lang.String inKey,
byte[] inValue,
boolean isDefault)
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.inValue - A byte array containing the value to be associated with the key.isDefault - A boolean that is true if the value was not specified by the user.
public void setObject(java.lang.String inKey,
danger.io.Storable inObject)
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.inObject - A Storable object containing the object to be associated with the key.
public void setObject(java.lang.String inKey,
danger.io.Storable inObject,
boolean isDefaultSetting)
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.inObject - A Storable object containing the object to be associated with the key.isDefaultSetting - A boolean that is true if the value was not specified by the user.
public void getObject(java.lang.String inKey,
danger.io.Storable ioObject)
throws SettingsDBException
inKey - A String specifying the key to be found. String keys cannot be longer than 128,
and is case sensitive.ioObject - A Storable object to hold the data associated with the key.public java.lang.String remove(java.lang.String inKey)
inKey - A String specifying the key to be found.protected void resolveAllRecords()
protected void resolveAutoSyncConflicts()
public void setAutoSyncNotifyee(Listener inNotifyee)
inNotifyee - The listener to be notified of the autosync events.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||