Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.feedhenry.sdk.sync
Class FHSyncClient

    java.lang.Object
      com.feedhenry.sdk.sync.FHSyncClient

    public class FHSyncClient

extends java.lang.Object

The sync client is part of the FeedHenry data sync framework. It provides a mechanism to manage bi-direction data synchronization. For more details, please check data sync framewrok docs.

Field Summary
`protected static java.lang.String` | `LOG_TAG`

Constructor Summary
`FHSyncClient()`

Method Summary
`JSONObject` | `create(java.lang.String pDataId, JSONObject pData)` Create a new data record in dataset with pDataId
`JSONObject` | `delete(java.lang.String pDataId, java.lang.String pUID)` Delete a data record in the dataset with pDataId
`void` | `destroy()` Stop all sync processes for all the datasets managed by the sync client.
`static FHSyncClient` | `getInstance()` Get the singleton instance of the sync client.
`void` | `init(android.content.Context pContext, FHSyncConfig pConfig, FHSyncListener pListener)` Initialize the sync client.
`JSONObject` | `list(java.lang.String pDataId)` List all the data in the dataset with pDataId.
`void` | `listCollisions(java.lang.String pDataId, FHActCallback pCallback)` List sync collisions in dataset with id pDataId
`void` | `manage(java.lang.String pDataId, FHSyncConfig pConfig, JSONObject pQueryParams)` Use the sync client to manage a dataset.
`JSONObject` | `read(java.lang.String pDataId, java.lang.String pUID)` Read a data record with pUID in dataset with pDataId
`void` | `removeCollision(java.lang.String pDataId, java.lang.String pCollisionHash, FHActCallback pCallback)` Remove a sync collision record in the dataset with id pDataId
`void` | `setListener(FHSyncListener pListener)` Re-set the sync listener
`void` | `stop(java.lang.String pDataId)` Stop the sync process for dataset with id pDataId
`JSONObject` | `update(java.lang.String pDataId, java.lang.String pUID, JSONObject pData)` Update an existing data record in dataset with pDataId

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LOG_TAG

    protected static final java.lang.String LOG_TAG

See Also:
  Constant Field Values

Constructor Detail

### FHSyncClient

    public FHSyncClient()

Method Detail

### getInstance

    public static FHSyncClient getInstance()

  Get the singleton instance of the sync client.

  Returns:
    the sync client instance

### init

    public void init(android.content.Context pContext,
                     FHSyncConfig pConfig,
                     FHSyncListener pListener)

  Initialize the sync client. Should be called every time an app/activity starts.

  Parameters:
    `pContext` - The app context
    `pConfig` - The sync configuration
    `pListener` - The sync listener

### setListener

    public void setListener(FHSyncListener pListener)

  Re-set the sync listener

  Parameters:
    `pListener` - the new sync listener

### manage

    public void manage(java.lang.String pDataId,
                       FHSyncConfig pConfig,
                       JSONObject pQueryParams)
                throws java.lang.Exception

  Use the sync client to manage a dataset.

  Parameters:
    `pDataId` - The id of the dataset.
    `pConfig` - The sync configuration for the dataset. If not specified, the sync configuration passed in the init method will be used
    `pQueryParams` - Query parameters for the dataset
  Throws:
    `java.lang.Exception`

### list

    public JSONObject list(java.lang.String pDataId)

  List all the data in the dataset with pDataId.

  Parameters:
    `pDataId` - The id of the dataset
  Returns:
    all data records. Each record contains a key "uid" with the id value and a key "data" with the JSON data.

### read

    public JSONObject read(java.lang.String pDataId,
                           java.lang.String pUID)

  Read a data record with pUID in dataset with pDataId

  Parameters:
    `pDataId` - the id of the dataset
    `pUID` - the id of the data record
  Returns:
    the data record. Each record contains a key "uid" with the id value and a key "data" with the JSON data.

### create

    public JSONObject create(java.lang.String pDataId,
                             JSONObject pData)
                      throws java.lang.Exception

  Create a new data record in dataset with pDataId

  Parameters:
    `pDataId` - the id of the dataset
    `pData` - the actual data
  Returns:
    the created data record. Each record contains a key "uid" with the id value and a key "data" with the JSON data.
  Throws:
    `java.lang.Exception`

### update

    public JSONObject update(java.lang.String pDataId,
                             java.lang.String pUID,
                             JSONObject pData)
                      throws java.lang.Exception

  Update an existing data record in dataset with pDataId

  Parameters:
    `pDataId` - the id of the dataset
    `pUID` - the id of the data record
    `pData` - the new content of the data record
  Returns:
    the updated data record. Each record contains a key "uid" with the id value and a key "data" with the JSON data.
  Throws:
    `java.lang.Exception`

### delete

    public JSONObject delete(java.lang.String pDataId,
                             java.lang.String pUID)
                      throws java.lang.Exception

  Delete a data record in the dataset with pDataId

  Parameters:
    `pDataId` - the id of the dataset
    `pUID` - the id of the data record
  Returns:
    the deleted data record. Each record contains a key "uid" with the id value and a key "data" with the JSON data.
  Throws:
    `java.lang.Exception`

### listCollisions

    public void listCollisions(java.lang.String pDataId,
                               FHActCallback pCallback)
                        throws java.lang.Exception

  List sync collisions in dataset with id pDataId

  Parameters:
    `pDataId` - the id of the dataset
    `pCallback` - the callback function
  Throws:
    `java.lang.Exception`

### removeCollision

    public void removeCollision(java.lang.String pDataId,
                                java.lang.String pCollisionHash,
                                FHActCallback pCallback)
                         throws java.lang.Exception

  Remove a sync collision record in the dataset with id pDataId

  Parameters:
    `pDataId` - the id of the dataset
    `pCollisionHash` - the hash value of the collision record
    `pCallback` - the callback function
  Throws:
    `java.lang.Exception`

### stop

    public void stop(java.lang.String pDataId)
              throws java.lang.Exception

  Stop the sync process for dataset with id pDataId

  Parameters:
    `pDataId` - the id of the dataset
  Throws:
    `java.lang.Exception`

### destroy

    public void destroy()
                 throws java.lang.Exception

  Stop all sync processes for all the datasets managed by the sync client.

  Throws:
    `java.lang.Exception`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD