Package com.parse
Class ParseObject
- java.lang.Object
-
- com.parse.ParseObject
-
- Direct Known Subclasses:
ParseInstallation,ParseRole,ParseSession,ParseUser
public class ParseObject extends java.lang.ObjectTheParseObjectis 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, useput(String, Object)to fill it with data, and then usesaveInBackground()to persist to the cloud.The basic workflow for accessing existing data is to use a
ParseQueryto specify which existing data to retrieve.
-
-
Field Summary
Fields Modifier and Type Field Description static <any>CREATORstatic java.lang.StringDEFAULT_PINDefault name for pinning if not specified.static java.lang.StringKEY_CREATED_ATstatic java.lang.StringKEY_OBJECT_IDstatic java.lang.StringKEY_UPDATED_AT
-
Constructor Summary
Constructors Constructor Description ParseObject(java.lang.String theClassName)Constructs a newParseObjectwith no data in it.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.String key, java.lang.Object value)Atomically adds an object to the end of the array associated with a given key.voidaddAll(java.lang.String key, java.util.Collection<?> values)Atomically adds the objects contained in aCollectionto the end of the array associated with a given key.voidaddAllUnique(java.lang.String key, java.util.Collection<?> values)Atomically adds the objects contained in aCollectionto the array associated with a given key, only adding elements which are not already present in the array.voidaddUnique(java.lang.String key, java.lang.Object value)Atomically adds an object to the array associated with a given key, only if it is not already present in the array.booleancontainsKey(java.lang.String key)Whether this object has a particular key.static <T extends ParseObject>
Tcreate(java.lang.Class<T> subclass)Creates a newParseObjectbased upon a subclass type.static ParseObjectcreate(java.lang.String className)Creates a newParseObjectbased upon a class name.static <T extends ParseObject>
TcreateWithoutData(java.lang.Class<T> subclass, java.lang.String objectId)Creates a reference to an existingParseObjectfor use in creating associations betweenParseObjects.static ParseObjectcreateWithoutData(java.lang.String className, java.lang.String objectId)Creates a reference to an existingParseObjectfor use in creating associations betweenParseObjects.voiddelete()Deletes this object on the server.static <T extends ParseObject>
voiddeleteAll(java.util.List<T> objects)Deletes each object in the provided list.static <T extends ParseObject>
<any>deleteAllInBackground(java.util.List<T> objects)Deletes each object in the provided list.static <T extends ParseObject>
voiddeleteAllInBackground(java.util.List<T> objects, DeleteCallback callback)Deletes each object in the provided list.<any>deleteEventually()Deletes this object from the server at some unspecified time in the future, even if Parse is currently inaccessible.voiddeleteEventually(DeleteCallback callback)Deletes this object from the server at some unspecified time in the future, even if Parse is currently inaccessible.<any>deleteInBackground()Deletes this object on the server in a background thread.voiddeleteInBackground(DeleteCallback callback)Deletes this object on the server in a background thread.intdescribeContents()<T extends ParseObject>
Tfetch()Fetches this object with the data from the server.static <T extends ParseObject>
java.util.List<T>fetchAll(java.util.List<T> objects)Fetches all the objects in the provided list.static <T extends ParseObject>
java.util.List<T>fetchAllIfNeeded(java.util.List<T> objects)Fetches all the objects that don't have data in the provided list.static <T extends ParseObject>
<any>fetchAllIfNeededInBackground(java.util.List<T> objects)Fetches all the objects that don't have data in the provided list in the background.static <T extends ParseObject>
voidfetchAllIfNeededInBackground(java.util.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>
<any>fetchAllInBackground(java.util.List<T> objects)Fetches all the objects in the provided list in the background.static <T extends ParseObject>
voidfetchAllInBackground(java.util.List<T> objects, FindCallback<T> callback)Fetches all the objects in the provided list in the background.voidfetchFromLocalDatastore()Loads data from the local datastore into this object, if it has not been fetched from the server already.<T extends ParseObject>
voidfetchFromLocalDatastoreInBackground(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>
TfetchIfNeeded()If thisParseObjecthas not been fetched (i.e.<T extends ParseObject>
<any>fetchIfNeededInBackground()If thisParseObjecthas not been fetched (i.e.<T extends ParseObject>
voidfetchIfNeededInBackground(GetCallback<T> callback)If thisParseObjecthas not been fetched (i.e.<T extends ParseObject>
<any>fetchInBackground()Fetches this object with the data from the server in a background thread.<T extends ParseObject>
voidfetchInBackground(GetCallback<T> callback)Fetches this object with the data from the server in a background thread.static <T extends ParseObject>
TfromJSON(JSONObject json, java.lang.String defaultClassName, ParseDecoder decoder)Creates a newParseObjectbased on data from the Parse server.static <T extends ParseObject>
TfromJSON(JSONObject json, java.lang.String defaultClassName, ParseDecoder decoder, java.util.Set<java.lang.String> selectedKeys)Creates a newParseObjectbased on data from the Parse server.java.lang.Objectget(java.lang.String key)Access a value.ParseACLgetACL()Access theParseACLgoverning this object.booleangetBoolean(java.lang.String key)Access abooleanvalue.byte[]getBytes(java.lang.String key)Access abyte[]value.java.lang.StringgetClassName()Accessor to the class name.java.util.DategetCreatedAt()java.util.DategetDate(java.lang.String key)Access aDatevalue.doublegetDouble(java.lang.String key)Access adoublevalue.intgetInt(java.lang.String key)Access anintvalue.JSONArraygetJSONArray(java.lang.String key)Access aJSONArrayvalue.JSONObjectgetJSONObject(java.lang.String key)Access aJSONObjectvalue.<T> java.util.List<T>getList(java.lang.String key)Access aListvalue.longgetLong(java.lang.String key)Access alongvalue.<V> java.util.Map<java.lang.String,V>getMap(java.lang.String key)Access aMapvaluejava.lang.NumbergetNumber(java.lang.String key)Access aNumbervalue.java.lang.StringgetObjectId()Accessor to the object id.ParseFilegetParseFile(java.lang.String key)Access aParseFilevalue.ParseGeoPointgetParseGeoPoint(java.lang.String key)Access aParseGeoPointvalue.ParseObjectgetParseObject(java.lang.String key)Access aParseObjectvalue.ParsePolygongetParsePolygon(java.lang.String key)Access aParsePolygonvalue.ParseUsergetParseUser(java.lang.String key)Access aParseUservalue.<T extends ParseObject>
ParseRelation<T>getRelation(java.lang.String key)Access or create aParseRelationvalue for a keyjava.lang.StringgetString(java.lang.String key)Access aStringvalue.java.util.DategetUpdatedAt()booleanhas(java.lang.String key)Whether this object has a particular key.booleanhasSameId(ParseObject other)voidincrement(java.lang.String key)Atomically increments the given key by 1.voidincrement(java.lang.String key, java.lang.Number amount)Atomically increments the given key by the given number.booleanisDataAvailable()Gets whether theParseObjecthas been fetched.booleanisDataAvailable(java.lang.String key)Gets whether theParseObjectspecified key has been fetched.booleanisDirty()Whether any key-value pair in this object (or its children) has been added/updated/removed and not saved yet.booleanisDirty(java.lang.String key)Whether a value associated with a key has been added/updated/removed and not saved yet.java.util.Set<java.lang.String>keySet()Returns a set view of the keys contained in this object.voidpin()Stores the object and every object it points to in the local datastore, recursively.voidpin(java.lang.String name)Stores the object and every object it points to in the local datastore, recursively.static <T extends ParseObject>
voidpinAll(java.lang.String name, java.util.List<T> objects)Stores the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
voidpinAll(java.util.List<T> objects)Stores the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
<any>pinAllInBackground(java.lang.String name, java.util.List<T> objects)Stores the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
voidpinAllInBackground(java.lang.String name, java.util.List<T> objects, SaveCallback callback)Stores the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
<any>pinAllInBackground(java.util.List<T> objects)Stores the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
voidpinAllInBackground(java.util.List<T> objects, SaveCallback callback)Stores the objects and every object they point to in the local datastore, recursively.<any>pinInBackground()Stores the object and every object it points to in the local datastore, recursively.voidpinInBackground(SaveCallback callback)Stores the object and every object it points to in the local datastore, recursively.<any>pinInBackground(java.lang.String name)Stores the object and every object it points to in the local datastore, recursively.voidpinInBackground(java.lang.String name, SaveCallback callback)Stores the object and every object it points to in the local datastore, recursively.voidput(java.lang.String key, java.lang.Object value)Add a key-value pair to this object.static voidregisterSubclass(java.lang.Class<? extends ParseObject> subclass)Registers a custom subclass type with the Parse SDK, enabling strong-typing of thoseParseObjects whenever they appear.voidremove(java.lang.String key)Removes a key from this object's data if it exists.voidremoveAll(java.lang.String key, java.util.Collection<?> values)Atomically removes all instances of the objects contained in aCollectionfrom the array associated with a given key.voidrevert()Clears any changes to this object made since the last call tosave()orsaveInBackground().voidrevert(java.lang.String key)voidsave()Saves this object to the server.static <T extends ParseObject>
voidsaveAll(java.util.List<T> objects)Saves each object in the provided list.static <T extends ParseObject>
<any>saveAllInBackground(java.util.List<T> objects)Saves each object in the provided list to the server in a background thread.static <T extends ParseObject>
voidsaveAllInBackground(java.util.List<T> objects, SaveCallback callback)Saves each object in the provided list to the server in a background thread.<any>saveEventually()Saves this object to the server at some unspecified time in the future, even if Parse is currently inaccessible.voidsaveEventually(SaveCallback callback)Saves this object to the server at some unspecified time in the future, even if Parse is currently inaccessible.<any>saveInBackground()Saves this object to the server in a background thread.voidsaveInBackground(SaveCallback callback)Saves this object to the server in a background thread.voidsetACL(ParseACL acl)Set theParseACLgoverning this object.voidsetObjectId(java.lang.String newObjectId)Setter for the object id.voidunpin()Removes the object and every object it points to in the local datastore, recursively.voidunpin(java.lang.String name)Removes the object and every object it points to in the local datastore, recursively.static voidunpinAll()Removes the objects and every object they point to in the local datastore, recursively.static voidunpinAll(java.lang.String name)Removes the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
voidunpinAll(java.lang.String name, java.util.List<T> objects)Removes the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
voidunpinAll(java.util.List<T> objects)Removes the objects and every object they point to in the local datastore, recursively.static <any>unpinAllInBackground()Removes the objects and every object they point to in the local datastore, recursively.static voidunpinAllInBackground(DeleteCallback callback)Removes the objects and every object they point to in the local datastore, recursively.static <any>unpinAllInBackground(java.lang.String name)Removes the objects and every object they point to in the local datastore, recursively.static voidunpinAllInBackground(java.lang.String name, DeleteCallback callback)Removes the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
<any>unpinAllInBackground(java.lang.String name, java.util.List<T> objects)Removes the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
voidunpinAllInBackground(java.lang.String name, java.util.List<T> objects, DeleteCallback callback)Removes the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
<any>unpinAllInBackground(java.util.List<T> objects)Removes the objects and every object they point to in the local datastore, recursively.static <T extends ParseObject>
voidunpinAllInBackground(java.util.List<T> objects, DeleteCallback callback)Removes the objects and every object they point to in the local datastore, recursively.<any>unpinInBackground()Removes the object and every object it points to in the local datastore, recursively.voidunpinInBackground(DeleteCallback callback)Removes the object and every object it points to in the local datastore, recursively.<any>unpinInBackground(java.lang.String name)Removes the object and every object it points to in the local datastore, recursively.voidunpinInBackground(java.lang.String name, DeleteCallback callback)Removes the object and every object it points to in the local datastore, recursively.voidwriteToParcel(Parcel dest, int flags)
-
-
-
Field Detail
-
DEFAULT_PIN
public static final java.lang.String DEFAULT_PIN
Default name for pinning if not specified.- See Also:
pin(),unpin(), Constant Field Values
-
KEY_OBJECT_ID
public static final java.lang.String KEY_OBJECT_ID
- See Also:
- Constant Field Values
-
KEY_CREATED_AT
public static final java.lang.String KEY_CREATED_AT
- See Also:
- Constant Field Values
-
KEY_UPDATED_AT
public static final java.lang.String KEY_UPDATED_AT
- See Also:
- Constant Field Values
-
CREATOR
public static final <any> CREATOR
-
-
Constructor Detail
-
ParseObject
public ParseObject(java.lang.String theClassName)
Constructs a newParseObjectwith no data in it. AParseObjectconstructed in this way will not have an objectId and will not persist to the database untilsave()is called.Class names must be alphanumerical plus underscore, and start with a letter. It is recommended to name classes in
PascalCaseLikeThis.- Parameters:
theClassName- The className for thisParseObject.
-
-
Method Detail
-
create
public static ParseObject create(java.lang.String className)
Creates a newParseObjectbased upon a class name. If the class name is a special type (e.g. forParseUser), then the appropriate type ofParseObjectis returned.- Parameters:
className- The class of object to create.- Returns:
- A new
ParseObjectfor the given class name.
-
create
public static <T extends ParseObject> T create(java.lang.Class<T> subclass)
Creates a newParseObjectbased upon a subclass type. Note that the object will be created based upon theParseClassNameof the given subclass type. For example, calling create(ParseUser.class) may create an instance of a custom subclass ofParseUser.- Parameters:
subclass- The class of object to create.- Returns:
- A new
ParseObjectbased upon the class name of the given subclass type.
-
createWithoutData
public static ParseObject createWithoutData(java.lang.String className, java.lang.String objectId)
Creates a reference to an existingParseObjectfor use in creating associations betweenParseObjects. CallingisDataAvailable()on this object will returnfalseuntilfetchIfNeeded()orfetch()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
ParseObjectwithout data.
-
createWithoutData
public static <T extends ParseObject> T createWithoutData(java.lang.Class<T> subclass, java.lang.String objectId)
Creates a reference to an existingParseObjectfor use in creating associations betweenParseObjects. CallingisDataAvailable()on this object will returnfalseuntilfetchIfNeeded()orfetch()has been called. No network request will be made.- Parameters:
subclass- TheParseObjectsubclass to create.objectId- The object id for the referenced object.- Returns:
- A
ParseObjectwithout data.
-
registerSubclass
public static void registerSubclass(java.lang.Class<? extends ParseObject> subclass)
Registers a custom subclass type with the Parse SDK, enabling strong-typing of thoseParseObjects whenever they appear. Subclasses must specify theParseClassNameannotation and have a default constructor.- Parameters:
subclass- The subclass type to register.
-
fromJSON
public static <T extends ParseObject> T fromJSON(JSONObject json, java.lang.String defaultClassName, ParseDecoder decoder, java.util.Set<java.lang.String> selectedKeys)
Creates a newParseObjectbased on data from the Parse server.- Parameters:
json- The object's data.defaultClassName- The className of the object, if none is in the JSON.decoder- Delegate for knowing how to decode the values in the JSON.selectedKeys- Set of keys selected when quering for this object. If none, the object is assumed to be complete, i.e. this is all the data for the object on the server.
-
fromJSON
public static <T extends ParseObject> T fromJSON(JSONObject json, java.lang.String defaultClassName, ParseDecoder decoder)
Creates a newParseObjectbased on data from the Parse server.- Parameters:
json- The object's data. It is assumed to be complete, unless the JSON has theKEY_SELECTED_KEYSkey.defaultClassName- The className of the object, if none is in the JSON.decoder- Delegate for knowing how to decode the values in the JSON.
-
deleteAll
public static <T extends ParseObject> void deleteAll(java.util.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(java.util.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> <any> deleteAllInBackground(java.util.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
Taskthat is resolved when deleteAll completes.
-
saveAll
public static <T extends ParseObject> void saveAll(java.util.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(java.util.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> <any> saveAllInBackground(java.util.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
Taskthat is resolved when saveAll completes.
-
fetchAllIfNeededInBackground
public static <T extends ParseObject> <any> fetchAllIfNeededInBackground(java.util.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
Taskthat is resolved when fetchAllIfNeeded completes.
-
fetchAllIfNeeded
public static <T extends ParseObject> java.util.List<T> fetchAllIfNeeded(java.util.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(java.util.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> <any> fetchAllInBackground(java.util.List<T> objects)
Fetches all the objects in the provided list in the background.- Parameters:
objects- The list of objects to fetch.- Returns:
- A
Taskthat is resolved when fetch completes.
-
fetchAll
public static <T extends ParseObject> java.util.List<T> fetchAll(java.util.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(java.util.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.
-
pinAllInBackground
public static <T extends ParseObject> void pinAllInBackground(java.lang.String name, java.util.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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Parameters:
name- the nameobjects- the objects to be pinnedcallback- the callback- See Also:
unpinAllInBackground(String, java.util.List, DeleteCallback)
-
pinAllInBackground
public static <T extends ParseObject> <any> pinAllInBackground(java.lang.String name, java.util.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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Parameters:
name- the nameobjects- the objects to be pinned- Returns:
- A
Taskthat is resolved when pinning all completes. - See Also:
unpinAllInBackground(String, java.util.List)
-
pinAll
public static <T extends ParseObject> void pinAll(java.lang.String name, java.util.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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.fetchFromLocalDatastore()on it.- Parameters:
name- the nameobjects- the objects to be pinned- Throws:
ParseException- exception if fails- See Also:
unpinAll(String, java.util.List)
-
pinAllInBackground
public static <T extends ParseObject> void pinAllInBackground(java.util.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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Parameters:
objects- the objects to be pinnedcallback- the callback- See Also:
unpinAllInBackground(java.util.List, DeleteCallback),DEFAULT_PIN
-
pinAllInBackground
public static <T extends ParseObject> <any> pinAllInBackground(java.util.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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Parameters:
objects- the objects to be pinned- Returns:
- A
Taskthat is resolved when pinning all completes. - See Also:
unpinAllInBackground(java.util.List),DEFAULT_PIN
-
pinAll
public static <T extends ParseObject> void pinAll(java.util.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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Parameters:
objects- the objects to be pinned- Throws:
ParseException- exception if fails- See Also:
unpinAll(java.util.List),DEFAULT_PIN
-
unpinAllInBackground
public static <T extends ParseObject> void unpinAllInBackground(java.lang.String name, java.util.List<T> objects, DeleteCallback callback)
Removes the objects and every object they point to in the local datastore, recursively.- Parameters:
name- the nameobjects- the objectscallback- the callback- See Also:
pinAllInBackground(String, java.util.List, SaveCallback)
-
unpinAllInBackground
public static <T extends ParseObject> <any> unpinAllInBackground(java.lang.String name, java.util.List<T> objects)
Removes the objects and every object they point to in the local datastore, recursively.- Parameters:
name- the nameobjects- the objects- Returns:
- A
Taskthat is resolved when unpinning all completes. - See Also:
pinAllInBackground(String, java.util.List)
-
unpinAll
public static <T extends ParseObject> void unpinAll(java.lang.String name, java.util.List<T> objects) throws ParseException
Removes the objects and every object they point to in the local datastore, recursively.- Parameters:
name- the nameobjects- the objects- Throws:
ParseException- exception if fails- See Also:
pinAll(String, java.util.List)
-
unpinAllInBackground
public static <T extends ParseObject> void unpinAllInBackground(java.util.List<T> objects, DeleteCallback callback)
Removes the objects and every object they point to in the local datastore, recursively.- Parameters:
objects- the objectscallback- the callback- See Also:
pinAllInBackground(java.util.List, SaveCallback),DEFAULT_PIN
-
unpinAllInBackground
public static <T extends ParseObject> <any> unpinAllInBackground(java.util.List<T> objects)
Removes the objects and every object they point to in the local datastore, recursively.- Parameters:
objects- the objects- Returns:
- A
Taskthat is resolved when unpinning all completes. - See Also:
pinAllInBackground(java.util.List),DEFAULT_PIN
-
unpinAll
public static <T extends ParseObject> void unpinAll(java.util.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- exception if fails- See Also:
pinAll(java.util.List),DEFAULT_PIN
-
unpinAllInBackground
public static void unpinAllInBackground(java.lang.String name, DeleteCallback callback)Removes the objects and every object they point to in the local datastore, recursively.- Parameters:
name- the namecallback- the callback- See Also:
pinAll(String, java.util.List)
-
unpinAllInBackground
public static <any> unpinAllInBackground(java.lang.String name)
Removes the objects and every object they point to in the local datastore, recursively.- Parameters:
name- the name- Returns:
- A
Taskthat is resolved when unpinning all completes. - See Also:
pinAll(String, java.util.List)
-
unpinAll
public static void unpinAll(java.lang.String name) throws ParseExceptionRemoves the objects and every object they point to in the local datastore, recursively.- Parameters:
name- the name- Throws:
ParseException- exception if fails- See Also:
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:
pinAllInBackground(java.util.List, SaveCallback),DEFAULT_PIN
-
unpinAllInBackground
public static <any> unpinAllInBackground()
Removes the objects and every object they point to in the local datastore, recursively.- Returns:
- A
Taskthat is resolved when unpinning all completes. - See Also:
pinAllInBackground(java.util.List, SaveCallback),DEFAULT_PIN
-
unpinAll
public static void unpinAll() throws ParseExceptionRemoves the objects and every object they point to in the local datastore, recursively.- Throws:
ParseException- exception if fails- See Also:
pinAll(java.util.List),DEFAULT_PIN
-
getClassName
public java.lang.String getClassName()
Accessor to the class name.
-
getUpdatedAt
public java.util.Date getUpdatedAt()
This reports time as the server sees it, so that if you make changes to aParseObject, then wait a while, and then callsave(), the updated time will be the time of thesave()call rather than the time the object was changed locally.- Returns:
- The last time this object was updated on the server.
-
getCreatedAt
public java.util.Date getCreatedAt()
This reports time as the server sees it, so that if you create aParseObject, then wait a while, and then callsave(), the creation time will be the time of the firstsave()call rather than the time the object was created locally.- Returns:
- The first time this object was saved on the server.
-
keySet
public java.util.Set<java.lang.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.Note that while the returned set is unmodifiable, it is in fact not thread-safe, and creating a copy is recommended before iterating over it.
-
revert
public void revert(java.lang.String key)
- Parameters:
key- Thekeyto revert changes for.
-
revert
public void revert()
Clears any changes to this object made since the last call tosave()orsaveInBackground().
-
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:
- Whether this object has been altered and not saved yet.
-
isDirty
public boolean isDirty(java.lang.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:
- Whether this key has been altered and not saved yet.
-
getObjectId
public java.lang.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(java.lang.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 aParseObjectyourself and wish to recreate it, you can use this to recreate theParseObjectexactly.
-
save
public final void save() throws ParseExceptionSaves this object to the server. Typically, you should usesaveInBackground()instead of this, unless you are managing your own threading.- Throws:
ParseException- Throws an exception if the server is inaccessible.
-
saveInBackground
public final <any> saveInBackground()
Saves this object to the server in a background thread. This is preferable to usingsave(), unless your code is already running from a background thread.- Returns:
- A
Taskthat 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 usingsave(), 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()ordeleteEventually()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 <any> 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()ordeleteEventually()will cause old saves to be silently discarded until the connection can be re-established, and the queued objects can be saved.- Returns:
- A
Taskthat 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()orsaveEventually()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 <any> 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()orsaveEventually()will cause old instructions to be silently discarded until the connection can be re-established, and the queued objects can be saved.- Returns:
- A
Taskthat is resolved when the delete 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
ParseObjectthat was fetched. - Throws:
ParseException- Throws an exception if the server is inaccessible.
-
fetchInBackground
public final <T extends ParseObject> <any> 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
Taskthat 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> <any> fetchIfNeededInBackground()
If thisParseObjecthas not been fetched (i.e.isDataAvailable()returnsfalse), fetches this object with the data from the server in a background thread. This is preferable to usingfetchIfNeeded(), unless your code is already running from a background thread.- Returns:
- A
Taskthat is resolved when fetch completes.
-
fetchIfNeeded
public <T extends ParseObject> T fetchIfNeeded() throws ParseException
If thisParseObjecthas not been fetched (i.e.isDataAvailable()returnsfalse), 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 thisParseObjecthas not been fetched (i.e.isDataAvailable()returnsfalse), fetches this object with the data from the server in a background thread. This is preferable to usingfetchIfNeeded(), 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 <any> deleteInBackground()
Deletes this object on the server in a background thread. This is preferable to usingdelete(), unless your code is already running from a background thread.- Returns:
- A
Taskthat is resolved when delete completes.
-
delete
public final void delete() throws ParseExceptionDeletes 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 usingdelete(), unless your code is already running from a background thread.- Parameters:
callback-callback.done(e)is called when the save completes.
-
put
public void put(java.lang.String key, java.lang.Object value)Add a key-value pair to this object. It is recommended to name keys incamelCaseLikeThis.- Parameters:
key- Keys must be alphanumerical plus underscore, and start with a letter.value- Values may be numerical,String,JSONObject,JSONArray,JSONObject#NULL, or otherParseObjects. value may not benull.
-
has
public boolean has(java.lang.String key)
Whether this object has a particular key. Same ascontainsKey(String).- Parameters:
key- The key to check for- Returns:
- Whether this object contains the key
-
increment
public void increment(java.lang.String key)
Atomically increments the given key by 1.- Parameters:
key- The key to increment.
-
increment
public void increment(java.lang.String key, java.lang.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(java.lang.String key, java.lang.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(java.lang.String key, java.util.Collection<?> values)Atomically adds the objects contained in aCollectionto the end of the array associated with a given key.- Parameters:
key- The key.values- The objects to add.
-
addUnique
public void addUnique(java.lang.String key, java.lang.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(java.lang.String key, java.util.Collection<?> values)Atomically adds the objects contained in aCollectionto 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.
-
remove
public void remove(java.lang.String key)
Removes a key from this object's data if it exists.- Parameters:
key- The key to remove.
-
removeAll
public void removeAll(java.lang.String key, java.util.Collection<?> values)Atomically removes all instances of the objects contained in aCollectionfrom 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 callparseObject.removeAll(key, Arrays.asList(value)).- Parameters:
key- The key.values- The objects to remove.
-
containsKey
public boolean containsKey(java.lang.String key)
Whether this object has a particular key. Same ashas(String).- Parameters:
key- The key to check for- Returns:
- Whether this object contains the key
-
getString
public java.lang.String getString(java.lang.String key)
Access aStringvalue.- Parameters:
key- The key to access the value for.- Returns:
nullif there is no such key or if it is not aString.
-
getBytes
public byte[] getBytes(java.lang.String key)
Access abyte[]value.- Parameters:
key- The key to access the value for.- Returns:
nullif there is no such key or if it is not abyte[].
-
getNumber
public java.lang.Number getNumber(java.lang.String key)
Access aNumbervalue.- Parameters:
key- The key to access the value for.- Returns:
nullif there is no such key or if it is not aNumber.
-
getJSONArray
public JSONArray getJSONArray(java.lang.String key)
Access aJSONArrayvalue.- Parameters:
key- The key to access the value for.- Returns:
nullif there is no such key or if it is not aJSONArray.
-
getList
public <T> java.util.List<T> getList(java.lang.String key)
Access aListvalue.- Parameters:
key- The key to access the value for- Returns:
nullif there is no such key or if the value can't be converted to aList.
-
getMap
public <V> java.util.Map<java.lang.String,V> getMap(java.lang.String key)
Access aMapvalue- Parameters:
key- The key to access the value for- Returns:
nullif there is no such key or if the value can't be converted to aMap.
-
getJSONObject
public JSONObject getJSONObject(java.lang.String key)
Access aJSONObjectvalue.- Parameters:
key- The key to access the value for.- Returns:
nullif there is no such key or if it is not aJSONObject.
-
getInt
public int getInt(java.lang.String key)
Access anintvalue.- Parameters:
key- The key to access the value for.- Returns:
0if there is no such key or if it is not aint.
-
getDouble
public double getDouble(java.lang.String key)
Access adoublevalue.- Parameters:
key- The key to access the value for.- Returns:
0if there is no such key or if it is not adouble.
-
getLong
public long getLong(java.lang.String key)
Access alongvalue.- Parameters:
key- The key to access the value for.- Returns:
0if there is no such key or if it is not along.
-
getBoolean
public boolean getBoolean(java.lang.String key)
Access abooleanvalue.- Parameters:
key- The key to access the value for.- Returns:
falseif there is no such key or if it is not aboolean.
-
getDate
public java.util.Date getDate(java.lang.String key)
Access aDatevalue.- Parameters:
key- The key to access the value for.- Returns:
nullif there is no such key or if it is not aDate.
-
getParseObject
public ParseObject getParseObject(java.lang.String key)
Access aParseObjectvalue. This function will not perform a network request. Unless theParseObjecthas been downloaded (e.g. by aParseQuery.include(String)or by callingfetchIfNeeded()orfetch()),isDataAvailable()will returnfalse.- Parameters:
key- The key to access the value for.- Returns:
nullif there is no such key or if it is not aParseObject.
-
getParseUser
public ParseUser getParseUser(java.lang.String key)
Access aParseUservalue. This function will not perform a network request. Unless theParseObjecthas been downloaded (e.g. by aParseQuery.include(String)or by callingfetchIfNeeded()orfetch()),isDataAvailable()will returnfalse.- Parameters:
key- The key to access the value for.- Returns:
nullif there is no such key or if the value is not aParseUser.
-
getParseFile
public ParseFile getParseFile(java.lang.String key)
Access aParseFilevalue. This function will not perform a network request. Unless theParseFilehas been downloaded (e.g. by callingParseFile.getData()),ParseFile.isDataAvailable()will returnfalse.- Parameters:
key- The key to access the value for.- Returns:
nullif there is no such key or if it is not aParseFile.
-
getParseGeoPoint
public ParseGeoPoint getParseGeoPoint(java.lang.String key)
Access aParseGeoPointvalue.- Parameters:
key- The key to access the value for- Returns:
nullif there is no such key or if it is not aParseGeoPoint.
-
getParsePolygon
public ParsePolygon getParsePolygon(java.lang.String key)
Access aParsePolygonvalue.- Parameters:
key- The key to access the value for- Returns:
nullif there is no such key or if it is not aParsePolygon.
-
isDataAvailable
public boolean isDataAvailable()
Gets whether theParseObjecthas been fetched.- Returns:
trueif theParseObjectis new or has been fetched or refreshed.falseotherwise.
-
isDataAvailable
public boolean isDataAvailable(java.lang.String key)
Gets whether theParseObjectspecified key has been fetched. This means the property can be accessed safely.- Returns:
trueif theParseObjectkey is new or has been fetched or refreshed.falseotherwise.
-
getRelation
public <T extends ParseObject> ParseRelation<T> getRelation(java.lang.String key)
Access or create aParseRelationvalue 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 java.lang.Object get(java.lang.String key)
Access a value. In most cases it is more convenient to use a helper function such asgetString(String)orgetInt(String).- Parameters:
key- The key to access the value for.- Returns:
nullif there is no such key.
-
hasSameId
public boolean hasSameId(ParseObject other)
-
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 ParseExceptionLoads 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- exception if fails
-
pinInBackground
public void pinInBackground(java.lang.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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Parameters:
callback- the callback- See Also:
unpinInBackground(String, DeleteCallback)
-
pinInBackground
public <any> pinInBackground(java.lang.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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Returns:
- A
Taskthat is resolved when pinning completes. - See Also:
unpinInBackground(String)
-
pin
public void pin(java.lang.String name) throws ParseExceptionStores 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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Throws:
ParseException- exception if fails- See Also:
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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Parameters:
callback- the callback- See Also:
unpinInBackground(DeleteCallback),DEFAULT_PIN
-
pinInBackground
public <any> 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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Returns:
- A
Taskthat is resolved when pinning completes. - See Also:
unpinInBackground(),DEFAULT_PIN
-
pin
public void pin() throws ParseExceptionStores 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 useParseQuery.fromLocalDatastore(), or you can create an unfetched pointer withcreateWithoutData(Class, String)and then callfetchFromLocalDatastore()on it.- Throws:
ParseException- exception if fails- See Also:
unpin(),DEFAULT_PIN
-
unpinInBackground
public void unpinInBackground(java.lang.String name, DeleteCallback callback)Removes the object and every object it points to in the local datastore, recursively.- Parameters:
callback- the callback- See Also:
pinInBackground(String, SaveCallback)
-
unpinInBackground
public <any> unpinInBackground(java.lang.String name)
Removes the object and every object it points to in the local datastore, recursively.- Returns:
- A
Taskthat is resolved when unpinning completes. - See Also:
pinInBackground(String)
-
unpin
public void unpin(java.lang.String name) throws ParseExceptionRemoves the object and every object it points to in the local datastore, recursively.- Throws:
ParseException- See Also:
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:
pinInBackground(SaveCallback),DEFAULT_PIN
-
unpinInBackground
public <any> unpinInBackground()
Removes the object and every object it points to in the local datastore, recursively.- Returns:
- A
Taskthat is resolved when unpinning completes. - See Also:
pinInBackground(),DEFAULT_PIN
-
unpin
public void unpin() throws ParseExceptionRemoves the object and every object it points to in the local datastore, recursively.- Throws:
ParseException- See Also:
pin(),DEFAULT_PIN
-
describeContents
public int describeContents()
-
writeToParcel
public void writeToParcel(Parcel dest, int flags)
-
-