|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SyncSource
A SyncSource is responsible for storing and retrieving SyncItem objects from/to an external data source. Note that the SyncSource interface makes no assumptions about the underlying data source or about how data are formatted: each concrete implementation will use its specific storage and format.
A SyncSource is not used directly by the host application, instead its methods are called by the synchronization engine during modifications analysis.
The SyncSource methods are designed to perform an efficient synchronization process, letting the source selecting the changed items instead of doing more complex field by field comparison. It is responsibility of the source developer to make sure that the getNextNew/Updated/DeletedItem() methods return the correct values.
The configuration information required to set up a SyncSource is stored in the class SourceConfig , used by the BaseSyncSource class.
Field Summary | |
---|---|
static java.lang.String |
ENCODING_B64
|
static java.lang.String |
ENCODING_NONE
|
static int |
STATUS_CONNECTION_ERROR
A problem with the connection to the remote server occurred |
static int |
STATUS_RECV_ERROR
At least one message has an error during receive |
static int |
STATUS_SEND_ERROR
At least one message has an error during send |
static int |
STATUS_SERVER_ERROR
An error occurred with the remote server. |
static int |
STATUS_SUCCESS
No error for this session |
Method Summary | |
---|---|
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)
Called by the engine when new data has been received by the server, before processing it. |
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. |
java.lang.String |
getEncoding()
Returns the encoding of the source. |
SyncFilter |
getFilter()
Return the current filter for this SyncSource |
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 (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()
Retiurn 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()
Return the preferred sync mode of the source. |
java.lang.String |
getType()
Returns the type 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. |
int |
updateItem(SyncItem item)
Update a given SyncItem stored in the source backend. |
Field Detail |
---|
static final java.lang.String ENCODING_NONE
static final java.lang.String ENCODING_B64
static final int STATUS_SUCCESS
static final int STATUS_SEND_ERROR
static final int STATUS_RECV_ERROR
static final int STATUS_SERVER_ERROR
static final int STATUS_CONNECTION_ERROR
Method Detail |
---|
java.lang.String getName()
java.lang.String getSourceUri()
java.lang.String getType()
java.lang.String getEncoding()
int getSyncMode()
SyncFilter getFilter()
void setFilter(SyncFilter filter)
int addItem(SyncItem item) throws SyncException
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 syncint updateItem(SyncItem item) throws SyncException
item
- the SyncItem to update. The key of the item is already
the LUID.
SyncException
- if an unrecoverable error occur, to stop the syncint deleteItem(java.lang.String key) throws SyncException
key
- The key of the item to delete.
SyncException
- if an unrecoverable error occur, to stop the syncSyncItem getNextItem() throws SyncException
The implementation of this method must iterate on all the
items of the source, starting from the first after a beginSync()
call and returning null
when no more items
are available.
SyncException
SyncItem getNextNewItem() throws SyncException
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.
SyncException
SyncItem getNextUpdatedItem() throws SyncException
SyncException
SyncItem getNextDeletedItem() throws SyncException
SyncException
void setItemStatus(java.lang.String key, int status) throws SyncException
key
- the key of the itemstatus
- the status code received for that item
SyncException
- if the SyncSource wants to stop the syncvoid dataReceived(java.lang.String date, int size)
int getClientItemsNumber()
int getClientAddNumber()
int getClientReplaceNumber()
int getClientDeleteNumber()
int getServerItemsNumber()
void setServerItemsNumber(int number)
number
- of changes from the server, or -1 if not announced.long getLastAnchor()
void setLastAnchor(long time)
long getNextAnchor()
void setNextAnchor(long time)
void beginSync(int syncMode) throws SyncException
syncMode
- the synchronization type: one of the values in
sync4j.framework.core.AlertCode
SyncException
- in case of error. This will stop the sync processvoid endSync() throws SyncException
SyncException
- in case of error, to stop the commit.void setListener(com.funambol.util.SyncListener listener)
listener
- the listener or null to remove itcom.funambol.util.SyncListener getListener()
int getStatus()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |