Sync Android SDK  1.0.3
com.twilio.sync.SyncMap Interface Reference

SyncMap is a key-value store with Strings as keys and arbitrary JSON objects as values. More...

Classes

interface  Item
 Single item in a SyncMap. More...
 
interface  QueryOptions
 Options passed while querying SyncMap objects within Sync specifying query parameters and result set position and sorting. More...
 
enum  QueryOrder
 Defines collection query direction (forward or backwards item listing) More...
 

Public Member Functions

String getSid ()
 Retrieves a machine-generated unique identifier for this SyncMap. More...
 
String getUniqueName ()
 Retrieves a user-set unique name for this SyncMap. More...
 
Date getDateUpdated ()
 Retrieves a Date when the Map was last updated. More...
 
void getItem (String itemKey, SuccessListener< Item > listener)
 Retrieve Item from the SyncMap. More...
 
void setItem (String itemKey, JSONObject itemData, SuccessListener< Item > listener)
 Set Item in the SyncMap. More...
 
void setItem (String itemKey, JSONObject itemData, Item.Metadata metadata, SuccessListener< Item > listener)
 Set Item in the SyncMap. More...
 
void mutateItem (String itemKey, SyncMutator mutator, SuccessListener< Item > listener)
 Mutate Item in the SyncMap. More...
 
void mutateItem (String itemKey, SyncMutator mutator, Item.Metadata metadata, SuccessListener< Item > listener)
 Mutate Item in the SyncMap. More...
 
void setTtl (int ttl, SuccessListener< Void > listener)
 Set time to live for map object in seconds. More...
 
void setItemTtl (String itemKey, int ttl, SuccessListener< Void > listener)
 Set time to live for an item in list. More...
 
void removeItem (String itemKey, SuccessListener< Void > listener)
 Remove Item from the SyncMap. More...
 
void getItems (SuccessListener< SyncMapIterator > listener)
 Get iterator access to all items in the map. More...
 
QueryOptions queryOptions ()
 Provide options for querying items from the SyncMap. More...
 
void queryItems (QueryOptions options, SuccessListener< SyncMapPaginator > listener)
 Query paginated sequence of items from the map, based on query options. More...
 
void removeMap (SuccessListener< Void > listener)
 Remove entire SyncMap object. More...
 

Public Attributes

int INFINITE_DURATION = 0
 Time to live for a map, specifying no expiry.
 

Detailed Description

SyncMap is a key-value store with Strings as keys and arbitrary JSON objects as values.

You can add, remove and modify values associated with the keys.

To obtain an instance of a SyncMap use SyncClient#openMap.

Member Function Documentation

Date com.twilio.sync.SyncMap.getDateUpdated ( )

Retrieves a Date when the Map was last updated.

Returns
Date this Map was last updated.
void com.twilio.sync.SyncMap.getItem ( String  itemKey,
SuccessListener< Item listener 
)

Retrieve Item from the SyncMap.

Parameters
itemKeyKey of the item to retrieve.
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncMap.getItems ( SuccessListener< SyncMapIterator listener)

Get iterator access to all items in the map.

Parameters
listenerAsync result listener. See SuccessListener.
String com.twilio.sync.SyncMap.getSid ( )

Retrieves a machine-generated unique identifier for this SyncMap.

Returns
Map SID.
String com.twilio.sync.SyncMap.getUniqueName ( )

Retrieves a user-set unique name for this SyncMap.

Returns
Map Unique Name.
void com.twilio.sync.SyncMap.mutateItem ( String  itemKey,
SyncMutator  mutator,
SuccessListener< Item listener 
)

Mutate Item in the SyncMap.

Uses default metadata.

Parameters
itemKeyKey of the item to mutate.
mutatorMutator function object.
listenerAsync result listener. See SuccessListener.
See also
SyncMutator
void com.twilio.sync.SyncMap.mutateItem ( String  itemKey,
SyncMutator  mutator,
Item.Metadata  metadata,
SuccessListener< Item listener 
)

Mutate Item in the SyncMap.

Parameters
itemKeyKey of the item to mutate.
mutatorMutator function object.
metadataOptional metadata for the set item, currently only ttl.
listenerAsync result listener. See SuccessListener.
See also
SyncMutator
void com.twilio.sync.SyncMap.queryItems ( QueryOptions  options,
SuccessListener< SyncMapPaginator listener 
)

Query paginated sequence of items from the map, based on query options.

The order of items within the page is not guaranteed.

Parameters
optionsSpecific query options.
listenerAsync result listener. See SuccessListener.
QueryOptions com.twilio.sync.SyncMap.queryOptions ( )

Provide options for querying items from the SyncMap.

Returns
Default query options upon which you can build.
See also
SyncOptions
void com.twilio.sync.SyncMap.removeItem ( String  itemKey,
SuccessListener< Void >  listener 
)

Remove Item from the SyncMap.

Parameters
itemKeyKey of the item to remove.
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncMap.removeMap ( SuccessListener< Void >  listener)

Remove entire SyncMap object.

Parameters
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncMap.setItem ( String  itemKey,
JSONObject  itemData,
SuccessListener< Item listener 
)

Set Item in the SyncMap.

Uses default metadata.

Parameters
itemKeyKey of the item to set.
itemDataItem data to set as a JSON object.
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncMap.setItem ( String  itemKey,
JSONObject  itemData,
Item.Metadata  metadata,
SuccessListener< Item listener 
)

Set Item in the SyncMap.

Parameters
itemKeyKey of the item to set.
itemDataItem data to set as a JSON object.
metadataOptional metadata for the set item, currently only ttl.
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncMap.setItemTtl ( String  itemKey,
int  ttl,
SuccessListener< Void >  listener 
)

Set time to live for an item in list.

TTL specifies the minimum time the Item will live, sometime soon after this time the object will be deleted.

If time to live is not specified, object lives infinitely long.

TTL could be used in order to auto-recycle old unused objects, but it is not recommended to build some app logic like timers using ttl.

Parameters
itemKeyThe key of the item to adjust the ttl for.
ttlTime to live in seconds from now or Item#INFINITE_DURATION to indicate no expiry.
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncMap.setTtl ( int  ttl,
SuccessListener< Void >  listener 
)

Set time to live for map object in seconds.

This TTL specifies the minimum time the SyncMap will live, sometime soon after this time the object will be deleted.

If time to live is not specified, object lives infinitely long.

TTL could be used in order to auto-recycle old unused objects, but it is not recommended to build some app logic like timers using ttl.

Parameters
ttlTime to live in seconds from now or INFINITE_DURATION to indicate no expiry.
listenerAsync result listener. See SuccessListener.