|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.synchronization.SyncItem
public abstract class SyncItem
Provides an implementation of SyncCollection
to provide small objects
with easy access to the Synchronization API.
This class is used to provide backup/restore functionality to small bits
of information, typically configuration options.
Implementers should extend this object and implement the abstract functions:
SyncItem.getSyncName()
SyncItem.getSyncName(Locale locale)
SyncItem.getSyncVersion()
SyncItem.getSyncData(DataBuffer buffer, int version)
SyncItem.setSyncData(DataBuffer buffer, int version)
SyncCollection
,
SyncManager.enableSynchronization(net.rim.device.api.synchronization.SyncCollection)
,
SyncConverter
,
SyncObject
Constructor Summary | ||
---|---|---|
|
protected |
SyncItem()
|
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. |
|
boolean |
convert(SyncObject object,
DataBuffer buffer,
int version)
Converts a SyncObject into synchronization data. |
|
SyncObject |
convert(DataBuffer data,
int version,
int uid)
Extracts a SyncObject from the synchronization data. |
|
void |
endTransaction()
End a synchronization transaction involving this collection. |
|
SyncConverter |
getSyncConverter()
Retrieve the sync message converter for this collection. |
|
abstract boolean |
getSyncData(DataBuffer buffer,
int version)
Gets the data of this object for use in synchronization. |
|
abstract String |
getSyncName()
Retrieve this collection's sync name. |
|
abstract String |
getSyncName(Locale locale)
|
|
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. |
|
abstract int |
getSyncVersion()
Retrieve the unique identifier used by the sync framework to identify the synchronization version of this collection. |
|
int |
getUID()
Returns the unique ID stored in this SyncObject . |
|
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. |
|
abstract boolean |
setSyncData(DataBuffer buffer,
int version)
Sets the data of this object from the data received through synchronization. |
|
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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.rim.device.api.synchronization.SyncCollection |
---|
getSyncName |
Constructor Detail |
---|
protected SyncItem()
Method Detail |
---|
public abstract boolean setSyncData(DataBuffer buffer, int version)
buffer
- The data received through synchronization.version
- The version number specified with the data.
true
if the operation was successful;
false
otherwise.public abstract boolean getSyncData(DataBuffer buffer, int version)
buffer
- The DataBuffer into which the data should be placed.version
- The version of the information to be provided.
true
if the operation was successful;
false
otherwise.public int getUID()
SyncObject
SyncObject
.
getUID
in interface SyncObject
SyncObject.getUID()
public boolean convert(SyncObject object, DataBuffer buffer, int version)
SyncConverter
SyncObject
into synchronization data.
convert
in interface SyncConverter
object
- The SyncObject
to be converted.buffer
- The buffer into which the data will be placed.
This buffer should not be rewound as it may already contain
other data.version
- The version number specified with the data.
true
if the object was converted successfully;
false
otherwise.SyncConverter.convert( SyncObject, DataBuffer, int )
public SyncObject convert(DataBuffer data, int version, int uid)
SyncConverter
SyncObject
from the synchronization data.
convert
in interface SyncConverter
data
- The DataBuffer
containing only the synchronization data.
This buffer may be rewound as it will contain only the data
associated with the SyncObject
in question.version
- The version number specified with the data.
SyncObject
obtained from the synchronization data,
or null
if this conversion was unsuccessful.SyncConverter.convert( DataBuffer, int, int )
public abstract int getSyncVersion()
SyncCollection
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.
getSyncVersion
in interface SyncCollection
SyncCollection.getSyncVersion()
public abstract String getSyncName()
SyncCollection
Implementors must ensure that this method returns a sync name within the naming constraints outlined in this interface's description.
getSyncName
in interface SyncCollection
SyncCollection.getSyncName()
public abstract String getSyncName(Locale locale)
SyncCollection.getSyncName()
public boolean addSyncObject(SyncObject object)
SyncCollection
Implementations should, by default, set the sync object's dirty bit to clean.
addSyncObject
in interface SyncCollection
object
- The sync object to add to this collection.
SyncCollection.addSyncObject(net.rim.device.api.synchronization.SyncObject)
public boolean updateSyncObject(SyncObject oldObject, SyncObject newObject)
SyncCollection
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).
updateSyncObject
in interface SyncCollection
oldObject
- Sync object to replace; may be null.
SyncCollection.updateSyncObject(net.rim.device.api.synchronization.SyncObject, net.rim.device.api.synchronization.SyncObject)
public boolean removeSyncObject(SyncObject object)
SyncCollection
removeSyncObject
in interface SyncCollection
object
- Sync object to remove.
SyncCollection.removeSyncObject(net.rim.device.api.synchronization.SyncObject)
public boolean removeAllSyncObjects()
SyncCollection
removeAllSyncObjects
in interface SyncCollection
SyncCollection.removeAllSyncObjects()
public SyncObject[] getSyncObjects()
SyncCollection
Your implementation must allow for the fact that the synchronization manager will freely manipulate the returned array as it requires.
getSyncObjects
in interface SyncCollection
SyncCollection.getSyncObjects()
public SyncObject getSyncObject(int uid)
SyncCollection
getSyncObject
in interface SyncCollection
uid
- Unique identifier for the sync object to retrieve.
SyncCollection.getSyncObject(int)
public boolean isSyncObjectDirty(SyncObject object)
SyncCollection
isSyncObjectDirty
in interface SyncCollection
object
- Object to check.
SyncCollection.isSyncObjectDirty(net.rim.device.api.synchronization.SyncObject)
public void setSyncObjectDirty(SyncObject object)
SyncCollection
If the device modifies a sync object, then this method should be invoked in order to mark the object as recently changed.
setSyncObjectDirty
in interface SyncCollection
object
- Sync object to mark as having been recently modified.SyncCollection.setSyncObjectDirty(net.rim.device.api.synchronization.SyncObject)
public void clearSyncObjectDirty(SyncObject object)
SyncCollection
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.
clearSyncObjectDirty
in interface SyncCollection
object
- Sync object from which to remove the "recently modified"
mark.SyncCollection.clearSyncObjectDirty(net.rim.device.api.synchronization.SyncObject)
public int getSyncObjectCount()
SyncCollection
getSyncObjectCount
in interface SyncCollection
SyncCollection.getSyncObjectCount()
public SyncConverter getSyncConverter()
SyncCollection
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.
getSyncConverter
in interface SyncCollection
SyncCollection.getSyncConverter()
public void beginTransaction()
SyncCollection
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.
beginTransaction
in interface SyncCollection
SyncCollection.beginTransaction()
public void endTransaction()
SyncCollection
The sync manager invokes this method when terminating a
synchronization involving this collection (that it opened by invoking
SyncCollection.beginTransaction()
).
endTransaction
in interface SyncCollection
SyncCollection.endTransaction()
|
|||||||||
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