|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.funambol.syncml.client.TrackableSyncSource
public abstract class TrackableSyncSource
An abstract implementation of SyncSource, providing the ability to use a ChangesTracker to automatically trace changes. This class needs a ChangesTracker to be able to track changes
Field Summary | |
---|---|
protected java.util.Enumeration |
allItems
All items for slow syncs |
protected SourceConfig |
config
SyncSource configuration |
protected java.util.Enumeration |
delItems
Deleted items for fast syncs |
protected SyncFilter |
filter
Synchronization filter |
protected int |
globalStatus
Status of the sync source summarized in an integer value. |
protected java.util.Enumeration |
newItems
New items for fast syncs |
protected int |
syncMode
SyncMode, set by beginSync |
protected ChangesTracker |
tracker
|
protected java.util.Enumeration |
updItems
Updated items for fast syncs |
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 | |
---|---|
int |
addItem(SyncItem item)
The purpose of this implementation is simply to notify the tracker. |
void |
beginSync(int syncMode)
Called after SyncManager preparation and initialization just before start the synchronization of the SyncSource. |
SyncItem |
createSyncItem(java.lang.String key,
java.lang.String type,
char state,
java.lang.String parent,
long size)
Creates a new SyncItem for the engine to store incoming items |
void |
dataReceived(java.lang.String date,
int size)
Default implementation for |
protected abstract void |
deleteAllItems()
Physically delete all items |
int |
deleteItem(java.lang.String key)
The purpose of this implementation is simply to notify the tracker. |
void |
endSync()
Called just before committing the synchronization process by the SyncManager. |
protected abstract java.util.Enumeration |
getAllItemsKeys()
|
int |
getClientAddNumber()
Return the number of new items (add) that the client will send during the session. |
int |
getClientDeleteNumber()
Return the number of deleted items that the client will send during the session. |
int |
getClientItemsNumber()
Return the number of changes that the client will send during the session. |
int |
getClientReplaceNumber()
Return the number of replaced items that the client will send during the session. |
SourceConfig |
getConfig()
Returns the config of the source. |
java.lang.String |
getEncoding()
Returns the encoding of the source. |
SyncFilter |
getFilter()
Returns the current filter for this SyncSource. |
protected abstract SyncItem |
getItemContent(SyncItem item)
|
long |
getLastAnchor()
Return the Last Anchor for this source |
SyncListener |
getListener()
Returns the current listener (or null if not set) |
java.lang.String |
getName()
Returns the name of the source |
long |
getNextAnchor()
Return the Next Anchor for this source |
SyncItem |
getNextDeletedItem()
Returns a SyncItem containing the key of the first/next deleted item of the store (locally removed after the last sync, but not yet deleted on server) |
SyncItem |
getNextItem()
Returns the next item of the store (for slow sync). |
SyncItem |
getNextNewItem()
Returns the first/next new item of the store. |
SyncItem |
getNextUpdatedItem()
Returns the first/next updated item of the store (changed from the last sync) |
int |
getServerItemsNumber()
Return the number of changes that the server will send during the session. |
java.lang.String |
getSourceUri()
Returns the source URI |
int |
getStatus()
Returns the status of the sync source. |
int |
getSyncMode()
Returns the preferred sync mode of the source. |
ChangesTracker |
getTracker()
Return the current tracker for this source |
java.lang.String |
getType()
Returns the type of the source. |
void |
setConfig(SourceConfig config)
Sets the config of the source. |
void |
setFilter(SyncFilter filter)
Set a new filter for this SyncSource |
void |
setItemStatus(java.lang.String key,
int status)
Tell the SyncSource the status returned by the server for an Item previously sent. |
void |
setLastAnchor(long time)
Set the value of the Last Anchor for this source |
void |
setListener(SyncListener listener)
Set a sync listener. |
void |
setNextAnchor(long time)
Set the value of the Next Anchor for this source |
void |
setServerItemsNumber(int number)
Set the number of changes that the server will send during the session. |
void |
setTracker(ChangesTracker tracker)
Re-sets the tracker. |
int |
updateItem(SyncItem item)
The purpose of this implementation is simply to notify the tracker. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ChangesTracker tracker
protected java.util.Enumeration allItems
protected java.util.Enumeration newItems
protected java.util.Enumeration updItems
protected java.util.Enumeration delItems
protected SourceConfig config
protected SyncFilter filter
protected int syncMode
protected int globalStatus
Constructor Detail |
---|
public TrackableSyncSource(SourceConfig config, ChangesTracker tracker)
Method Detail |
---|
public void setTracker(ChangesTracker tracker)
tracker
- the new trackerpublic final ChangesTracker getTracker()
public void beginSync(int syncMode) throws SyncException
SyncSource
beginSync
in interface SyncSource
syncMode
- the synchronization type: one of the values in
sync4j.framework.core.AlertCode
SyncException
- in case of error. This will stop the sync processpublic void endSync() throws SyncException
SyncSource
endSync
in interface SyncSource
SyncException
- in case of error, to stop the commit.public SyncItem getNextItem() throws SyncException
SyncSource
The method returns the set of items in the source. This set can be frozen just after the beginSync is invoked or it can change as new changes are applied. The method only guarantees that it returns all the items that were in the store when beginSync got invoked. When an item is returned by this method it may be no longer in the source if it got deleted. In other words there is no guarantee an item returned is still in the source. This method acts as an iterator and is guaranteed to be initialized after beginSync.
getNextItem
in interface SyncSource
SyncException
public SyncItem getNextNewItem() throws SyncException
SyncSource
The implementation of this method must iterate on the items of the
source not yet sent to the server, starting from the first one after a
beginSync() call and returning null
when no more items are
available.
getNextNewItem
in interface SyncSource
SyncException
public SyncItem getNextUpdatedItem() throws SyncException
SyncSource
getNextUpdatedItem
in interface SyncSource
SyncException
public SyncItem getNextDeletedItem() throws SyncException
SyncSource
getNextDeletedItem
in interface SyncSource
SyncException
public void setItemStatus(java.lang.String key, int status) throws SyncException
SyncSource
setItemStatus
in interface SyncSource
key
- the key of the itemstatus
- the status code received for that item
SyncException
- if the SyncSource wants to stop the syncpublic SyncItem createSyncItem(java.lang.String key, java.lang.String type, char state, java.lang.String parent, long size)
createSyncItem
in interface SyncSource
key
- is the item keytype
- is the item typestate
- this item's stateparent
- is the item's parentsize
- is the item sizepublic int addItem(SyncItem item) throws SyncException
addItem
in interface SyncSource
item
- is the item being added
SyncException
- if an unrecoverable error occur, to stop the syncpublic int updateItem(SyncItem item) throws SyncException
updateItem
in interface SyncSource
item
- is the item being updated
SyncException
- if an unrecoverable error occur, to stop the syncpublic int deleteItem(java.lang.String key) throws SyncException
deleteItem
in interface SyncSource
key
- is the key of the item being deleted
SyncException
- if an unrecoverable error occur, to stop the syncpublic SourceConfig getConfig()
getConfig
in interface SyncSource
public void setConfig(SourceConfig config)
setConfig
in interface SyncSource
public int getStatus()
getStatus
in interface SyncSource
public void setListener(SyncListener listener)
setListener
in interface SyncSource
listener
- the listener or null to remove itpublic SyncListener getListener()
getListener
in interface SyncSource
public java.lang.String getName()
getName
in interface SyncSource
public java.lang.String getSourceUri()
getSourceUri
in interface SyncSource
public java.lang.String getType()
getType
in interface SyncSource
public java.lang.String getEncoding()
getEncoding
in interface SyncSource
public int getSyncMode()
getSyncMode
in interface SyncSource
public SyncFilter getFilter()
getFilter
in interface SyncSource
public void setFilter(SyncFilter filter)
setFilter
in interface SyncSource
public int getClientItemsNumber()
getClientItemsNumber
in interface SyncSource
public int getClientAddNumber()
getClientAddNumber
in interface SyncSource
public int getClientReplaceNumber()
getClientReplaceNumber
in interface SyncSource
public int getClientDeleteNumber()
getClientDeleteNumber
in interface SyncSource
public int getServerItemsNumber()
getServerItemsNumber
in interface SyncSource
public void setServerItemsNumber(int number)
setServerItemsNumber
in interface SyncSource
number
- of changes from the server, or -1 if not announced.public void dataReceived(java.lang.String date, int size)
dataReceived
in interface SyncSource
public long getLastAnchor()
getLastAnchor
in interface SyncSource
public void setLastAnchor(long time)
setLastAnchor
in interface SyncSource
public long getNextAnchor()
getNextAnchor
in interface SyncSource
public void setNextAnchor(long time)
setNextAnchor
in interface SyncSource
protected abstract java.util.Enumeration getAllItemsKeys()
protected abstract SyncItem getItemContent(SyncItem item) throws SyncException
SyncException
protected abstract void deleteAllItems()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |