com.funambol.syncml.client
Class FileSyncSource

java.lang.Object
  extended by com.funambol.syncml.client.BaseSyncSource
      extended by com.funambol.syncml.client.TrackableSyncSource
          extended by com.funambol.syncml.client.FileSyncSource
All Implemented Interfaces:
SyncSource

public class FileSyncSource
extends TrackableSyncSource

An implementation of TrackableSyncSource, providing the ability sync briefcases (files)


Field Summary
 
Fields inherited from class com.funambol.syncml.client.TrackableSyncSource
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
FileSyncSource(SourceConfig config, ChangesTracker tracker, java.lang.String directory)
          FileSyncSource constructor: initialize source config
 
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.
 int deleteItem(java.lang.String key)
          Delete a SyncItem stored in the source backend.
protected  java.util.Enumeration getAllItemsKeys()
           
protected  SyncItem getItemContent(SyncItem item)
          This function gets the item content in the backend database and returns a complete item.
 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 updateItem(SyncItem item)
          Update a given SyncItem stored in the source backend.
 
Methods inherited from class com.funambol.syncml.client.TrackableSyncSource
endSync, initAllItems, initChangedItems, initDelItems, initNewItems, initUpdItems, setItemStatus
 
Methods inherited from class com.funambol.syncml.client.BaseSyncSource
dataReceived, getClientAddNumber, getClientDeleteNumber, getClientItemsNumber, getClientReplaceNumber, getConfig, getEncoding, getFilter, getLastAnchor, getListener, getName, getNextAnchor, getNextDeletedItem, getServerItemsNumber, getSourceUri, getStatus, getSyncMode, getType, setConfig, setFilter, setLastAnchor, setListener, setNextAnchor, setServerItemsNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSyncSource

public FileSyncSource(SourceConfig config,
                      ChangesTracker tracker,
                      java.lang.String directory)
FileSyncSource 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 TrackableSyncSource
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

getAllItemsKeys

protected java.util.Enumeration getAllItemsKeys()
                                         throws SyncException
Specified by:
getAllItemsKeys in class TrackableSyncSource
Throws:
SyncException

getNextItem

public SyncItem getNextItem()
                     throws SyncException
Description copied from class: BaseSyncSource
Returns the next item of the store.

Specified by:
getNextItem in interface SyncSource
Overrides:
getNextItem in class BaseSyncSource
Returns:
the current item or null if no more items
Throws:
SyncException

getNextNewItem

public SyncItem getNextNewItem()
                        throws SyncException
Description copied from class: BaseSyncSource
Returns the next new item of the store (not yet sent to the server)

Specified by:
getNextNewItem in interface SyncSource
Overrides:
getNextNewItem in class BaseSyncSource
Returns:
the first new item, in a SyncItem object, or null if no new items are present.
Throws:
SyncException

getNextUpdatedItem

public SyncItem getNextUpdatedItem()
                            throws SyncException
Description copied from class: BaseSyncSource
Returns the first/next updated item of the store (changed from the last sync)

Specified by:
getNextUpdatedItem in interface SyncSource
Overrides:
getNextUpdatedItem in class BaseSyncSource
Returns:
the first updated item, in a SyncItem object, or null if no updated items are present.
Throws:
SyncException

addItem

public int addItem(SyncItem item)
            throws SyncException
Description copied from class: BaseSyncSource
Add a new SyncItem to this source backend. The item key after a successful add must contain the local UID, that is used by the engine to send the mappings to the server. The source must then change the item key accordingly before return.

Specified by:
addItem in interface SyncSource
Specified by:
addItem in class BaseSyncSource
Parameters:
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.
Returns:
the status code of the operation. It will be returned to the server in the response for this item.
Throws:
SyncException - if an unrecoverable error occur, to stop the sync

updateItem

public int updateItem(SyncItem item)
               throws SyncException
Description copied from class: BaseSyncSource
Update a given SyncItem stored in the source backend.

Specified by:
updateItem in interface SyncSource
Specified by:
updateItem in class BaseSyncSource
Parameters:
item - the SyncItem to update. The key of the item is already the LUID.
Returns:
the status code of the operation. It will be returned to the server in the response for this item.
Throws:
SyncException - if an unrecoverable error occur, to stop the sync

deleteItem

public int deleteItem(java.lang.String key)
               throws SyncException
Description copied from class: BaseSyncSource
Delete a SyncItem stored in the source backend.

Specified by:
deleteItem in interface SyncSource
Specified by:
deleteItem in class BaseSyncSource
Parameters:
key - The key of the item to delete.
Returns:
the status code of the operation. It will be returned to the server in the response for this item.
Throws:
SyncException - if an unrecoverable error occur, to stop the sync

getItemContent

protected SyncItem getItemContent(SyncItem item)
                           throws SyncException
Description copied from class: BaseSyncSource
This function gets the item content in the backend database and returns a complete item. The parameter item is marked final because should not be used for the filled item: it is a reference to the array entry, and filling it would cause the array to keep all the filled items at the end (the gc will not dispose them).

The content of the item depends also from the encoding of this SyncSource:

  • if the encoding is none, it must be a String, converted with getBytes(), so the engine will send it unchanged.
  • if the encoding is b64, the content can be binary, and the type should be set accordingly, so that the receiving source can handle it. In this way, the binary content is transferred encoded in the SyncML message. This encoding can be applied to a test item too, to avoid problems with charset or other, like what is done with the SIF format.

    Specified by:
    getItemContent in class BaseSyncSource
    Throws:
    SyncException


  • Copyright © 2006 Funambol.