com.funambol.syncml.client
Class TrackableSyncSource

java.lang.Object
  extended by com.funambol.syncml.client.BaseSyncSource
      extended by com.funambol.syncml.client.TrackableSyncSource
All Implemented Interfaces:
SyncSource
Direct Known Subclasses:
ConfigSyncSource, FileSyncSource

public abstract class TrackableSyncSource
extends BaseSyncSource

An abstract implementation of BaseSyncSource, providing the ability to use a ChangesTracker to automatically trace changes. This class needs a ChangesTracker to be able to track changes and it provides initNewItems, initUpdItems, initDelItems and initAllItems.


Field Summary
protected  ChangesTracker tracker
           
 
Fields inherited from class com.funambol.syncml.client.BaseSyncSource
allIndex, allItems, config, delIndex, delItems, filter, globalStatus, newIndex, newItems, syncMode, updIndex, updItems
 
Fields inherited from interface com.funambol.syncml.spds.SyncSource
ENCODING_B64, ENCODING_NONE, STATUS_CONNECTION_ERROR, STATUS_RECV_ERROR, STATUS_SEND_ERROR, STATUS_SERVER_ERROR, STATUS_SUCCESS
 
Constructor Summary
TrackableSyncSource(SourceConfig config, ChangesTracker tracker)
          TrackableSyncSource constructor: initialize source config
 
Method Summary
 void beginSync(int syncMode)
          Called after SyncManager preparation and initialization just before start the synchronization of the SyncSource.
 void endSync()
          Called just before committing the synchronization process by the SyncManager.
protected abstract  java.util.Enumeration getAllItemsKeys()
           
protected  void initAllItems()
          In a concrete implementation, this function should search the database for all the items present and store their keys.
protected  SyncItem[] initChangedItems(java.util.Enumeration itemsEnum, int itemsCount)
           
protected  void initDelItems()
          In a real implementation, this function should search the database for the deleted items present and store their keys.
protected  void initNewItems()
          In a concrete implementation, this function should search the database for the new items present and store their keys.
protected  void initUpdItems()
          In a real implementation, this function should search the database for the modified items present and store their keys.
 void setItemStatus(java.lang.String key, int status)
          Tell the SyncSource the status returned by the server for an Item previously sent.
 
Methods inherited from class com.funambol.syncml.client.BaseSyncSource
addItem, dataReceived, deleteItem, getClientAddNumber, getClientDeleteNumber, getClientItemsNumber, getClientReplaceNumber, getConfig, getEncoding, getFilter, getItemContent, getLastAnchor, getListener, getName, getNextAnchor, getNextDeletedItem, getNextItem, getNextNewItem, getNextUpdatedItem, getServerItemsNumber, getSourceUri, getStatus, getSyncMode, getType, setConfig, setFilter, setLastAnchor, setListener, setNextAnchor, setServerItemsNumber, updateItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tracker

protected ChangesTracker tracker
Constructor Detail

TrackableSyncSource

public TrackableSyncSource(SourceConfig config,
                           ChangesTracker tracker)
TrackableSyncSource constructor: initialize source config

Method Detail

beginSync

public void beginSync(int syncMode)
               throws SyncException
Description copied from class: BaseSyncSource
Called after SyncManager preparation and initialization just before start the synchronization of the SyncSource.

Specified by:
beginSync in interface SyncSource
Overrides:
beginSync in class BaseSyncSource
Parameters:
syncMode - the synchronization type: one of the values in sync4j.framework.core.AlertCode
Throws:
SyncException - in case of error. This will stop the sync process

endSync

public void endSync()
             throws SyncException
Description copied from class: BaseSyncSource
Called just before committing the synchronization process by the SyncManager. The SyncSource can stop the commit phase raising an exception here.

Specified by:
endSync in interface SyncSource
Overrides:
endSync in class BaseSyncSource
Throws:
SyncException - in case of error, to stop the commit.

initAllItems

protected void initAllItems()
                     throws SyncException
Description copied from class: BaseSyncSource
In a concrete implementation, this function should search the database for all the items present and store their keys.

Specified by:
initAllItems in class BaseSyncSource
Throws:
SyncException - implementation can throw a SyncException to stop the sync on fatal errors.

initNewItems

protected void initNewItems()
                     throws SyncException
Description copied from class: BaseSyncSource
In a concrete implementation, this function should search the database for the new items present and store their keys.

Specified by:
initNewItems in class BaseSyncSource
Throws:
SyncException - implementation can throw a SyncException to stop the sync on fatal errors.

initUpdItems

protected void initUpdItems()
                     throws SyncException
Description copied from class: BaseSyncSource
In a real implementation, this function should search the database for the modified items present and store their keys. The policy to detect a change can vary from one source to another: from generating a CRC to keep the status in a field of the item in the backend database.

Specified by:
initUpdItems in class BaseSyncSource
Throws:
SyncException - implementation can throw a SyncException to stop the sync on fatal errors.

initDelItems

protected void initDelItems()
                     throws SyncException
Description copied from class: BaseSyncSource
In a real implementation, this function should search the database for the deleted items present and store their keys. The policy to detect a deleted item can vary from one source to another: from keeping a list of items after the last sync to keep the items with a deleted flag and then remove them after the successful deletion on the server.

Specified by:
initDelItems in class BaseSyncSource
Throws:
SyncException - implementation can throw a SyncException to stop the sync on fatal errors.

initChangedItems

protected SyncItem[] initChangedItems(java.util.Enumeration itemsEnum,
                                      int itemsCount)

setItemStatus

public void setItemStatus(java.lang.String key,
                          int status)
                   throws SyncException
Description copied from class: BaseSyncSource
Tell the SyncSource the status returned by the server for an Item previously sent. This is a dummy implementation that just logs the status. A concrete implementation can override this method to perform some checks on the received status.

Specified by:
setItemStatus in interface SyncSource
Overrides:
setItemStatus in class BaseSyncSource
Parameters:
key - the key of the item
status - the status code received for that item
Throws:
SyncException - if the SyncSource wants to stop the sync

getAllItemsKeys

protected abstract java.util.Enumeration getAllItemsKeys()


Copyright © 2006 Funambol.