|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectcom.parse.ParseObject
public class ParseObject
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.
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
|
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
|
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. |
|
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. |
|
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. |
|
|
fetch()
Fetches this object with the data from the server. |
|
static List<ParseObject> |
fetchAll(List<ParseObject> objects)
Fetches all the objects in the provided list. |
|
static
|
fetchAllIfNeeded(List<T> objects)
Fetches all the objects that don't have data in the provided list. |
|
static
|
fetchAllIfNeededInBackground(List<T> objects,
FindCallback<T> callback)
Fetches all the objects that don't have data in the provided list in the background |
|
static
|
fetchAllInBackground(List<T> objects,
FindCallback<T> callback)
Fetches all the objects in the provided list in the background |
|
ParseObject |
fetchIfNeeded()
If this ParseObject has not been fetched (i.e. |
|
void |
fetchIfNeededInBackground(GetCallback<ParseObject> callback)
If this ParseObject has not been fetched (i.e. |
|
|
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. |
|
|
getList(String key)
Access a List |
|
long |
getLong(String key)
Access a long value. |
|
|
getMap(String key)
Access a Map |
|
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. |
|
|
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. |
|
Set<String> |
keySet()
Returns a set view of the keys contained in this object. |
|
void |
put(String key,
Object value)
Add a key-value pair to this object. |
|
void |
refresh()
Refreshes this object with the data from the server. |
|
void |
refreshInBackground(RefreshCallback callback)
Refreshes this object with the data from the server in a background thread. |
|
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 void |
saveAll(List<ParseObject> objects)
Saves each object in the provided list. |
|
static void |
saveAllInBackground(List<ParseObject> objects)
Saves each object to the server in a background thread. |
|
static void |
saveAllInBackground(List<ParseObject> objects,
SaveCallback callback)
Saves each object in the provided list to the server in a background thread. |
|
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. |
|
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. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ParseObject()
ParseClassName
annotation on the subclass.
public ParseObject(String theClassName)
Class names must be alphanumerical plus underscore, and start with a letter. It is recommended to name classes in CamelCaseLikeThis.
theClassName
- The className for this ParseObject.Method Detail |
---|
public static ParseObject create(String className)
className
- The class of object to create.
public static <T extends ParseObject> T create(Class<T> subclass)
ParseClassName
of the given subclass type. For example, calling
create(ParseUser.class) may create an instance of a custom subclass of ParseUser.
subclass
- The class of object to create.
public static ParseObject createWithoutData(String className, String objectId)
ParseObject.isDataAvailable()
on this object will return false
until
ParseObject.fetchIfNeeded()
or ParseObject.refresh()
has been called. No network request will be
made.
className
- The object's class.objectId
- The object id for the referenced object.
public static <T extends ParseObject> T createWithoutData(Class<T> subclass, String objectId)
ParseObject.isDataAvailable()
on this object will return false
until
ParseObject.fetchIfNeeded()
or ParseObject.refresh()
has been called. No network request will be
made.
subclass
- The ParseObject subclass to create.objectId
- The object id for the referenced object.
public static void registerSubclass(Class<? extends ParseObject> subclass)
ParseClassName
annotation and have a default constructor.
subclass
- The subclass type to register.public String getClassName()
public Set<String> keySet()
public Date getUpdatedAt()
public Date getCreatedAt()
public String getObjectId()
public void setObjectId(String newObjectId)
public final void save() throws ParseException
ParseObject.saveInBackground(com.parse.SaveCallback)
instead of
this, unless you are managing your own threading.
ParseException
- Throws an exception if the server is inaccessible.public final void saveInBackground(SaveCallback callback)
callback
- callback.done(e) is called when the save completes.public final void saveInBackground()
public final void saveEventually()
public void saveEventually(SaveCallback callback)
callback
- - A callback which will be called if the save completes before the app exits.public final void deleteEventually()
public final void deleteEventually(DeleteCallback callback)
callback
- - A callback which will be called if the delete completes before the app exits.public final void refresh() throws ParseException
ParseException
- Throws an exception if the server is inaccessible.public final void refreshInBackground(RefreshCallback callback)
callback
- callback.done(object, e) is called when the refresh completes.public <T extends ParseObject> T fetch() throws ParseException
ParseException
- Throws an exception if the server is inaccessible.public final <T extends ParseObject> void fetchInBackground(GetCallback<T> callback)
callback
- callback.done(object, e) is called when the fetch completes.public ParseObject fetchIfNeeded() throws ParseException
ParseObject.isDataAvailable()
returns false),
fetches this object with the data from the server.
ParseException
- Throws an exception if the server is inaccessible.public final void fetchIfNeededInBackground(GetCallback<ParseObject> callback)
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.
callback
- callback.done(object, e) is called when the fetch completes.public final void delete() throws ParseException
ParseException
- Throws an error if the object does not exist or if the internet fails.public final void deleteInBackground(DeleteCallback callback)
callback
- callback.done(e) is called when the save completes.public final void deleteInBackground()
public static void saveAll(List<ParseObject> objects) throws ParseException
objects
- The objects to save.
ParseException
- Throws an exception if the server returns an error or is inaccessible.public static <T extends ParseObject> List<T> fetchAllIfNeeded(List<T> objects) throws ParseException
objects
- The list of objects to fetch.
ParseException
- Throws an exception if the server returns an error or is inaccessible.public static <T extends ParseObject> void fetchAllIfNeededInBackground(List<T> objects, FindCallback<T> callback)
objects
- The list of objects to fetch.callback
- callback.done(result, e) is called when the fetch completes.public static List<ParseObject> fetchAll(List<ParseObject> objects) throws ParseException
objects
- The list of objects to fetch.
ParseException
- Throws an exception if the server returns an error or is inaccessible.public static <T extends ParseObject> void fetchAllInBackground(List<T> objects, FindCallback<T> callback)
objects
- The list of objects to fetch.callback
- callback.done(result, e) is called when the fetch completes.public static void saveAllInBackground(List<ParseObject> objects, SaveCallback callback)
objects
- The objects to save.callback
- callback.done(e) is called when the save completes.public static void saveAllInBackground(List<ParseObject> objects)
objects
- The objects to save.public void remove(String key)
key
- The key to remove.public boolean has(String key)
key
- The key to check for
public void put(String key, Object value)
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
.public void increment(String key)
key
- The key to increment.public void increment(String key, Number amount)
key
- The key to increment.amount
- The amount to increment by.public void add(String key, Object value)
key
- The key.value
- The object to add.public void addAll(String key, Collection<?> values)
Collection
to the end of the array
associated with a given key.
key
- The key.values
- The objects to add.public void addUnique(String key, Object value)
key
- The key.value
- The object to add.public void addAllUnique(String key, Collection<?> values)
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.
key
- The key.values
- The objects to add.public void removeAll(String key, Collection<?> values)
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))
.
key
- The key.values
- The objects to remove.public boolean containsKey(String key)
key
- The key to check for
public String getString(String key)
key
- The key to access the value for.
public byte[] getBytes(String key)
key
- The key to access the value for.
public Number getNumber(String key)
key
- The key to access the value for.
public JSONArray getJSONArray(String key)
key
- The key to access the value for.
public <T> List<T> getList(String key)
key
- The key to access the value for
public <V> Map<String,V> getMap(String key)
key
- The key to access the value for
public JSONObject getJSONObject(String key)
key
- The key to access the value for.
public int getInt(String key)
key
- The key to access the value for.
public double getDouble(String key)
key
- The key to access the value for.
public long getLong(String key)
key
- The key to access the value for.
public boolean getBoolean(String key)
key
- The key to access the value for.
public Date getDate(String key)
key
- The key to access the value for.
public ParseObject getParseObject(String key)
ParseQuery.include(String)
or by calling
ParseObject.fetchIfNeeded()
or ParseObject.refresh()
), ParseObject.isDataAvailable()
will return false.
key
- The key to access the value for.
public ParseUser getParseUser(String key)
ParseQuery.include(String)
or by calling
ParseObject.fetchIfNeeded()
or ParseObject.refresh()
), ParseObject.isDataAvailable()
will return false.
key
- The key to access the value for.
public ParseFile getParseFile(String key)
ParseFile.getData()
),
ParseFile.isDataAvailable()
will return false.
key
- The key to access the value for.
public ParseGeoPoint getParseGeoPoint(String key)
key
- The key to access the value for
public ParseACL getACL()
public void setACL(ParseACL acl)
public boolean isDataAvailable()
true
if the ParseObject is new or has been fetched or refreshed. false
otherwise.public <T extends ParseObject> ParseRelation<T> getRelation(String key)
key
- The key to access the relation for.
public Object get(String key)
key
- The key to access the value for.
Throws
- a ParseException if the server could not be reached to load a relational value.public boolean hasSameId(ParseObject other)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |