Sync Android SDK  0.8.5
com.twilio.sync.Document Class Reference

Document is an arbitrary JSON value. More...

Public Member Functions

native String getSid ()
 Retrieves a machine-generated unique identifier for this Document. More...
 
native String getUniqueName ()
 Retrieves a user-set unique name for this Document. More...
 
native 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 (Mutator mutator, SuccessListener< JSONObject > listener)
 Mutate value of the document using provided Mutator function. More...
 
void mutateData (Mutator mutator, Metadata metadata, SuccessListener< JSONObject > listener)
 Mutate value of the document using provided Mutator function. More...
 
void setTtl (int ttl, SuccessListener< Void > listener)
 Update the document’s time to live. More...
 
void removeDocument (SuccessListener< Void > listener)
 Remove document. More...
 

Public Attributes

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

Detailed Description

Document is an arbitrary JSON value.

You can set, get and modify this value.

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

Member Function Documentation

native JSONObject com.twilio.sync.Document.getData ( )

Get value of the document as a JSON object.

Returns
Document value.
native String com.twilio.sync.Document.getSid ( )

Retrieves a machine-generated unique identifier for this Document.

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

Retrieves a user-set unique name for this Document.

Returns
Document Unique Name.
void com.twilio.sync.Document.mutateData ( Mutator  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.Document.mutateData ( Mutator  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.Document.removeDocument ( SuccessListener< Void >  listener)

Remove document.

Parameters
listenerAsync result listener. See SuccessListener.
void com.twilio.sync.Document.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.Document.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.Document.setTtl ( int  ttl,
SuccessListener< Void >  listener 
)

Update the document’s time to live.

Parameters
ttlThe new time to live for this document in seconds from now or Document.InfiniteDuration to indicate no expiry.
listenerAsync result listener. See SuccessListener.