com.parse
Class ParseObject

Object
  extended by com.parse.ParseObject
Direct Known Subclasses:
ParseInstallation, ParseRole, ParseUser

public class ParseObject
extends Object

The ParseObject is a local representation of data that can be saved and retrieved from the Parse cloud.

The basic workflow for creating new data is to construct a new ParseObject, use put() to fill it with data, and then use save() to persist to the database.

The basic workflow for accessing existing data is to use a ParseQuery to specify which existing data to retrieve.


Field Summary
static String DEFAULT_PIN
          Default name for pinning if not specified.
 
Constructor Summary
protected ParseObject()
          The base class constructor to call in subclasses.
  ParseObject(String theClassName)
          Constructs a new ParseObject with no data in it.
 
Method Summary
 void add(String key, Object value)
          Atomically adds an object to the end of the array associated with a given key.
 void addAll(String key, Collection<?> values)
          Atomically adds the objects contained in a Collection to the end of the array associated with a given key.
 void addAllUnique(String key, Collection<?> values)
          Atomically adds the objects contained in a Collection to the array associated with a given key, only adding elements which are not already present in the array.
 void addUnique(String key, Object value)
          Atomically adds an object to the array associated with a given key, only if it is not already present in the array.
 boolean containsKey(String key)
          Whether this object has a particular key.
static
<T extends ParseObject>
T
create(Class<T> subclass)
          Creates a new ParseObject based upon a subclass type.
static ParseObject create(String className)
          Creates a new ParseObject based upon a class name.
static
<T extends ParseObject>
T
createWithoutData(Class<T> subclass, String objectId)
          Creates a reference to an existing ParseObject for use in creating associations between ParseObjects.
static ParseObject createWithoutData(String className, String objectId)
          Creates a reference to an existing ParseObject for use in creating associations between ParseObjects.
 void delete()
          Deletes this object on the server.
static
<T extends ParseObject>
void
deleteAll(List<T> objects)
          Deletes each object in the provided list.
static
<T extends ParseObject>
bolts.Task<Void>
deleteAllInBackground(List<T> objects)
          Deletes each object in the provided list.
static
<T extends ParseObject>
void
deleteAllInBackground(List<T> objects, DeleteCallback callback)
          Deletes each object in the provided list.
 bolts.Task<Void> deleteEventually()
          Deletes this object from the server at some unspecified time in the future, even if Parse is currently inaccessible.
 void deleteEventually(DeleteCallback callback)
          Deletes this object from the server at some unspecified time in the future, even if Parse is currently inaccessible.
 bolts.Task<Void> deleteInBackground()
          Deletes this object on the server in a background thread.
 void deleteInBackground(DeleteCallback callback)
          Deletes this object on the server in a background thread.
<T extends ParseObject>
T
fetch()
          Fetches this object with the data from the server.
static
<T extends ParseObject>
List<T>
fetchAll(List<T> objects)
          Fetches all the objects in the provided list.
static
<T extends ParseObject>
List<T>
fetchAllIfNeeded(List<T> objects)
          Fetches all the objects that don't have data in the provided list.
static
<T extends ParseObject>
bolts.Task<List<T>>
fetchAllIfNeededInBackground(List<T> objects)
          Fetches all the objects that don't have data in the provided list in the background.
static
<T extends ParseObject>
void
fetchAllIfNeededInBackground(List<T> objects, FindCallback<T> callback)
          Fetches all the objects that don't have data in the provided list in the background.
static
<T extends ParseObject>
bolts.Task<List<T>>
fetchAllInBackground(List<T> objects)
          Fetches all the objects in the provided list in the background.
static
<T extends ParseObject>
void
fetchAllInBackground(List<T> objects, FindCallback<T> callback)
          Fetches all the objects in the provided list in the background.
 void fetchFromLocalDatastore()
          Loads data from the local datastore into this object, if it has not been fetched from the server already.
<T extends ParseObject>
void
fetchFromLocalDatastoreInBackground(GetCallback<T> callback)
          Loads data from the local datastore into this object, if it has not been fetched from the server already.
<T extends ParseObject>
T
fetchIfNeeded()
          If this ParseObject has not been fetched (i.e.
<T extends ParseObject>
bolts.Task<T>
fetchIfNeededInBackground()
          If this ParseObject has not been fetched (i.e.
<T extends ParseObject>
void
fetchIfNeededInBackground(GetCallback<T> callback)
          If this ParseObject has not been fetched (i.e.
<T extends ParseObject>
bolts.Task<T>
fetchInBackground()
          Fetches this object with the data from the server in a background thread.
<T extends ParseObject>
void
fetchInBackground(GetCallback<T> callback)
          Fetches this object with the data from the server in a background thread.
 Object get(String key)
          Access a value.
 ParseACL getACL()
          Access the ParseACL governing this object.
 boolean getBoolean(String key)
          Access a boolean value.
 byte[] getBytes(String key)
          Access a byte array value.
 String getClassName()
          Accessor to the class name.
 Date getCreatedAt()
          This reports time as the server sees it, so that if you create a ParseObject, then wait a while, and then call save(), the creation time will be the time of the first save() call rather than the time the object was created locally.
 Date getDate(String key)
          Access a Date value.
 double getDouble(String key)
          Access a double value.
 int getInt(String key)
          Access an int value.
 JSONArray getJSONArray(String key)
          Access a JSONArray value.
 JSONObject getJSONObject(String key)
          Access a JSONObject value.
<T> List<T>
getList(String key)
          Access a List value.
 long getLong(String key)
          Access a long value.
<V> Map<String,V>
getMap(String key)
          Access a Map value
 Number getNumber(String key)
          Access a numerical value.
 String getObjectId()
          Accessor to the object id.
 ParseFile getParseFile(String key)
          Access a ParseFile value.
 ParseGeoPoint getParseGeoPoint(String key)
          Access a ParseGeoPoint value.
 ParseObject getParseObject(String key)
          Access a ParseObject value.
 ParseUser getParseUser(String key)
          Access a ParseUser value.
<T extends ParseObject>
ParseRelation<T>
getRelation(String key)
          Access or create a Relation value for a key
 String getString(String key)
          Access a string value.
 Date getUpdatedAt()
          This reports time as the server sees it, so that if you make changes to a ParseObject, then wait a while, and then call save(), the updated time will be the time of the save() call rather than the time the object was changed locally.
 boolean has(String key)
          Whether this object has a particular key.
 boolean hasSameId(ParseObject other)
           
 void increment(String key)
          Atomically increments the given key by 1.
 void increment(String key, Number amount)
          Atomically increments the given key by the given number.
 boolean isDataAvailable()
          Gets whether the ParseObject has been fetched.
 boolean isDirty()
          Whether any key-value pair in this object (or its children) has been added/updated/removed and not saved yet.
 boolean isDirty(String key)
          Whether a value associated with a key has been added/updated/removed and not saved yet.
 Set<String> keySet()
          Returns a set view of the keys contained in this object.
 void pin()
          Stores the object and every object it points to in the local datastore, recursively.
 void pin(String name)
          Stores the object and every object it points to in the local datastore, recursively.
static
<T extends ParseObject>
void
pinAll(List<T> objects)
          Stores the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
void
pinAll(String name, List<T> objects)
          Stores the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
bolts.Task<Void>
pinAllInBackground(List<T> objects)
          Stores the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
void
pinAllInBackground(List<T> objects, SaveCallback callback)
          Stores the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
bolts.Task<Void>
pinAllInBackground(String name, List<T> objects)
          Stores the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
void
pinAllInBackground(String name, List<T> objects, SaveCallback callback)
          Stores the objects and every object they point to in the local datastore, recursively.
 bolts.Task<Void> pinInBackground()
          Stores the object and every object it points to in the local datastore, recursively.
 void pinInBackground(SaveCallback callback)
          Stores the object and every object it points to in the local datastore, recursively.
 bolts.Task<Void> pinInBackground(String name)
          Stores the object and every object it points to in the local datastore, recursively.
 void pinInBackground(String name, SaveCallback callback)
          Stores the object and every object it points to in the local datastore, recursively.
 void put(String key, Object value)
          Add a key-value pair to this object.
 void refresh()
          Deprecated. Please use ParseObject.fetch() instead.
 void refreshInBackground(RefreshCallback callback)
          Deprecated. Please use ParseObject.fetchInBackground(GetCallback) instead.
static void registerSubclass(Class<? extends ParseObject> subclass)
          Registers a custom subclass type with the Parse SDK, enabling strong-typing of those ParseObjects whenever they appear.
 void remove(String key)
          Removes a key from this object's data if it exists.
 void removeAll(String key, Collection<?> values)
          Atomically removes all instances of the objects contained in a Collection from the array associated with a given key.
 void save()
          Saves this object to the server.
static
<T extends ParseObject>
void
saveAll(List<T> objects)
          Saves each object in the provided list.
static
<T extends ParseObject>
bolts.Task<Void>
saveAllInBackground(List<T> objects)
          Saves each object in the provided list to the server in a background thread.
static
<T extends ParseObject>
void
saveAllInBackground(List<T> objects, SaveCallback callback)
          Saves each object in the provided list to the server in a background thread.
 bolts.Task<Void> saveEventually()
          Saves this object to the server at some unspecified time in the future, even if Parse is currently inaccessible.
 void saveEventually(SaveCallback callback)
          Saves this object to the server at some unspecified time in the future, even if Parse is currently inaccessible.
 bolts.Task<Void> saveInBackground()
          Saves this object to the server in a background thread.
 void saveInBackground(SaveCallback callback)
          Saves this object to the server in a background thread.
 void setACL(ParseACL acl)
          Set the ParseACL governing this object.
 void setObjectId(String newObjectId)
          Setter for the object id.
 void unpin()
          Removes the object and every object it points to in the local datastore, recursively.
 void unpin(String name)
          Removes the object and every object it points to in the local datastore, recursively.
static void unpinAll()
          Removes the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
void
unpinAll(List<T> objects)
          Removes the objects and every object they point to in the local datastore, recursively.
static void unpinAll(String name)
          Removes the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
void
unpinAll(String name, List<T> objects)
          Removes the objects and every object they point to in the local datastore, recursively.
static bolts.Task<Void> unpinAllInBackground()
          Removes the objects and every object they point to in the local datastore, recursively.
static void unpinAllInBackground(DeleteCallback callback)
          Removes the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
bolts.Task<Void>
unpinAllInBackground(List<T> objects)
          Removes the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
void
unpinAllInBackground(List<T> objects, DeleteCallback callback)
          Removes the objects and every object they point to in the local datastore, recursively.
static bolts.Task<Void> unpinAllInBackground(String name)
          Removes the objects and every object they point to in the local datastore, recursively.
static void unpinAllInBackground(String name, DeleteCallback callback)
          Removes the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
bolts.Task<Void>
unpinAllInBackground(String name, List<T> objects)
          Removes the objects and every object they point to in the local datastore, recursively.
static
<T extends ParseObject>
void
unpinAllInBackground(String name, List<T> objects, DeleteCallback callback)
          Removes the objects and every object they point to in the local datastore, recursively.
 bolts.Task<Void> unpinInBackground()
          Removes the object and every object it points to in the local datastore, recursively.
 void unpinInBackground(DeleteCallback callback)
          Removes the object and every object it points to in the local datastore, recursively.
 bolts.Task<Void> unpinInBackground(String name)
          Removes the object and every object it points to in the local datastore, recursively.
 void unpinInBackground(String name, DeleteCallback callback)
          Removes the object and every object it points to in the local datastore, recursively.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PIN

public static final String DEFAULT_PIN
Default name for pinning if not specified.

See Also:
ParseObject.pin(), ParseObject.unpin(), Constant Field Values
Constructor Detail

ParseObject

protected ParseObject()
The base class constructor to call in subclasses. Uses the class name specified with the ParseClassName annotation on the subclass.


ParseObject

public ParseObject(String theClassName)
Constructs a new ParseObject with no data in it. A ParseObject constructed in this way will not have an objectId and will not persist to the database until save() is called.

Class names must be alphanumerical plus underscore, and start with a letter. It is recommended to name classes in CamelCaseLikeThis.

Parameters:
theClassName - The className for this ParseObject.
Method Detail

create

public static ParseObject create(String className)
Creates a new ParseObject based upon a class name. If the class name is a special type (e.g. for ParseUser), then the appropriate type of ParseObject is returned.

Parameters:
className - The class of object to create.
Returns:
A new ParseObject for the given class name.

create

public static <T extends ParseObject> T create(Class<T> subclass)
Creates a new ParseObject based upon a subclass type. Note that the object will be created based upon the ParseClassName of the given subclass type. For example, calling create(ParseUser.class) may create an instance of a custom subclass of ParseUser.

Parameters:
subclass - The class of object to create.
Returns:
A new ParseObject based upon the class name of the given subclass type.

createWithoutData

public static ParseObject createWithoutData(String className,
                                            String objectId)
Creates a reference to an existing ParseObject for use in creating associations between ParseObjects. Calling ParseObject.isDataAvailable() on this object will return false until ParseObject.fetchIfNeeded() or ParseObject.refresh() has been called. No network request will be made.

Parameters:
className - The object's class.
objectId - The object id for the referenced object.
Returns:
A ParseObject without data.

createWithoutData

public static <T extends ParseObject> T createWithoutData(Class<T> subclass,
                                                          String objectId)
Creates a reference to an existing ParseObject for use in creating associations between ParseObjects. Calling ParseObject.isDataAvailable() on this object will return false until ParseObject.fetchIfNeeded() or ParseObject.refresh() has been called. No network request will be made.

Parameters:
subclass - The ParseObject subclass to create.
objectId - The object id for the referenced object.
Returns:
A ParseObject without data.

registerSubclass

public static void registerSubclass(Class<? extends ParseObject> subclass)
Registers a custom subclass type with the Parse SDK, enabling strong-typing of those ParseObjects whenever they appear. Subclasses must specify the ParseClassName annotation and have a default constructor.

Parameters:
subclass - The subclass type to register.

getClassName

public String getClassName()
Accessor to the class name.


keySet

public Set<String> keySet()
Returns a set view of the keys contained in this object. This does not include createdAt, updatedAt, authData, or objectId. It does include things like username and ACL.


getUpdatedAt

public Date getUpdatedAt()
This reports time as the server sees it, so that if you make changes to a ParseObject, then wait a while, and then call save(), the updated time will be the time of the save() call rather than the time the object was changed locally.

Returns:
The last time this object was updated on the server.

getCreatedAt

public Date getCreatedAt()
This reports time as the server sees it, so that if you create a ParseObject, then wait a while, and then call save(), the creation time will be the time of the first save() call rather than the time the object was created locally.

Returns:
The first time this object was saved on the server.

isDirty

public boolean isDirty()
Whether any key-value pair in this object (or its children) has been added/updated/removed and not saved yet.

Returns:
Returns whether this object has been altered and not saved yet.

isDirty

public boolean isDirty(String key)
Whether a value associated with a key has been added/updated/removed and not saved yet.

Parameters:
key - The key to check for
Returns:
Returns whether this key has been altered and not saved yet.

getObjectId

public String getObjectId()
Accessor to the object id. An object id is assigned as soon as an object is saved to the server. The combination of a className and an objectId uniquely identifies an object in your application.

Returns:
The object id.

setObjectId

public void setObjectId(String newObjectId)
Setter for the object id. In general you do not need to use this. However, in some cases this can be convenient. For example, if you are serializing a ParseObject yourself and wish to recreate it, you can use this to recreate the ParseObject exactly.


save

public final void save()
                throws ParseException
Saves this object to the server. Typically, you should use ParseObject.saveInBackground() instead of this, unless you are managing your own threading.

Throws:
ParseException - Throws an exception if the server is inaccessible.

saveInBackground

public final bolts.Task<Void> saveInBackground()
Saves this object to the server in a background thread. This is preferable to using save(), unless your code is already running from a background thread.

Returns:
A Task that is resolved when the save completes.

saveInBackground

public final void saveInBackground(SaveCallback callback)
Saves this object to the server in a background thread. This is preferable to using save(), unless your code is already running from a background thread.

Parameters:
callback - callback.done(e) is called when the save completes.

saveEventually

public final void saveEventually(SaveCallback callback)
Saves this object to the server at some unspecified time in the future, even if Parse is currently inaccessible. Use this when you may not have a solid network connection, and don't need to know when the save completes. If there is some problem with the object such that it can't be saved, it will be silently discarded. Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is available. Objects saved this way will persist even after the app is closed, in which case they will be sent the next time the app is opened. If more than 10MB of data is waiting to be sent, subsequent calls to saveEventually or deleteEventually will cause old saves to be silently discarded until the connection can be re-established, and the queued objects can be saved.

Parameters:
callback - - A callback which will be called if the save completes before the app exits.

saveEventually

public final bolts.Task<Void> saveEventually()
Saves this object to the server at some unspecified time in the future, even if Parse is currently inaccessible. Use this when you may not have a solid network connection, and don't need to know when the save completes. If there is some problem with the object such that it can't be saved, it will be silently discarded. Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is available. Objects saved this way will persist even after the app is closed, in which case they will be sent the next time the app is opened. If more than 10MB of data is waiting to be sent, subsequent calls to saveEventually or deleteEventually will cause old saves to be silently discarded until the connection can be re-established, and the queued objects can be saved.

Returns:
A Task that is resolved when the save completes.

deleteEventually

public final void deleteEventually(DeleteCallback callback)
Deletes this object from the server at some unspecified time in the future, even if Parse is currently inaccessible. Use this when you may not have a solid network connection, and don't need to know when the delete completes. If there is some problem with the object such that it can't be deleted, the request will be silently discarded. Delete requests made with this method will be stored locally in an on-disk cache until they can be transmitted to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is available. Delete instructions saved this way will persist even after the app is closed, in which case they will be sent the next time the app is opened. If more than 10MB of commands are waiting to be sent, subsequent calls to deleteEventually or saveEventually will cause old instructions to be silently discarded until the connection can be re-established, and the queued objects can be saved.

Parameters:
callback - - A callback which will be called if the delete completes before the app exits.

deleteEventually

public final bolts.Task<Void> deleteEventually()
Deletes this object from the server at some unspecified time in the future, even if Parse is currently inaccessible. Use this when you may not have a solid network connection, and don't need to know when the delete completes. If there is some problem with the object such that it can't be deleted, the request will be silently discarded. Delete requests made with this method will be stored locally in an on-disk cache until they can be transmitted to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is available. Delete instructions saved this way will persist even after the app is closed, in which case they will be sent the next time the app is opened. If more than 10MB of commands are waiting to be sent, subsequent calls to deleteEventually or saveEventually will cause old instructions to be silently discarded until the connection can be re-established, and the queued objects can be saved.

Returns:
A Task that is resolved when the delete completes.

refresh

@Deprecated
public final void refresh()
                   throws ParseException
Deprecated. Please use ParseObject.fetch() instead.

Refreshes this object with the data from the server. Call this whenever you want the state of the object to reflect exactly what is on the server.

Throws:
ParseException - Throws an exception if the server is inaccessible.

refreshInBackground

@Deprecated
public final void refreshInBackground(RefreshCallback callback)
Deprecated. Please use ParseObject.fetchInBackground(GetCallback) instead.

Refreshes this object with the data from the server in a background thread. This is preferable to using refresh(), unless your code is already running from a background thread.

Parameters:
callback - callback.done(object, e) is called when the refresh completes.

fetch

public <T extends ParseObject> T fetch()
                            throws ParseException
Fetches this object with the data from the server. Call this whenever you want the state of the object to reflect exactly what is on the server.

Returns:
The ParseObject that was fetched.
Throws:
ParseException - Throws an exception if the server is inaccessible.

fetchInBackground

public final <T extends ParseObject> bolts.Task<T> fetchInBackground()
Fetches this object with the data from the server in a background thread. This is preferable to using fetch(), unless your code is already running from a background thread.

Returns:
A Task that is resolved when fetch completes.

fetchInBackground

public final <T extends ParseObject> void fetchInBackground(GetCallback<T> callback)
Fetches this object with the data from the server in a background thread. This is preferable to using fetch(), unless your code is already running from a background thread.

Parameters:
callback - callback.done(object, e) is called when the fetch completes.

fetchIfNeededInBackground

public final <T extends ParseObject> bolts.Task<T> fetchIfNeededInBackground()
If this ParseObject has not been fetched (i.e. ParseObject.isDataAvailable() returns false), fetches this object with the data from the server in a background thread. This is preferable to using ParseObject.fetchIfNeeded(), unless your code is already running from a background thread.

Returns:
A Task that is resolved when fetch completes.

fetchIfNeeded

public <T extends ParseObject> T fetchIfNeeded()
                                    throws ParseException
If this ParseObject has not been fetched (i.e. ParseObject.isDataAvailable() returns false), fetches this object with the data from the server.

Returns:
The fetched ParseObject.
Throws:
ParseException - Throws an exception if the server is inaccessible.

fetchIfNeededInBackground

public final <T extends ParseObject> void fetchIfNeededInBackground(GetCallback<T> callback)
If this ParseObject has not been fetched (i.e. ParseObject.isDataAvailable() returns false), fetches this object with the data from the server in a background thread. This is preferable to using ParseObject.fetchIfNeeded(), unless your code is already running from a background thread.

Parameters:
callback - callback.done(object, e) is called when the fetch completes.

deleteInBackground

public final bolts.Task<Void> deleteInBackground()
Deletes this object on the server in a background thread. This is preferable to using delete(), unless your code is already running from a background thread.

Returns:
A Task that is resolved when delete completes.

delete

public final void delete()
                  throws ParseException
Deletes this object on the server. This does not delete or destroy the object locally.

Throws:
ParseException - Throws an error if the object does not exist or if the internet fails.

deleteInBackground

public final void deleteInBackground(DeleteCallback callback)
Deletes this object on the server in a background thread. This is preferable to using delete(), unless your code is already running from a background thread.

Parameters:
callback - callback.done(e) is called when the save completes.

deleteAll

public static <T extends ParseObject> void deleteAll(List<T> objects)
                      throws ParseException
Deletes each object in the provided list. This is faster than deleting each object individually because it batches the requests.

Parameters:
objects - The objects to delete.
Throws:
ParseException - Throws an exception if the server returns an error or is inaccessible.

deleteAllInBackground

public static <T extends ParseObject> void deleteAllInBackground(List<T> objects,
                                                                 DeleteCallback callback)
Deletes each object in the provided list. This is faster than deleting each object individually because it batches the requests.

Parameters:
objects - The objects to delete.
callback - The callback method to execute when completed.

deleteAllInBackground

public static <T extends ParseObject> bolts.Task<Void> deleteAllInBackground(List<T> objects)
Deletes each object in the provided list. This is faster than deleting each object individually because it batches the requests.

Parameters:
objects - The objects to delete.
Returns:
A Task that is resolved when deleteAll completes.

saveAll

public static <T extends ParseObject> void saveAll(List<T> objects)
                    throws ParseException
Saves each object in the provided list. This is faster than saving each object individually because it batches the requests.

Parameters:
objects - The objects to save.
Throws:
ParseException - Throws an exception if the server returns an error or is inaccessible.

saveAllInBackground

public static <T extends ParseObject> void saveAllInBackground(List<T> objects,
                                                               SaveCallback callback)
Saves each object in the provided list to the server in a background thread. This is preferable to using saveAll, unless your code is already running from a background thread.

Parameters:
objects - The objects to save.
callback - callback.done(e) is called when the save completes.

saveAllInBackground

public static <T extends ParseObject> bolts.Task<Void> saveAllInBackground(List<T> objects)
Saves each object in the provided list to the server in a background thread. This is preferable to using saveAll, unless your code is already running from a background thread.

Parameters:
objects - The objects to save.
Returns:
A Task that is resolved when saveAll completes.

fetchAllIfNeededInBackground

public static <T extends ParseObject> bolts.Task<List<T>> fetchAllIfNeededInBackground(List<T> objects)
Fetches all the objects that don't have data in the provided list in the background.

Parameters:
objects - The list of objects to fetch.
Returns:
A Task that is resolved when fetchAllIfNeeded completes.

fetchAllIfNeeded

public static <T extends ParseObject> List<T> fetchAllIfNeeded(List<T> objects)
                                                    throws ParseException
Fetches all the objects that don't have data in the provided list.

Parameters:
objects - The list of objects to fetch.
Returns:
The list passed in for convenience.
Throws:
ParseException - Throws an exception if the server returns an error or is inaccessible.

fetchAllIfNeededInBackground

public static <T extends ParseObject> void fetchAllIfNeededInBackground(List<T> objects,
                                                                        FindCallback<T> callback)
Fetches all the objects that don't have data in the provided list in the background.

Parameters:
objects - The list of objects to fetch.
callback - callback.done(result, e) is called when the fetch completes.

fetchAllInBackground

public static <T extends ParseObject> bolts.Task<List<T>> fetchAllInBackground(List<T> objects)
Fetches all the objects in the provided list in the background.

Parameters:
objects - The list of objects to fetch.
Returns:
A Task that is resolved when fetch completes.

fetchAll

public static <T extends ParseObject> List<T> fetchAll(List<T> objects)
                                            throws ParseException
Fetches all the objects in the provided list.

Parameters:
objects - The list of objects to fetch.
Returns:
The list passed in.
Throws:
ParseException - Throws an exception if the server returns an error or is inaccessible.

fetchAllInBackground

public static <T extends ParseObject> void fetchAllInBackground(List<T> objects,
                                                                FindCallback<T> callback)
Fetches all the objects in the provided list in the background.

Parameters:
objects - The list of objects to fetch.
callback - callback.done(result, e) is called when the fetch completes.

remove

public void remove(String key)
Removes a key from this object's data if it exists.

Parameters:
key - The key to remove.

has

public boolean has(String key)
Whether this object has a particular key. Same as containsKey.

Parameters:
key - The key to check for
Returns:
Returns whether this object contains the key

put

public void put(String key,
                Object value)
Add a key-value pair to this object. It is recommended to name keys in partialCamelCaseLikeThis.

Parameters:
key - Keys must be alphanumerical plus underscore, and start with a letter.
value - Values may be numerical, String, JSONObject, JSONArray, JSONObject.NULL, or other ParseObjects. value may not be null.

increment

public void increment(String key)
Atomically increments the given key by 1.

Parameters:
key - The key to increment.

increment

public void increment(String key,
                      Number amount)
Atomically increments the given key by the given number.

Parameters:
key - The key to increment.
amount - The amount to increment by.

add

public void add(String key,
                Object value)
Atomically adds an object to the end of the array associated with a given key.

Parameters:
key - The key.
value - The object to add.

addAll

public void addAll(String key,
                   Collection<?> values)
Atomically adds the objects contained in a Collection to the end of the array associated with a given key.

Parameters:
key - The key.
values - The objects to add.

addUnique

public void addUnique(String key,
                      Object value)
Atomically adds an object to the array associated with a given key, only if it is not already present in the array. The position of the insert is not guaranteed.

Parameters:
key - The key.
value - The object to add.

addAllUnique

public void addAllUnique(String key,
                         Collection<?> values)
Atomically adds the objects contained in a Collection to the array associated with a given key, only adding elements which are not already present in the array. The position of the insert is not guaranteed.

Parameters:
key - The key.
values - The objects to add.

removeAll

public void removeAll(String key,
                      Collection<?> values)
Atomically removes all instances of the objects contained in a Collection from the array associated with a given key. To maintain consistency with the Java Collection API, there is no method removing all instances of a single object. Instead, you can call parseObject.removeAll(key, Arrays.asList(value)).

Parameters:
key - The key.
values - The objects to remove.

containsKey

public boolean containsKey(String key)
Whether this object has a particular key. Same as 'has'.

Parameters:
key - The key to check for
Returns:
Returns whether this object contains the key

getString

public String getString(String key)
Access a string value.

Parameters:
key - The key to access the value for.
Returns:
Returns null if there is no such key or if it is not a String.

getBytes

public byte[] getBytes(String key)
Access a byte array value.

Parameters:
key - The key to access the value for.
Returns:
Returns null if there is no such key or if it is not a byte array.

getNumber

public Number getNumber(String key)
Access a numerical value.

Parameters:
key - The key to access the value for.
Returns:
Returns null if there is no such key or if it is not a Number.

getJSONArray

public JSONArray getJSONArray(String key)
Access a JSONArray value.

Parameters:
key - The key to access the value for.
Returns:
Returns null if there is no such key or if it is not a JSONArray.

getList

public <T> List<T> getList(String key)
Access a List value.

Parameters:
key - The key to access the value for
Returns:
Returns null if there is no such key or if the value can't be converted to a List

getMap

public <V> Map<String,V> getMap(String key)
Access a Map value

Parameters:
key - The key to access the value for
Returns:
Returns null if there is no such key or if the value can't be converted to a Map.

getJSONObject

public JSONObject getJSONObject(String key)
Access a JSONObject value.

Parameters:
key - The key to access the value for.
Returns:
Returns null if there is no such key or if it is not a JSONObject.

getInt

public int getInt(String key)
Access an int value.

Parameters:
key - The key to access the value for.
Returns:
Returns 0 if there is no such key or if it is not a JSONObject.

getDouble

public double getDouble(String key)
Access a double value.

Parameters:
key - The key to access the value for.
Returns:
Returns 0 if there is no such key or if it is not a double.

getLong

public long getLong(String key)
Access a long value.

Parameters:
key - The key to access the value for.
Returns:
Returns 0 if there is no such key or if it is not a long.

getBoolean

public boolean getBoolean(String key)
Access a boolean value.

Parameters:
key - The key to access the value for.
Returns:
Returns false if there is no such key or if it is not a boolean.

getDate

public Date getDate(String key)
Access a Date value.

Parameters:
key - The key to access the value for.
Returns:
Returns null if there is no such key or if it is not a Date.

getParseObject

public ParseObject getParseObject(String key)
Access a ParseObject value. This function will not perform a network request. Unless the ParseObject has been downloaded (e.g. by a ParseQuery.include(String) or by calling ParseObject.fetchIfNeeded() or ParseObject.refresh()), ParseObject.isDataAvailable() will return false.

Parameters:
key - The key to access the value for.
Returns:
Returns null if there is no such key or if it is not a ParseObject.

getParseUser

public ParseUser getParseUser(String key)
Access a ParseUser value. This function will not perform a network request. Unless the ParseObject has been downloaded (e.g. by a ParseQuery.include(String) or by calling ParseObject.fetchIfNeeded() or ParseObject.refresh()), ParseObject.isDataAvailable() will return false.

Parameters:
key - The key to access the value for.
Returns:
Returns null if there is no such key or if it is not a ParseUser.

getParseFile

public ParseFile getParseFile(String key)
Access a ParseFile value. This function will not perform a network request. Unless the ParseFile has been downloaded (e.g. by calling ParseFile.getData()), ParseFile.isDataAvailable() will return false.

Parameters:
key - The key to access the value for.
Returns:
Returns null if there is no such key or if it is not a ParseFile.

getParseGeoPoint

public ParseGeoPoint getParseGeoPoint(String key)
Access a ParseGeoPoint value.

Parameters:
key - The key to access the value for
Returns:
Returns null if there is no such key or if it is not a ParseGeoPoint.

getACL

public ParseACL getACL()
Access the ParseACL governing this object.


setACL

public void setACL(ParseACL acl)
Set the ParseACL governing this object.


isDataAvailable

public boolean isDataAvailable()
Gets whether the ParseObject has been fetched.

Returns:
true if the ParseObject is new or has been fetched or refreshed. false otherwise.

getRelation

public <T extends ParseObject> ParseRelation<T> getRelation(String key)
Access or create a Relation value for a key

Parameters:
key - The key to access the relation for.
Returns:
the ParseRelation object if the relation already exists for the key or can be created for this key.

get

public Object get(String key)
Access a value. In most cases it is more convenient to use a helper function such as getString or getInt.

Parameters:
key - The key to access the value for.
Returns:
Returns null if there is no such key.

hasSameId

public boolean hasSameId(ParseObject other)

pinAllInBackground

public static <T extends ParseObject> void pinAllInBackground(String name,
                                                              List<T> objects,
                                                              SaveCallback callback)
Stores the objects and every object they point to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Parameters:
name - the name
objects - the objects to be pinned
callback - the callback
See Also:
ParseObject.unpinAllInBackground(String, java.util.List, DeleteCallback)

pinAllInBackground

public static <T extends ParseObject> bolts.Task<Void> pinAllInBackground(String name,
                                                                          List<T> objects)
Stores the objects and every object they point to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Parameters:
name - the name
objects - the objects to be pinned
Returns:
A Task that is resolved when pinning all completes.
See Also:
ParseObject.unpinAllInBackground(String, java.util.List)

pinAll

public static <T extends ParseObject> void pinAll(String name,
                                                  List<T> objects)
                   throws ParseException
Stores the objects and every object they point to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Parameters:
name - the name
objects - the objects to be pinned
Throws:
ParseException
See Also:
ParseObject.unpinAll(String, java.util.List)

pinAllInBackground

public static <T extends ParseObject> void pinAllInBackground(List<T> objects,
                                                              SaveCallback callback)
Stores the objects and every object they point to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Parameters:
objects - the objects to be pinned
callback - the callback
See Also:
ParseObject.unpinAllInBackground(java.util.List, DeleteCallback), ParseObject.DEFAULT_PIN

pinAllInBackground

public static <T extends ParseObject> bolts.Task<Void> pinAllInBackground(List<T> objects)
Stores the objects and every object they point to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Parameters:
objects - the objects to be pinned
Returns:
A Task that is resolved when pinning all completes.
See Also:
ParseObject.unpinAllInBackground(java.util.List), ParseObject.DEFAULT_PIN

pinAll

public static <T extends ParseObject> void pinAll(List<T> objects)
                   throws ParseException
Stores the objects and every object they point to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Parameters:
objects - the objects to be pinned
Throws:
ParseException
See Also:
ParseObject.unpinAll(java.util.List), ParseObject.DEFAULT_PIN

unpinAllInBackground

public static <T extends ParseObject> void unpinAllInBackground(String name,
                                                                List<T> objects,
                                                                DeleteCallback callback)
Removes the objects and every object they point to in the local datastore, recursively.

Parameters:
name - the name
objects - the objects
callback - the callback
See Also:
ParseObject.pinAllInBackground(String, java.util.List, SaveCallback)

unpinAllInBackground

public static <T extends ParseObject> bolts.Task<Void> unpinAllInBackground(String name,
                                                                            List<T> objects)
Removes the objects and every object they point to in the local datastore, recursively.

Parameters:
name - the name
objects - the objects
Returns:
A Task that is resolved when unpinning all completes.
See Also:
ParseObject.pinAllInBackground(String, java.util.List)

unpinAll

public static <T extends ParseObject> void unpinAll(String name,
                                                    List<T> objects)
                     throws ParseException
Removes the objects and every object they point to in the local datastore, recursively.

Parameters:
name - the name
objects - the objects
Throws:
ParseException
See Also:
ParseObject.pinAll(String, java.util.List)

unpinAllInBackground

public static <T extends ParseObject> void unpinAllInBackground(List<T> objects,
                                                                DeleteCallback callback)
Removes the objects and every object they point to in the local datastore, recursively.

Parameters:
objects - the objects
callback - the callback
See Also:
ParseObject.pinAllInBackground(java.util.List, SaveCallback), ParseObject.DEFAULT_PIN

unpinAllInBackground

public static <T extends ParseObject> bolts.Task<Void> unpinAllInBackground(List<T> objects)
Removes the objects and every object they point to in the local datastore, recursively.

Parameters:
objects - the objects
Returns:
A Task that is resolved when unpinning all completes.
See Also:
ParseObject.pinAllInBackground(java.util.List), ParseObject.DEFAULT_PIN

unpinAll

public static <T extends ParseObject> void unpinAll(List<T> objects)
                     throws ParseException
Removes the objects and every object they point to in the local datastore, recursively.

Parameters:
objects - the objects
Throws:
ParseException
See Also:
ParseObject.pinAll(java.util.List), ParseObject.DEFAULT_PIN

unpinAllInBackground

public static void unpinAllInBackground(String name,
                                        DeleteCallback callback)
Removes the objects and every object they point to in the local datastore, recursively.

Parameters:
name - the name
callback - the callback
See Also:
ParseObject.pinAll(String, java.util.List)

unpinAllInBackground

public static bolts.Task<Void> unpinAllInBackground(String name)
Removes the objects and every object they point to in the local datastore, recursively.

Parameters:
name - the name
Returns:
A Task that is resolved when unpinning all completes.
See Also:
ParseObject.pinAll(String, java.util.List)

unpinAll

public static void unpinAll(String name)
                     throws ParseException
Removes the objects and every object they point to in the local datastore, recursively.

Parameters:
name - the name
Throws:
ParseException
See Also:
ParseObject.pinAll(String, java.util.List)

unpinAllInBackground

public static void unpinAllInBackground(DeleteCallback callback)
Removes the objects and every object they point to in the local datastore, recursively.

Parameters:
callback - the callback
See Also:
ParseObject.pinAllInBackground(java.util.List, SaveCallback), ParseObject.DEFAULT_PIN

unpinAllInBackground

public static bolts.Task<Void> unpinAllInBackground()
Removes the objects and every object they point to in the local datastore, recursively.

Returns:
A Task that is resolved when unpinning all completes.
See Also:
ParseObject.pinAllInBackground(java.util.List, SaveCallback), ParseObject.DEFAULT_PIN

unpinAll

public static void unpinAll()
                     throws ParseException
Removes the objects and every object they point to in the local datastore, recursively.

Throws:
ParseException
See Also:
ParseObject.pinAll(java.util.List), ParseObject.DEFAULT_PIN

fetchFromLocalDatastoreInBackground

public <T extends ParseObject> void fetchFromLocalDatastoreInBackground(GetCallback<T> callback)
Loads data from the local datastore into this object, if it has not been fetched from the server already. If the object is not stored in the local datastore, this method with do nothing.


fetchFromLocalDatastore

public void fetchFromLocalDatastore()
                             throws ParseException
Loads data from the local datastore into this object, if it has not been fetched from the server already. If the object is not stored in the local datastore, this method with throw a CACHE_MISS exception.

Throws:
ParseException

pinInBackground

public void pinInBackground(String name,
                            SaveCallback callback)
Stores the object and every object it points to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Parameters:
callback - the callback
See Also:
ParseObject.unpinInBackground(String, DeleteCallback)

pinInBackground

public bolts.Task<Void> pinInBackground(String name)
Stores the object and every object it points to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Returns:
A Task that is resolved when pinning completes.
See Also:
ParseObject.unpinInBackground(String)

pin

public void pin(String name)
         throws ParseException
Stores the object and every object it points to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Throws:
ParseException
See Also:
ParseObject.unpin(String)

pinInBackground

public void pinInBackground(SaveCallback callback)
Stores the object and every object it points to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Parameters:
callback - the callback
See Also:
ParseObject.unpinInBackground(DeleteCallback), ParseObject.DEFAULT_PIN

pinInBackground

public bolts.Task<Void> pinInBackground()
Stores the object and every object it points to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Returns:
A Task that is resolved when pinning completes.
See Also:
ParseObject.unpinInBackground(), ParseObject.DEFAULT_PIN

pin

public void pin()
         throws ParseException
Stores the object and every object it points to in the local datastore, recursively. If those other objects have not been fetched from Parse, they will not be stored. However, if they have changed data, all of the changes will be retained. To get the objects back later, you can use a ParseQuery that uses ParseQuery#fromLocalDatastore(), or you can create an unfetched pointer with ParseObject.createWithoutData() and then call fetchFromLocalDatastore() on it.

Throws:
ParseException
See Also:
ParseObject.unpin(), ParseObject.DEFAULT_PIN

unpinInBackground

public void unpinInBackground(String name,
                              DeleteCallback callback)
Removes the object and every object it points to in the local datastore, recursively.

Parameters:
callback - the callback
See Also:
ParseObject.pinInBackground(String, SaveCallback)

unpinInBackground

public bolts.Task<Void> unpinInBackground(String name)
Removes the object and every object it points to in the local datastore, recursively.

Returns:
A Task that is resolved when unpinning completes.
See Also:
ParseObject.pinInBackground(String)

unpin

public void unpin(String name)
           throws ParseException
Removes the object and every object it points to in the local datastore, recursively.

Throws:
ParseException
See Also:
ParseObject.pin(String)

unpinInBackground

public void unpinInBackground(DeleteCallback callback)
Removes the object and every object it points to in the local datastore, recursively.

Parameters:
callback - the callback
See Also:
ParseObject.pinInBackground(SaveCallback), ParseObject.DEFAULT_PIN

unpinInBackground

public bolts.Task<Void> unpinInBackground()
Removes the object and every object it points to in the local datastore, recursively.

Returns:
A Task that is resolved when unpinning completes.
See Also:
ParseObject.pinInBackground(), ParseObject.DEFAULT_PIN

unpin

public void unpin()
           throws ParseException
Removes the object and every object it points to in the local datastore, recursively.

Throws:
ParseException
See Also:
ParseObject.pin(), ParseObject.DEFAULT_PIN