|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.funambol.syncml.client.BaseSyncSource
public abstract class BaseSyncSource
An abstract implementation of the SyncSource interface, providing the basic framework each SyncSource has to implement. A developer can choose to extends BaseSyncSource or to implements SyncSource directly if needed. The class BaseSyncSource uses the SyncConfig to store the source configuration data. With this class is possible to alter the source configuration, which is not permitted by the SyncSource interface.
Field Summary | |
---|---|
protected int |
allIndex
|
protected SyncItem[] |
allItems
|
protected SourceConfig |
config
SyncSource configuration |
protected int |
delIndex
|
protected SyncItem[] |
delItems
|
protected SyncFilter |
filter
Synchronization filter |
protected int |
globalStatus
Status of the sync source summarized in an integer value. |
protected int |
newIndex
|
protected SyncItem[] |
newItems
|
protected int |
syncMode
SyncMode, set by beginSync |
protected int |
updIndex
|
protected SyncItem[] |
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 | |
---|---|
BaseSyncSource(SourceConfig config)
BaseSyncSource constructor: initialize source config |
Method Summary | |
---|---|
abstract int |
addItem(SyncItem item)
Add a new SyncItem to this source backend. |
void |
beginSync(int syncMode)
Called after SyncManager preparation and initialization just before start the synchronization of the SyncSource. |
void |
dataReceived(java.lang.String date,
int size)
Default implementation for |
abstract int |
deleteItem(java.lang.String key)
Delete a SyncItem stored in the source backend. |
void |
endSync()
Called just before committing the synchronization process by the SyncManager. |
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)
This function gets the item content in the backend database and returns a complete item. |
long |
getLastAnchor()
Return the Last Anchor for this source |
com.funambol.util.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. |
SyncItem |
getNextNewItem()
Returns the next new item of the store (not yet sent to the server) |
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. |
java.lang.String |
getType()
Returns the type of the source. |
protected abstract void |
initAllItems()
In a concrete implementation, this function should search the database for all the items present and store their keys. |
protected abstract void |
initDelItems()
In a real implementation, this function should search the database for the deleted items present and store their keys. |
protected abstract void |
initNewItems()
In a concrete implementation, this function should search the database for the new items present and store their keys. |
protected abstract void |
initUpdItems()
In a real implementation, this function should search the database for the modified items present and store their keys. |
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(com.funambol.util.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. |
abstract int |
updateItem(SyncItem item)
Update a given SyncItem stored in the source backend. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected SourceConfig config
protected SyncFilter filter
protected int syncMode
protected SyncItem[] allItems
protected SyncItem[] newItems
protected SyncItem[] updItems
protected SyncItem[] delItems
protected int allIndex
protected int newIndex
protected int updIndex
protected int delIndex
protected int globalStatus
Constructor Detail |
---|
public BaseSyncSource(SourceConfig config)
Method Detail |
---|
public SourceConfig getConfig()
public void setConfig(SourceConfig config)
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 abstract int addItem(SyncItem item) throws SyncException
addItem
in interface SyncSource
item
- the SyncItem to add, with the GUID sent by the server.
The source is resposible to set it to the LUID before
returning a successful status code.
SyncException
- if an unrecoverable error occur, to stop the syncpublic abstract int updateItem(SyncItem item) throws SyncException
updateItem
in interface SyncSource
item
- the SyncItem to update. The key of the item is already
the LUID.
SyncException
- if an unrecoverable error occur, to stop the syncpublic abstract int deleteItem(java.lang.String key) throws SyncException
deleteItem
in interface SyncSource
key
- The key of the item to delete.
SyncException
- if an unrecoverable error occur, to stop the syncpublic SyncItem getNextItem() throws SyncException
getNextItem
in interface SyncSource
SyncException
public SyncItem getNextNewItem() throws SyncException
getNextNewItem
in interface SyncSource
SyncException
public SyncItem getNextUpdatedItem() throws SyncException
getNextUpdatedItem
in interface SyncSource
SyncException
public SyncItem getNextDeletedItem() throws SyncException
getNextDeletedItem
in interface SyncSource
SyncException
public void setItemStatus(java.lang.String key, int status) throws SyncException
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 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
public void beginSync(int syncMode) throws SyncException
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
endSync
in interface SyncSource
SyncException
- in case of error, to stop the commit.public void setListener(com.funambol.util.SyncListener listener)
setListener
in interface SyncSource
listener
- the listener or null to remove itpublic com.funambol.util.SyncListener getListener()
getListener
in interface SyncSource
public int getStatus()
getStatus
in interface SyncSource
protected abstract void initAllItems() throws SyncException
SyncException
- implementation can throw a SyncException
to stop the sync on fatal errors.protected abstract void initNewItems() throws SyncException
SyncException
- implementation can throw a SyncException
to stop the sync on fatal errors.protected abstract void initUpdItems() throws SyncException
SyncException
- implementation can throw a SyncException
to stop the sync on fatal errors.protected abstract void initDelItems() throws SyncException
SyncException
- implementation can throw a SyncException
to stop the sync on fatal errors.protected abstract SyncItem getItemContent(SyncItem item) throws SyncException
The content of the item depends also from the encoding of this SyncSource:
SyncException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |