|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SyncCollection
Defines functionality required for a collection of SyncObject
instances, used for backup, restore, and synchronization of persisted data
with a back-end synchronization service.
Implementation constraints
Naming your collection: Every collection has a name that uniquely
identifies the collection within the sync system. Your collection's sync name
is equivalent to a database name for your ID, and get used as a unique key
within the system. When the device gets connected to a Desktop Manager, the
sync name appears to the user as the database name for your
collection. During enterprise activation, the sync name appears in the
activation list as collection name.
Note that once code with your sync collection's name has interacted with a backup/restore service, you may not change the name without breaking backwards compatibility.
Sync collection names should not, therefore, be localized or dynamic.
Additionally, your sync collection's name must consist of no less than 1 and no more than 32 characters.
Finally, some back-end services treat your sync collection's name with case-sensitivity and some do not; therefore, you should ensure that your collection's name does not rely solely on differences of case to be unique, as this will work with some services, but not with others.
SyncItem
,
SyncManager.enableSynchronization(net.rim.device.api.synchronization.SyncCollection)
,
StateInfoListener
Method Summary | ||
---|---|---|
|
boolean |
addSyncObject(SyncObject object)
Add a sync object to this collection. |
|
void |
beginTransaction()
Start a synchronization transaction involving this collection. |
|
void |
clearSyncObjectDirty(SyncObject object)
Mark a provided sync object as not having been recently modified. |
|
void |
endTransaction()
End a synchronization transaction involving this collection. |
|
SyncConverter |
getSyncConverter()
Retrieve the sync message converter for this collection. |
|
String |
getSyncName()
Retrieve this collection's sync name. |
|
String |
getSyncName(Locale locale)
Retrieve a localized name for this collection. |
|
SyncObject |
getSyncObject(int uid)
Retrieve the sync object associated with provided ID from this collection. |
|
int |
getSyncObjectCount()
Retrieve the number of sync objects in this collection. |
|
SyncObject[] |
getSyncObjects()
Retrieve all the sync objects from this collection. |
|
int |
getSyncVersion()
Retrieve the unique identifier used by the sync framework to identify the synchronization version of this collection. |
|
boolean |
isSyncObjectDirty(SyncObject object)
Determine if the provided sync object has recently been modified. |
|
boolean |
removeAllSyncObjects()
Flush all sync objects out of this collection. |
|
boolean |
removeSyncObject(SyncObject object)
Remove a sync object from this collection. |
|
void |
setSyncObjectDirty(SyncObject object)
Mark a provided sync object as having been recently modified. |
|
boolean |
updateSyncObject(SyncObject oldObject,
SyncObject newObject)
Replace an existing sync object in this collection with a new one. |
Method Detail |
---|
boolean addSyncObject(SyncObject object)
Implementations should, by default, set the sync object's dirty bit to clean.
object
- The sync object to add to this collection.
boolean updateSyncObject(SyncObject oldObject, SyncObject newObject)
Implementations should find the provided old sync object in this collection, and then replace it with the provided new sync object. After the replacement, your implementation should mark the new sync object as clean.
Implementations should cope with a null reference to an old object by
simply adding the new object to this collection (however, consumers
should in general rely upon SyncCollection.addSyncObject(SyncObject)
to add new
objects).
oldObject
- Sync object to replace; may be null.newobject
- New sync object to replace the old one; must not be
null, or the same object as provided for the old sync object.
boolean removeSyncObject(SyncObject object)
object
- Sync object to remove.
boolean removeAllSyncObjects()
SyncObject[] getSyncObjects()
Your implementation must allow for the fact that the synchronization manager will freely manipulate the returned array as it requires.
SyncObject getSyncObject(int uid)
uid
- Unique identifier for the sync object to retrieve.
boolean isSyncObjectDirty(SyncObject object)
object
- Object to check.
void setSyncObjectDirty(SyncObject object)
If the device modifies a sync object, then this method should be invoked in order to mark the object as recently changed.
object
- Sync object to mark as having been recently modified.SyncCollection.clearSyncObjectDirty(SyncObject)
void clearSyncObjectDirty(SyncObject object)
If the device successfully accounts for recent modifications to a sync object, then this method should be invoked in order to remove the "recently modified" mark from the object.
object
- Sync object from which to remove the "recently modified"
mark.SyncCollection.setSyncObjectDirty(SyncObject)
int getSyncObjectCount()
int getSyncVersion()
The back-end synchronization framework supports incremental changes to this collection's data only as long as the sync version for this collection remains unchanged.
When the sync version value for this collection changes on the device, the back-end service assumes that data tagged with the previous version value cannot be reliably synchronized to the device, and will purge all data not tagged with this current sync version value.
String getSyncName()
Implementors must ensure that this method returns a sync name within the naming constraints outlined in this interface's description.
String getSyncName(Locale locale)
Implementors may wish to provide a localized name for collection
implementations; however, this localized name should get used for display
purposes only: the underlying sync name used with the rest of the sync
system must be canonical and retrieved by SyncCollection.getSyncName()
.
The system will use the value retrieved from SyncCollection.getSyncName()
for its display purposes if this method returns null.
locale
- Display locale of interest.
SyncConverter getSyncConverter()
The sync system depends upon a sync message converter to serialize
the sync objects contained within this collection, and to create new
SyncObject
instances from their serialized forms.
void beginTransaction()
The sync system uses transactions to perform synchronizations that involve a large number of data records (because all the affected data records must be handled in a series of packets with the back-end service). The sync manager invokes this method before serially adding, modifying, or deleting a data record.
When the synchronization transaction is complete, the sync manager
will terminate it by invoking SyncCollection.endTransaction()
.
Notice that the OTA Sync framework provides a similar function through
the OTASyncListener
transaction listener interface.
void endTransaction()
The sync manager invokes this method when terminating a
synchronization involving this collection (that it opened by invoking
SyncCollection.beginTransaction()
).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal