public interface SyncDocument
You can set, get and modify this value.
To obtain an instance of a SyncDocument use SyncClient.openDocument(com.twilio.sync.SyncOptions, com.twilio.sync.SyncDocumentObserver, com.twilio.sync.SuccessListener<com.twilio.sync.SyncDocument>).
| Modifier and Type | Interface and Description |
|---|---|
static interface |
SyncDocument.Metadata |
| Modifier and Type | Field and Description |
|---|---|
static int |
INFINITE_DURATION
Time to live for a document, specifying no expiry.
|
| Modifier and Type | Method and Description |
|---|---|
org.json.JSONObject |
getData()
Get value of the document as a JSON object.
|
java.util.Date |
getDateUpdated()
Retrieves a Date when the Document was last updated.
|
java.lang.String |
getSid()
Retrieves a machine-generated unique identifier for this SyncDocument.
|
java.lang.String |
getUniqueName()
Retrieves a user-set unique name for this SyncDocument.
|
void |
mutateData(SyncMutator mutator,
SuccessListener<org.json.JSONObject> listener)
Mutate value of the document using provided Mutator function.
|
void |
mutateData(SyncMutator mutator,
SyncDocument.Metadata metadata,
SuccessListener<org.json.JSONObject> listener)
Mutate value of the document using provided Mutator function.
|
void |
removeDocument(SuccessListener<java.lang.Void> listener)
Remove document.
|
void |
setData(org.json.JSONObject data,
SuccessListener<org.json.JSONObject> listener)
Set value of the document as a JSON object.
|
void |
setData(org.json.JSONObject data,
SyncDocument.Metadata metadata,
SuccessListener<org.json.JSONObject> listener)
Set value of the document as a JSON object.
|
void |
setTtl(int ttl,
SuccessListener<java.lang.Void> listener)
Set time to live for document object in seconds.
|
static final int INFINITE_DURATION
java.lang.String getSid()
java.lang.String getUniqueName()
java.util.Date getDateUpdated()
org.json.JSONObject getData()
void setData(org.json.JSONObject data,
SuccessListener<org.json.JSONObject> listener)
metadata.data - New document data.listener - Async result listener. See SuccessListener.void setData(org.json.JSONObject data,
SyncDocument.Metadata metadata,
SuccessListener<org.json.JSONObject> listener)
data - New document data.metadata - Optional metadata for the updated document, currently only ttl.listener - Async result listener. See SuccessListener.void mutateData(SyncMutator mutator, SuccessListener<org.json.JSONObject> listener)
metadata.mutator - Mutator which will be applied to document data.listener - Async result listener. See SuccessListener.void mutateData(SyncMutator mutator, SyncDocument.Metadata metadata, SuccessListener<org.json.JSONObject> listener)
mutator - Mutator which will be applied to document data.metadata - Optional metadata for the updated document, currently only ttl.listener - Async result listener. See SuccessListener.void setTtl(int ttl,
SuccessListener<java.lang.Void> listener)
This TTL specifies the minimum time the SyncDocument 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.
ttl - Time to live in seconds from now or INFINITE_DURATION to indicate no expiry.listener - Async result listener. See SuccessListener.void removeDocument(SuccessListener<java.lang.Void> listener)
listener - Async result listener. See SuccessListener.