Sync Android SDK  2.0.0
com.twilio.sync.SyncDocument Interface Reference

SyncDocument is an arbitrary JSON value. More...

Public Member Functions

String getSid ()
 Retrieves a machine-generated unique identifier for this SyncDocument. More...
 
String getUniqueName ()
 Retrieves a user-set unique name for this SyncDocument. More...
 
Date getDateUpdated ()
 Retrieves a Date when the Document was last updated. More...
 
JSONObject getData ()
 Get value of the document as a JSON object. More...
 
void setData (JSONObject data, SuccessListener< JSONObject > listener)
 Set value of the document as a JSON object. More...
 
void setData (JSONObject data, Metadata metadata, SuccessListener< JSONObject > listener)
 Set value of the document as a JSON object. More...
 
void mutateData (SyncMutator mutator, SuccessListener< JSONObject > listener)
 Mutate value of the document using provided Mutator function. More...
 
void mutateData (SyncMutator mutator, Metadata metadata, SuccessListener< JSONObject > listener)
 Mutate value of the document using provided Mutator function. More...
 
void setTtl (int ttl, SuccessListener< Void > listener)
 Set time to live for document object in seconds. More...
 
void removeDocument (SuccessListener< Void > listener)
 Remove document. More...
 

Public Attributes

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

Detailed Description

SyncDocument is an arbitrary JSON value.

You can set, get and modify this value.

To obtain an instance of a SyncDocument use SyncClient#openDocument.

Member Function Documentation

JSONObject com.twilio.sync.SyncDocument.getData ( )

Get value of the document as a JSON object.

Returns
Document value.
Date com.twilio.sync.SyncDocument.getDateUpdated ( )

Retrieves a Date when the Document was last updated.

Returns
Date this Document was last updated.
String com.twilio.sync.SyncDocument.getSid ( )

Retrieves a machine-generated unique identifier for this SyncDocument.

Returns
Document SID.
String com.twilio.sync.SyncDocument.getUniqueName ( )

Retrieves a user-set unique name for this SyncDocument.

Returns
Document Unique Name.
void com.twilio.sync.SyncDocument.mutateData ( SyncMutator  mutator,
SuccessListener< JSONObject >  listener 
)

Mutate value of the document using provided Mutator function.

Uses default metadata.

Parameters
mutatorMutator which will be applied to document data.
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncDocument.mutateData ( SyncMutator  mutator,
Metadata  metadata,
SuccessListener< JSONObject >  listener 
)

Mutate value of the document using provided Mutator function.

Parameters
mutatorMutator which will be applied to document data.
metadataOptional metadata for the updated document, currently only ttl.
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncDocument.removeDocument ( SuccessListener< Void >  listener)

Remove document.

Parameters
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncDocument.setData ( JSONObject  data,
SuccessListener< JSONObject >  listener 
)

Set value of the document as a JSON object.

Uses default metadata.

Parameters
dataNew document data.
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncDocument.setData ( JSONObject  data,
Metadata  metadata,
SuccessListener< JSONObject >  listener 
)

Set value of the document as a JSON object.

Parameters
dataNew document data.
metadataOptional metadata for the updated document, currently only ttl.
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.SyncDocument.setTtl ( int  ttl,
SuccessListener< Void >  listener 
)

Set time to live for document object in seconds.

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.

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