public class Map
extends java.lang.Object
You can add, remove and modify values associated with the keys.
To obtain an instance of a Map use SyncClient.openMap(com.twilio.sync.Options, com.twilio.sync.MapObserver, com.twilio.sync.SuccessListener<com.twilio.sync.Map>)
.
Modifier and Type | Class and Description |
---|---|
static class |
Map.Item
Single item in a Map.
|
static class |
Map.PageSort
Defines result ordering within a single paginator page.
|
static class |
Map.QueryOptions
Defines query options for requesting items from a Map.
|
static class |
Map.QueryOrder
Defines collection query direction (forward or backwards item listing)
|
Modifier and Type | Field and Description |
---|---|
int |
InfiniteDuration |
Modifier and Type | Method and Description |
---|---|
void |
dispose() |
void |
getItem(java.lang.String itemKey,
SuccessListener<Map.Item> listener)
Retrieve Item from the Map.
|
void |
getItems(SuccessListener<MapIterator> listener)
Get iterator access to all items in the map.
|
java.lang.String |
getSid()
Retrieves a machine-generated unique identifier for this Map.
|
java.lang.String |
getUniqueName()
Retrieves a user-set unique name for this Map.
|
void |
mutateItem(java.lang.String itemKey,
Mutator mutator,
Map.Item.Metadata metadata,
SuccessListener<Map.Item> listener)
Mutate Item in the Map.
|
void |
mutateItem(java.lang.String itemKey,
Mutator mutator,
SuccessListener<Map.Item> listener)
Mutate Item in the Map.
|
void |
queryItems(Map.QueryOptions options,
SuccessListener<MapPaginator> listener)
Query paginated sequence of items from the map, based on query options.
|
Map.QueryOptions |
queryOptions()
Provide options for querying items from the Map.
|
void |
removeItem(java.lang.String itemKey,
SuccessListener<java.lang.Void> listener)
Remove Item from the Map.
|
void |
removeMap(SuccessListener<java.lang.Void> listener)
Remove entire Map object.
|
void |
setItem(java.lang.String itemKey,
org.json.JSONObject itemData,
Map.Item.Metadata metadata,
SuccessListener<Map.Item> listener)
Set Item in the Map.
|
void |
setItem(java.lang.String itemKey,
org.json.JSONObject itemData,
SuccessListener<Map.Item> listener)
Set Item in the Map.
|
void |
setItemTtl(java.lang.String itemKey,
int ttl,
SuccessListener<java.lang.Void> listener)
Update the map item’s time to live.
|
void |
setTtl(int ttl,
SuccessListener<java.lang.Void> listener)
Update the map’s time to live.
|
public final int InfiniteDuration
public java.lang.String getSid()
public java.lang.String getUniqueName()
public void getItem(java.lang.String itemKey, SuccessListener<Map.Item> listener)
itemKey
- Key of the item to retrieve.listener
- Async result listener. See SuccessListener
.public void setItem(java.lang.String itemKey, org.json.JSONObject itemData, SuccessListener<Map.Item> listener)
itemKey
- Key of the item to set.itemData
- Item data to set as a JSON object.listener
- Async result listener. See SuccessListener
.public void setItem(java.lang.String itemKey, org.json.JSONObject itemData, Map.Item.Metadata metadata, SuccessListener<Map.Item> listener)
itemKey
- Key of the item to set.itemData
- Item data to set as a JSON object.metadata
- Optional metadata for the set item, currently only ttl.listener
- Async result listener. See SuccessListener
.public void mutateItem(java.lang.String itemKey, Mutator mutator, SuccessListener<Map.Item> listener)
itemKey
- Key of the item to mutate.mutator
- Mutator function object.listener
- Async result listener. See SuccessListener
.Mutator
public void mutateItem(java.lang.String itemKey, Mutator mutator, Map.Item.Metadata metadata, SuccessListener<Map.Item> listener)
itemKey
- Key of the item to mutate.mutator
- Mutator function object.metadata
- Optional metadata for the set item, currently only ttl.listener
- Async result listener. See SuccessListener
.Mutator
public void setTtl(int ttl, SuccessListener<java.lang.Void> listener)
ttl
- The new time to live for this map in seconds from now
or InfiniteDuration
to indicate no expiry.listener
- Async result listener. See SuccessListener
.public void setItemTtl(java.lang.String itemKey, int ttl, SuccessListener<java.lang.Void> listener)
itemKey
- The key of the item to adjust the ttl for.ttl
- The new time to live for this map item in seconds from now
or Map.Item.InfiniteDuration
to indicate no expiry.listener
- Async result listener. See SuccessListener
.public void removeItem(java.lang.String itemKey, SuccessListener<java.lang.Void> listener)
itemKey
- Key of the item to remove.listener
- Async result listener. See SuccessListener
.public void getItems(SuccessListener<MapIterator> listener)
listener
- Async result listener. See SuccessListener
.public Map.QueryOptions queryOptions()
Options
public void queryItems(Map.QueryOptions options, SuccessListener<MapPaginator> listener)
options
- Specific query options.listener
- Async result listener. See SuccessListener
.public void removeMap(SuccessListener<java.lang.Void> listener)
listener
- Async result listener. See SuccessListener
.public void dispose()