|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.funambol.syncml.client.CacheTracker
public class CacheTracker
This class implements a ChangesTracker and it is based on comparison of fingerprints. This means that the class can take a snapshot of the SyncSource and store it in a StringKeyValueStore (a parameter the client must provide). For each item in the SyncSource its fingerprint is stored in the store. When getNewItems, getUpdatedItems and getDeletedItems are invoked, they compare the SyncSource current state and the last snapshot and detect changes. By default MD5 is used to compute fingerprints, but the method can be redefined if a client wants to use a different method.
Field Summary | |
---|---|
protected java.util.Hashtable |
deletedItems
|
protected java.util.Hashtable |
newItems
|
protected TrackableSyncSource |
ss
|
protected StringKeyValueStore |
status
|
protected int |
syncMode
|
protected java.util.Hashtable |
updatedItems
|
Constructor Summary | |
---|---|
CacheTracker(StringKeyValueStore status)
Creates a CacheTracker. |
Method Summary | |
---|---|
void |
begin(int syncMode)
This method allows implementations to get ready to return list of changes. |
protected java.lang.String |
computeFingerprint(SyncItem item)
|
void |
empty()
Empty the tracker status. |
void |
end()
This method allows implementations to clean data. |
protected java.util.Hashtable |
getAllFilesFingerprint()
Create an hashtable with all files and their fingerprints |
java.util.Enumeration |
getDeletedItems()
Returns the list of deleted items. |
int |
getDeletedItemsCount()
Returns the number of deleted items that will be returned by the getDeletedItems method |
java.util.Enumeration |
getNewItems()
Returns the list of new items. |
int |
getNewItemsCount()
Returns the number of new items that will be returned by the getNewItems method |
java.util.Enumeration |
getUpdatedItems()
Returns the list of updated items. |
int |
getUpdatedItemsCount()
Returns the number of deleted items that will be returned by the getDeletedItems method |
protected boolean |
isSuccess(int status)
|
boolean |
removeItem(SyncItem item)
Remove the given item from the list of changes |
void |
reset()
This method cleans any pending change. |
void |
setItemStatus(java.lang.String key,
int itemStatus)
Set an item status returned by the server as result of the synchronization. |
void |
setSyncSource(TrackableSyncSource ss)
Associates this tracker to the given sync source |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Hashtable newItems
protected java.util.Hashtable deletedItems
protected java.util.Hashtable updatedItems
protected TrackableSyncSource ss
protected StringKeyValueStore status
protected int syncMode
Constructor Detail |
---|
public CacheTracker(StringKeyValueStore status)
status
- is the key value store with stored dataMethod Detail |
---|
public void setSyncSource(TrackableSyncSource ss)
setSyncSource
in interface ChangesTracker
ss
- the sync sourcepublic void reset() throws TrackerException
reset
in interface ChangesTracker
TrackerException
public void begin(int syncMode) throws TrackerException
ChangesTracker
begin
in interface ChangesTracker
syncMode
- The sync mode
TrackerException
public void end() throws TrackerException
ChangesTracker
end
in interface ChangesTracker
TrackerException
public java.util.Enumeration getNewItems() throws TrackerException
getNewItems
in interface ChangesTracker
TrackerException
public int getNewItemsCount() throws TrackerException
getNewItemsCount
in interface ChangesTracker
TrackerException
public java.util.Enumeration getUpdatedItems() throws TrackerException
getUpdatedItems
in interface ChangesTracker
TrackerException
public int getUpdatedItemsCount() throws TrackerException
getUpdatedItemsCount
in interface ChangesTracker
TrackerException
public java.util.Enumeration getDeletedItems() throws TrackerException
getDeletedItems
in interface ChangesTracker
TrackerException
public int getDeletedItemsCount() throws TrackerException
getDeletedItemsCount
in interface ChangesTracker
TrackerException
public void setItemStatus(java.lang.String key, int itemStatus) throws TrackerException
ChangesTracker
setItemStatus
in interface ChangesTracker
key
- the item key (cannot be null)itemStatus
- the syncml status for this item
TrackerException
protected java.lang.String computeFingerprint(SyncItem item)
protected java.util.Hashtable getAllFilesFingerprint() throws SyncException
SyncException
protected boolean isSuccess(int status)
public boolean removeItem(SyncItem item) throws TrackerException
ChangesTracker
removeItem
in interface ChangesTracker
item
- is the item to be removed
TrackerException
public void empty() throws TrackerException
ChangesTracker
empty
in interface ChangesTracker
TrackerException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |