public final class MesosferData
extends java.lang.Object
MesosferData
is a local representation of data that can be saved and retrieved from
the Mesosfer cloud.
The basic workflow for creating new data is to construct a new MesosferData
by accessing
createData(MesosferDataSchema)
or createData(String)
, use
setData(String, Object)
to fill it with data, and then use
saveAsync(SaveCallback)
to persist to the cloud.
The basic workflow for accessing existing data is to use a MesosferQuery
to specify which
existing data to retrieve.Modifier and Type | Method and Description |
---|---|
static MesosferData |
createData(MesosferDataSchema schema)
Constructs a new
MesosferData with no data in it. |
static MesosferData |
createData(java.lang.String bucket)
Constructs a new
MesosferData with no data in it. |
static MesosferData |
createWithObjectId(java.lang.String objectId)
Creates a reference to an existing
MesosferData for use in creating associations between
MesosferData s. |
void |
deleteAsync(DeleteCallback callback)
Deletes this object on the server in a background thread.
|
void |
fetchAsync(GetCallback<MesosferData> callback)
Fetches this object with the data from the server in a background thread.
|
java.util.Date |
getCreatedAt()
This reports time as the server sees it, so that if you create a
MesosferData ,
then wait a while, and then call saveAsync(SaveCallback) , the creation time will be
the time of the first saveAsync(SaveCallback) call rather than the time the object
was created locally. |
MesosferObject |
getData()
Gets the
MesosferObject that already saved in MesosferData . |
org.json.JSONArray |
getDataArray(java.lang.String key)
Gets the
JSONArray value from the getData() given key string. |
boolean |
getDataBoolean(java.lang.String key)
Gets the
Boolean value from the getData() given key string. |
java.util.Date |
getDataDate(java.lang.String key)
Gets the
Date value from the getData() given key string. |
double |
getDataDouble(java.lang.String key)
Gets the
Double value from the getData() given key string. |
int |
getDataInteger(java.lang.String key)
Gets the
Integer value from the getData() given key string. |
long |
getDataLong(java.lang.String key)
Gets the
Long value from the getData() given key string. |
java.lang.Number |
getDataNumber(java.lang.String key)
Gets the
Number value from the getData() given key string. |
org.json.JSONObject |
getDataObject(java.lang.String key)
Gets the
JSONObject value from the getData() given key string. |
MesosferDataSchema |
getDataSchema()
Gets data
MesosferDataSchema of this object. |
java.lang.String |
getDataString(java.lang.String key)
Gets the
String value from the getData() given key string. |
java.lang.String |
getObjectId()
Accessor to the object id.
|
static MesosferQuery<MesosferData> |
getQuery(MesosferDataSchema schema)
Constructs a query for
MesosferData . |
static MesosferQuery<MesosferData> |
getQuery(java.lang.String bucket)
Constructs a query for
MesosferData . |
java.util.Date |
getUpdatedAt()
This reports time as the server sees it, so that if you make changes to a
MesosferData ,
then wait a while, and then call saveAsync(SaveCallback) , the updated time will be
the time of the saveAsync(SaveCallback) call rather than the time the object
was changed locally. |
boolean |
isDataAvailable()
Gets whether the
MesosferData has been fetched. |
void |
saveAsync(SaveCallback callback)
Saves this object with the data from the server in a background thread.
|
MesosferData |
setData(java.lang.String key,
java.lang.Object value)
Add a key-value pair to this object.
|
org.json.JSONObject |
toJSON()
To put all keys and values of this
MesosferData into a JSONObject . |
java.lang.String |
toString() |
public static MesosferData createData(java.lang.String bucket)
MesosferData
with no data in it. A MesosferData
constructed in this way will not have an objectId and will not persist to the database until
saveAsync(SaveCallback)
is called.
Bucket names must be alphanumerical, and must start with a letter. It is recommended
to name classes in MesosferCaseLikeThis
.
bucket
- the bucket name for this MesosferData
MesosferData
public static MesosferData createData(MesosferDataSchema schema)
MesosferData
with no data in it. A ParseObject
constructed in
this way will not have an objectId and will not persist to the database until
saveAsync(SaveCallback)
is called.
Bucket names must be alphanumerical, and must start with a letter. It is recommended
to name classes in MesosferCaseLikeThis
.
schema
- the MesosferDataSchema
of the bucket for this MesosferData
MesosferData
public static MesosferData createWithObjectId(java.lang.String objectId)
MesosferData
for use in creating associations between
MesosferData
s. Calling isDataAvailable()
on this object will return
false
until fetchAsync(GetCallback)
has been called.objectId
- The object id for the referenced object.MesosferData
without data.public boolean isDataAvailable()
MesosferData
has been fetched.true
if the MesosferData
is new or has been fetched.
false
otherwise.public MesosferObject getData()
MesosferObject
that already saved in MesosferData
.MesosferObject
public java.lang.String getDataString(java.lang.String key)
String
value from the getData()
given key string.key
- the key of String
value to get fromString
valuepublic java.util.Date getDataDate(java.lang.String key)
Date
value from the getData()
given key string.key
- the key of Date
value to get fromDate
valuepublic int getDataInteger(java.lang.String key)
Integer
value from the getData()
given key string.key
- the key of Integer
value to get fromInteger
valuepublic double getDataDouble(java.lang.String key)
Double
value from the getData()
given key string.key
- the key of Double
value to get fromDouble
valuepublic long getDataLong(java.lang.String key)
Long
value from the getData()
given key string.key
- the key of Long
value to get fromLong
valuepublic java.lang.Number getDataNumber(java.lang.String key)
Number
value from the getData()
given key string.key
- the key of Number
value to get fromNumber
valuepublic boolean getDataBoolean(java.lang.String key)
Boolean
value from the getData()
given key string.key
- the key of Boolean
value to get fromBoolean
valuepublic org.json.JSONObject getDataObject(java.lang.String key)
JSONObject
value from the getData()
given key string.key
- the key of JSONObject
value to get fromJSONObject
valuepublic org.json.JSONArray getDataArray(java.lang.String key)
JSONArray
value from the getData()
given key string.key
- the key of JSONArray
value to get fromJSONArray
valuepublic java.lang.String getObjectId()
public java.util.Date getCreatedAt()
MesosferData
,
then wait a while, and then call saveAsync(SaveCallback)
, the creation time will be
the time of the first saveAsync(SaveCallback)
call rather than the time the object
was created locally.public java.util.Date getUpdatedAt()
MesosferData
,
then wait a while, and then call saveAsync(SaveCallback)
, the updated time will be
the time of the saveAsync(SaveCallback)
call rather than the time the object
was changed locally.public MesosferDataSchema getDataSchema()
MesosferDataSchema
of this object.MesosferDataSchema
objectpublic MesosferData setData(java.lang.String key, java.lang.Object value)
camelCaseLikeThis
.key
- Keys must be alphanumerical, and start with a letter.value
- Values may be numerical, String
, JSONObject
, JSONArray
,
JSONObject.NULL
, or Date
s. value may not be null
.public void fetchAsync(GetCallback<MesosferData> callback)
callback
- callback.done(object, e)
is called when the fetch completes.public void saveAsync(SaveCallback callback)
callback
- callback.done(e)
is called when the save completes.public void deleteAsync(DeleteCallback callback)
callback
- callback.done(e)
is called when the save completes.public static MesosferQuery<MesosferData> getQuery(MesosferDataSchema schema)
MesosferData
.schema
- The MesosferDataSchema
that used for MesosferData
public static MesosferQuery<MesosferData> getQuery(java.lang.String bucket)
MesosferData
.bucket
- The bucket name that used for MesosferData
public org.json.JSONObject toJSON()
MesosferData
into a JSONObject
.JSONObject
of all keys and valuespublic java.lang.String toString()
toString
in class java.lang.Object