Class ParseQuery<T extends ParseObject>
- java.lang.Object
-
- com.parse.ParseQuery<T>
-
public class ParseQuery<T extends ParseObject> extends java.lang.Object
TheParseQuery
class defines a query that is used to fetchParseObject
s. The most common use case is finding all objects that match a query through thefindInBackground()
method, using aFindCallback
. For example, this sample code fetches all objects of class"MyClass"
. It calls a different function depending on whether the fetch succeeded or not.ParseQuery<ParseObject> query = ParseQuery.getQuery("MyClass"); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> objects, ParseException e) { if (e == null) { objectsWereRetrievedSuccessfully(objects); } else { objectRetrievalFailed(); } } }
A
ParseQuery
can also be used to retrieve a single object whose id is known, through thegetInBackground(String)
method, using aGetCallback
. For example, this sample code fetches an object of class"MyClass"
and idmyId
. It calls a different function depending on whether the fetch succeeded or not.ParseQuery<ParseObject> query = ParseQuery.getQuery("MyClass"); query.getInBackground(myId, new GetCallback<ParseObject>() { public void done(ParseObject object, ParseException e) { if (e == null) { objectWasRetrievedSuccessfully(object); } else { objectRetrievalFailed(); } } }
A
ParseQuery
can also be used to count the number of objects that match the query without retrieving all of those objects. For example, this sample code counts the number of objects of the class"MyClass"
.ParseQuery<ParseObject> query = ParseQuery.getQuery("MyClass"); query.countInBackground(new CountCallback() { public void done(int count, ParseException e) { if (e == null) { objectsWereCounted(count); } else { objectCountFailed(); } } }
Using the callback methods is usually preferred because the network operation will not block the calling thread. However, in some cases it may be easier to use the
find()
,get(String)
orcount()
calls, which do block the calling thread. For example, if your application has already spawned a background task to perform work, that background task could use the blocking calls and avoid the code complexity of callbacks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ParseQuery.CachePolicy
CachePolicy
specifies different caching policies that could be used withParseQuery
.static class
ParseQuery.State<T extends ParseObject>
Used by Parse LiveQuery
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_LIMIT
-
Constructor Summary
Constructors Constructor Description ParseQuery(ParseQuery.State.Builder<T> builder)
ParseQuery(ParseQuery<T> query)
Constructs a copy ofquery
;ParseQuery(java.lang.Class<T> subclass)
Constructs a query for aParseObject
subclass type.ParseQuery(java.lang.String theClassName)
Constructs a query.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ParseQuery<T>
addAscendingOrder(java.lang.String key)
Also sorts the results in ascending order by the given key.ParseQuery<T>
addDescendingOrder(java.lang.String key)
Also sorts the results in descending order by the given key.void
cancel()
Cancels the current network request(s) (if any is running).ParseQuery<T>
clear(java.lang.String key)
Clears constraints related to the given key, if any was set previously.static void
clearAllCachedResults()
Clears the cached result for all queries.void
clearCachedResult()
Removes the previously cached result for this query, forcing the next find() to hit the network.int
count()
Counts the number of objects that match this query.<any>
countInBackground()
Counts the number of objects that match this query in a background thread.void
countInBackground(CountCallback callback)
Counts the number of objects that match this query in a background thread.java.util.List<T>
find()
Retrieves a list ofParseObject
s that satisfy this query.<any>
findInBackground()
Retrieves a list ofParseObject
s that satisfy this query from the source in a background thread.void
findInBackground(FindCallback<T> callback)
Retrieves a list ofParseObject
s that satisfy this query from the source in a background thread.ParseQuery<T>
fromLocalDatastore()
Change the source of this query to all pinned objects.ParseQuery<T>
fromNetwork()
Change the source of this query to the server.ParseQuery<T>
fromPin()
Change the source of this query to the default group of pinned objects.ParseQuery<T>
fromPin(java.lang.String name)
Change the source of this query to a specific group of pinned objects.T
get(java.lang.String objectId)
Constructs aParseObject
whose id is already known by fetching data from the source.ParseQuery.State.Builder<T>
getBuilder()
ParseQuery.CachePolicy
getCachePolicy()
java.lang.String
getClassName()
Accessor for the class name.T
getFirst()
Retrieves at most oneParseObject
that satisfies this query.<any>
getFirstInBackground()
Retrieves at most oneParseObject
that satisfies this query from the source in a background thread.void
getFirstInBackground(GetCallback<T> callback)
Retrieves at most oneParseObject
that satisfies this query from the source in a background thread.<any>
getInBackground(java.lang.String objectId)
Constructs aParseObject
whose id is already known by fetching data from the source in a background thread.void
getInBackground(java.lang.String objectId, GetCallback<T> callback)
Constructs aParseObject
whose id is already known by fetching data from the source in a background thread.int
getLimit()
Accessor for the limit.long
getMaxCacheAge()
Gets the maximum age of cached data that will be considered in this query.static <T extends ParseObject>
ParseQuery<T>getQuery(java.lang.Class<T> subclass)
Creates a new query for the givenParseObject
subclass type.static <T extends ParseObject>
ParseQuery<T>getQuery(java.lang.String className)
Creates a new query for the given class name.int
getSkip()
Accessor for the skip value.boolean
hasCachedResult()
Returns whether or not this query has a cached result.ParseQuery<T>
ignoreACLs()
Ignore ACLs when querying from the Local Datastore.ParseQuery<T>
include(java.lang.String key)
Include nestedParseObject
s for the provided key.boolean
isRunning()
static <T extends ParseObject>
ParseQuery<T>or(java.util.List<ParseQuery<T>> queries)
Constructs a query that is theor
of the given queries.ParseQuery<T>
orderByAscending(java.lang.String key)
Sorts the results in ascending order by the given key.ParseQuery<T>
orderByDescending(java.lang.String key)
Sorts the results in descending order by the given key.ParseQuery<T>
selectKeys(java.util.Collection<java.lang.String> keys)
Restrict the fields of returnedParseObject
s to only include the provided keys.ParseQuery<T>
setCachePolicy(ParseQuery.CachePolicy newCachePolicy)
Change the caching policy of this query.ParseQuery<T>
setLimit(int newLimit)
Controls the maximum number of results that are returned.ParseQuery<T>
setMaxCacheAge(long maxAgeInMilliseconds)
Sets the maximum age of cached data that will be considered in this query.ParseQuery<T>
setSkip(int newSkip)
Controls the number of results to skip before returning any results.ParseQuery<T>
setTrace(boolean shouldTrace)
Turn on performance tracing of finds.ParseQuery<T>
whereContainedIn(java.lang.String key, java.util.Collection<?> values)
Add a constraint to the query that requires a particular key's value to be contained in the provided list of values.ParseQuery<T>
whereContains(java.lang.String key, java.lang.String substring)
Add a constraint for finding string values that contain a provided string.ParseQuery<T>
whereContainsAll(java.lang.String key, java.util.Collection<?> values)
Add a constraint to the query that requires a particular key's value to contain every one of the provided list of values.ParseQuery<T>
whereContainsAllStartsWith(java.lang.String key, java.util.Collection<java.lang.String> values)
Add a constraint to the query that requires a particular key's value to contain each one of the provided list of strings entirely or just starting with given strings.ParseQuery<T>
whereDoesNotExist(java.lang.String key)
Add a constraint for finding objects that do not contain a given key.ParseQuery<T>
whereDoesNotMatchKeyInQuery(java.lang.String key, java.lang.String keyInQuery, ParseQuery<?> query)
Add a constraint to the query that requires a particular key's value does not match any value for a key in the results of anotherParseQuery
.ParseQuery<T>
whereDoesNotMatchQuery(java.lang.String key, ParseQuery<?> query)
Add a constraint to the query that requires a particular key's value does not match anotherParseQuery
.ParseQuery<T>
whereEndsWith(java.lang.String key, java.lang.String suffix)
Add a constraint for finding string values that end with a provided string.ParseQuery<T>
whereEqualTo(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be equal to the provided value.ParseQuery<T>
whereExists(java.lang.String key)
Add a constraint for finding objects that contain the given key.ParseQuery<T>
whereFullText(java.lang.String key, java.lang.String text)
Adds a constraint for finding string values that contain a provided string using Full Text SearchParseQuery<T>
whereGreaterThan(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be greater than the provided value.ParseQuery<T>
whereGreaterThanOrEqualTo(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be greater than or equal to the provided value.ParseQuery<T>
whereLessThan(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be less than the provided value.ParseQuery<T>
whereLessThanOrEqualTo(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be less than or equal to the provided value.ParseQuery<T>
whereMatches(java.lang.String key, java.lang.String regex)
Add a regular expression constraint for finding string values that match the provided regular expression.ParseQuery<T>
whereMatches(java.lang.String key, java.lang.String regex, java.lang.String modifiers)
Add a regular expression constraint for finding string values that match the provided regular expression.ParseQuery<T>
whereMatchesKeyInQuery(java.lang.String key, java.lang.String keyInQuery, ParseQuery<?> query)
Add a constraint to the query that requires a particular key's value matches a value for a key in the results of anotherParseQuery
.ParseQuery<T>
whereMatchesQuery(java.lang.String key, ParseQuery<?> query)
Add a constraint to the query that requires a particular key's value match anotherParseQuery
.ParseQuery<T>
whereNear(java.lang.String key, ParseGeoPoint point)
Add a proximity based constraint for finding objects with key point values near the point given.ParseQuery<T>
whereNotContainedIn(java.lang.String key, java.util.Collection<?> values)
Add a constraint to the query that requires a particular key's value not be contained in the provided list of values.ParseQuery<T>
whereNotEqualTo(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be not equal to the provided value.ParseQuery<T>
wherePolygonContains(java.lang.String key, ParseGeoPoint point)
Add a constraint to the query that requires a particular key's coordinates that contains aParseGeoPoint
sParseQuery<T>
whereStartsWith(java.lang.String key, java.lang.String prefix)
Add a constraint for finding string values that start with a provided string.ParseQuery<T>
whereWithinGeoBox(java.lang.String key, ParseGeoPoint southwest, ParseGeoPoint northeast)
Add a constraint to the query that requires a particular key's coordinates be contained within a given rectangular geographic bounding box.ParseQuery<T>
whereWithinKilometers(java.lang.String key, ParseGeoPoint point, double maxDistance)
Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.ParseQuery<T>
whereWithinMiles(java.lang.String key, ParseGeoPoint point, double maxDistance)
Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.ParseQuery<T>
whereWithinPolygon(java.lang.String key, ParsePolygon polygon)
ParseQuery<T>
whereWithinPolygon(java.lang.String key, java.util.List<ParseGeoPoint> points)
Adds a constraint to the query that requires a particular key's coordinates be contained within and on the bounds of a given polygon.ParseQuery<T>
whereWithinRadians(java.lang.String key, ParseGeoPoint point, double maxDistance)
Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.
-
-
-
Field Detail
-
MAX_LIMIT
public static final int MAX_LIMIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ParseQuery
public ParseQuery(java.lang.Class<T> subclass)
Constructs a query for aParseObject
subclass type. A default query with no further parameters will retrieve allParseObject
s of the provided class.- Parameters:
subclass
- TheParseObject
subclass type to retrieve.
-
ParseQuery
public ParseQuery(java.lang.String theClassName)
Constructs a query. A default query with no further parameters will retrieve allParseObject
s of the provided class.- Parameters:
theClassName
- The name of the class to retrieveParseObject
s for.
-
ParseQuery
public ParseQuery(ParseQuery<T> query)
Constructs a copy ofquery
;- Parameters:
query
- The query to copy.
-
ParseQuery
public ParseQuery(ParseQuery.State.Builder<T> builder)
-
-
Method Detail
-
or
public static <T extends ParseObject> ParseQuery<T> or(java.util.List<ParseQuery<T>> queries)
Constructs a query that is theor
of the given queries.- Parameters:
queries
- The list ofParseQuery
s to 'or' together- Returns:
- A
ParseQuery
that is the 'or' of the passed in queries
-
getQuery
public static <T extends ParseObject> ParseQuery<T> getQuery(java.lang.Class<T> subclass)
Creates a new query for the givenParseObject
subclass type. A default query with no further parameters will retrieve allParseObject
s of the provided class.- Parameters:
subclass
- TheParseObject
subclass type to retrieve.- Returns:
- A new
ParseQuery
.
-
getQuery
public static <T extends ParseObject> ParseQuery<T> getQuery(java.lang.String className)
Creates a new query for the given class name. A default query with no further parameters will retrieve allParseObject
s of the provided class name.- Parameters:
className
- The name of the class to retrieveParseObject
s for.- Returns:
- A new
ParseQuery
.
-
clearAllCachedResults
public static void clearAllCachedResults()
Clears the cached result for all queries.
-
getBuilder
public ParseQuery.State.Builder<T> getBuilder()
-
cancel
public void cancel()
Cancels the current network request(s) (if any is running).
-
isRunning
public boolean isRunning()
-
find
public java.util.List<T> find() throws ParseException
Retrieves a list ofParseObject
s that satisfy this query.- Returns:
- A list of all
ParseObject
s obeying the conditions set in this query. - Throws:
ParseException
- Throws aParseException
if no object is found.- See Also:
ParseException.OBJECT_NOT_FOUND
-
getFirst
public T getFirst() throws ParseException
Retrieves at most oneParseObject
that satisfies this query.Note:This mutates the
ParseQuery
.- Returns:
- A
ParseObject
obeying the conditions set in this query. - Throws:
ParseException
- Throws aParseException
if no object is found.- See Also:
ParseException.OBJECT_NOT_FOUND
-
getCachePolicy
public ParseQuery.CachePolicy getCachePolicy()
- Returns:
- the caching policy.
-
setCachePolicy
public ParseQuery<T> setCachePolicy(ParseQuery.CachePolicy newCachePolicy)
Change the caching policy of this query.Unsupported when Local Datastore is enabled.
- Returns:
- this, so you can chain this call.
- See Also:
fromLocalDatastore()
,fromPin()
,fromPin(String)
-
fromNetwork
public ParseQuery<T> fromNetwork()
Change the source of this query to the server.Requires Local Datastore to be enabled.
- Returns:
- this, so you can chain this call.
- See Also:
setCachePolicy(CachePolicy)
-
fromLocalDatastore
public ParseQuery<T> fromLocalDatastore()
Change the source of this query to all pinned objects.Requires Local Datastore to be enabled.
- Returns:
- this, so you can chain this call.
- See Also:
setCachePolicy(CachePolicy)
-
fromPin
public ParseQuery<T> fromPin()
Change the source of this query to the default group of pinned objects.Requires Local Datastore to be enabled.
- Returns:
- this, so you can chain this call.
- See Also:
ParseObject.DEFAULT_PIN
,setCachePolicy(CachePolicy)
-
fromPin
public ParseQuery<T> fromPin(java.lang.String name)
Change the source of this query to a specific group of pinned objects.Requires Local Datastore to be enabled.
- Parameters:
name
- the pinned group- Returns:
- this, so you can chain this call.
- See Also:
setCachePolicy(CachePolicy)
-
ignoreACLs
public ParseQuery<T> ignoreACLs()
Ignore ACLs when querying from the Local Datastore.This is particularly useful when querying for objects with Role based ACLs set on them.
- Returns:
- this, so you can chain this call.
-
getMaxCacheAge
public long getMaxCacheAge()
Gets the maximum age of cached data that will be considered in this query. The returned value is in milliseconds
-
setMaxCacheAge
public ParseQuery<T> setMaxCacheAge(long maxAgeInMilliseconds)
Sets the maximum age of cached data that will be considered in this query.- Returns:
- this, so you can chain this call.
-
findInBackground
public <any> findInBackground()
Retrieves a list ofParseObject
s that satisfy this query from the source in a background thread.This is preferable to using
find()
, unless your code is already running in a background thread.- Returns:
- A
Task
that will be resolved when the find has completed.
-
findInBackground
public void findInBackground(FindCallback<T> callback)
Retrieves a list ofParseObject
s that satisfy this query from the source in a background thread.This is preferable to using
find()
, unless your code is already running in a background thread.- Parameters:
callback
- callback.done(objectList, e) is called when the find completes.
-
getFirstInBackground
public <any> getFirstInBackground()
Retrieves at most oneParseObject
that satisfies this query from the source in a background thread.This is preferable to using
getFirst()
, unless your code is already running in a background thread.Note:This mutates the
ParseQuery
.- Returns:
- A
Task
that will be resolved when the get has completed.
-
getFirstInBackground
public void getFirstInBackground(GetCallback<T> callback)
Retrieves at most oneParseObject
that satisfies this query from the source in a background thread.This is preferable to using
getFirst()
, unless your code is already running in a background thread.Note:This mutates the
ParseQuery
.- Parameters:
callback
- callback.done(object, e) is called when the find completes.
-
count
public int count() throws ParseException
Counts the number of objects that match this query. This does not use caching.- Throws:
ParseException
- Throws an exception when the network connection fails or when the query is invalid.
-
countInBackground
public <any> countInBackground()
Counts the number of objects that match this query in a background thread. This does not use caching.- Returns:
- A
Task
that will be resolved when the count has completed.
-
countInBackground
public void countInBackground(CountCallback callback)
Counts the number of objects that match this query in a background thread. This does not use caching.- Parameters:
callback
- callback.done(count, e) will be called when the count completes.
-
get
public T get(java.lang.String objectId) throws ParseException
Constructs aParseObject
whose id is already known by fetching data from the source.Note:This mutates the
ParseQuery
.- Parameters:
objectId
- Object id of theParseObject
to fetch.- Throws:
ParseException
- Throws an exception when there is no such object or when the network connection fails.- See Also:
ParseException.OBJECT_NOT_FOUND
-
hasCachedResult
public boolean hasCachedResult()
Returns whether or not this query has a cached result.
-
clearCachedResult
public void clearCachedResult()
Removes the previously cached result for this query, forcing the next find() to hit the network. If there is no cached result for this query, then this is a no-op.
-
getInBackground
public <any> getInBackground(java.lang.String objectId)
Constructs aParseObject
whose id is already known by fetching data from the source in a background thread. This does not use caching.This is preferable to using the
ParseObject.createWithoutData(String, String)
, unless your code is already running in a background thread.- Parameters:
objectId
- Object id of theParseObject
to fetch.- Returns:
- A
Task
that is resolved when the fetch completes.
-
getInBackground
public void getInBackground(java.lang.String objectId, GetCallback<T> callback)
Constructs aParseObject
whose id is already known by fetching data from the source in a background thread. This does not use caching.This is preferable to using the
ParseObject.createWithoutData(String, String)
, unless your code is already running in a background thread.- Parameters:
objectId
- Object id of theParseObject
to fetch.callback
- callback.done(object, e) will be called when the fetch completes.
-
whereEqualTo
public ParseQuery<T> whereEqualTo(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be equal to the provided value.- Parameters:
key
- The key to check.value
- The value that theParseObject
must contain.- Returns:
- this, so you can chain this call.
-
whereLessThan
public ParseQuery<T> whereLessThan(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be less than the provided value.- Parameters:
key
- The key to check.value
- The value that provides an upper bound.- Returns:
- this, so you can chain this call.
-
whereNotEqualTo
public ParseQuery<T> whereNotEqualTo(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be not equal to the provided value.- Parameters:
key
- The key to check.value
- The value that must not be equalled.- Returns:
- this, so you can chain this call.
-
whereGreaterThan
public ParseQuery<T> whereGreaterThan(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be greater than the provided value.- Parameters:
key
- The key to check.value
- The value that provides an lower bound.- Returns:
- this, so you can chain this call.
-
whereLessThanOrEqualTo
public ParseQuery<T> whereLessThanOrEqualTo(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be less than or equal to the provided value.- Parameters:
key
- The key to check.value
- The value that provides an upper bound.- Returns:
- this, so you can chain this call.
-
whereGreaterThanOrEqualTo
public ParseQuery<T> whereGreaterThanOrEqualTo(java.lang.String key, java.lang.Object value)
Add a constraint to the query that requires a particular key's value to be greater than or equal to the provided value.- Parameters:
key
- The key to check.value
- The value that provides an lower bound.- Returns:
- this, so you can chain this call.
-
whereContainedIn
public ParseQuery<T> whereContainedIn(java.lang.String key, java.util.Collection<?> values)
Add a constraint to the query that requires a particular key's value to be contained in the provided list of values.- Parameters:
key
- The key to check.values
- The values that will match.- Returns:
- this, so you can chain this call.
-
whereContainsAll
public ParseQuery<T> whereContainsAll(java.lang.String key, java.util.Collection<?> values)
Add a constraint to the query that requires a particular key's value to contain every one of the provided list of values.- Parameters:
key
- The key to check. This key's value must be an array.values
- The values that will match.- Returns:
- this, so you can chain this call.
-
whereFullText
public ParseQuery<T> whereFullText(java.lang.String key, java.lang.String text)
Adds a constraint for finding string values that contain a provided string using Full Text SearchRequires [email protected]
- Parameters:
key
- The key to be constrained.text
- String to be searched- Returns:
- this, so you can chain this call.
-
whereContainsAllStartsWith
public ParseQuery<T> whereContainsAllStartsWith(java.lang.String key, java.util.Collection<java.lang.String> values)
Add a constraint to the query that requires a particular key's value to contain each one of the provided list of strings entirely or just starting with given strings.- Parameters:
key
- The key to check. This key's value must be an array.values
- The values that will match entirely or starting with them.- Returns:
- this, so you can chain this call.
-
whereMatchesQuery
public ParseQuery<T> whereMatchesQuery(java.lang.String key, ParseQuery<?> query)
Add a constraint to the query that requires a particular key's value match anotherParseQuery
.This only works on keys whose values are
ParseObject
s or lists ofParseObject
s.- Parameters:
key
- The key to check.query
- The query that the value should match- Returns:
- this, so you can chain this call.
-
whereDoesNotMatchQuery
public ParseQuery<T> whereDoesNotMatchQuery(java.lang.String key, ParseQuery<?> query)
Add a constraint to the query that requires a particular key's value does not match anotherParseQuery
.This only works on keys whose values are
ParseObject
s or lists ofParseObject
s.- Parameters:
key
- The key to check.query
- The query that the value should not match- Returns:
- this, so you can chain this call.
-
whereMatchesKeyInQuery
public ParseQuery<T> whereMatchesKeyInQuery(java.lang.String key, java.lang.String keyInQuery, ParseQuery<?> query)
Add a constraint to the query that requires a particular key's value matches a value for a key in the results of anotherParseQuery
.- Parameters:
key
- The key whose value is being checkedkeyInQuery
- The key in the objects from the sub query to look inquery
- The sub query to run- Returns:
- this, so you can chain this call.
-
whereDoesNotMatchKeyInQuery
public ParseQuery<T> whereDoesNotMatchKeyInQuery(java.lang.String key, java.lang.String keyInQuery, ParseQuery<?> query)
Add a constraint to the query that requires a particular key's value does not match any value for a key in the results of anotherParseQuery
.- Parameters:
key
- The key whose value is being checked and excludedkeyInQuery
- The key in the objects from the sub query to look inquery
- The sub query to run- Returns:
- this, so you can chain this call.
-
whereNotContainedIn
public ParseQuery<T> whereNotContainedIn(java.lang.String key, java.util.Collection<?> values)
Add a constraint to the query that requires a particular key's value not be contained in the provided list of values.- Parameters:
key
- The key to check.values
- The values that will not match.- Returns:
- this, so you can chain this call.
-
whereNear
public ParseQuery<T> whereNear(java.lang.String key, ParseGeoPoint point)
Add a proximity based constraint for finding objects with key point values near the point given.- Parameters:
key
- The key that theParseGeoPoint
is stored in.point
- The referenceParseGeoPoint
that is used.- Returns:
- this, so you can chain this call.
-
whereWithinMiles
public ParseQuery<T> whereWithinMiles(java.lang.String key, ParseGeoPoint point, double maxDistance)
Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.Radius of earth used is
3958.8
miles.- Parameters:
key
- The key that theParseGeoPoint
is stored in.point
- The referenceParseGeoPoint
that is used.maxDistance
- Maximum distance (in miles) of results to return.- Returns:
- this, so you can chain this call.
-
whereWithinKilometers
public ParseQuery<T> whereWithinKilometers(java.lang.String key, ParseGeoPoint point, double maxDistance)
Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.Radius of earth used is
6371.0
kilometers.- Parameters:
key
- The key that theParseGeoPoint
is stored in.point
- The referenceParseGeoPoint
that is used.maxDistance
- Maximum distance (in kilometers) of results to return.- Returns:
- this, so you can chain this call.
-
whereWithinRadians
public ParseQuery<T> whereWithinRadians(java.lang.String key, ParseGeoPoint point, double maxDistance)
Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.- Parameters:
key
- The key that theParseGeoPoint
is stored in.point
- The referenceParseGeoPoint
that is used.maxDistance
- Maximum distance (in radians) of results to return.- Returns:
- this, so you can chain this call.
-
whereWithinGeoBox
public ParseQuery<T> whereWithinGeoBox(java.lang.String key, ParseGeoPoint southwest, ParseGeoPoint northeast)
Add a constraint to the query that requires a particular key's coordinates be contained within a given rectangular geographic bounding box.- Parameters:
key
- The key to be constrained.southwest
- The lower-left inclusive corner of the box.northeast
- The upper-right inclusive corner of the box.- Returns:
- this, so you can chain this call.
-
whereWithinPolygon
public ParseQuery<T> whereWithinPolygon(java.lang.String key, java.util.List<ParseGeoPoint> points)
Adds a constraint to the query that requires a particular key's coordinates be contained within and on the bounds of a given polygon. Supports closed and open (last point is connected to first) pathsPolygon must have at least 3 points
- Parameters:
key
- The key to be constrained.points
- Listor ParsePolygon - Returns:
- this, so you can chain this call.
-
whereWithinPolygon
public ParseQuery<T> whereWithinPolygon(java.lang.String key, ParsePolygon polygon)
-
wherePolygonContains
public ParseQuery<T> wherePolygonContains(java.lang.String key, ParseGeoPoint point)
Add a constraint to the query that requires a particular key's coordinates that contains aParseGeoPoint
s(Requires [email protected])
- Parameters:
key
- The key to be constrained.point
- ParseGeoPoint- Returns:
- this, so you can chain this call.
-
whereMatches
public ParseQuery<T> whereMatches(java.lang.String key, java.lang.String regex)
Add a regular expression constraint for finding string values that match the provided regular expression.This may be slow for large datasets.
- Parameters:
key
- The key that the string to match is stored in.regex
- The regular expression pattern to match.- Returns:
- this, so you can chain this call.
-
whereMatches
public ParseQuery<T> whereMatches(java.lang.String key, java.lang.String regex, java.lang.String modifiers)
Add a regular expression constraint for finding string values that match the provided regular expression.This may be slow for large datasets.
- Parameters:
key
- The key that the string to match is stored in.regex
- The regular expression pattern to match.modifiers
- Any of the following supported PCRE modifiers:
i
- Case insensitive search
m
- Search across multiple lines of input- Returns:
- this, so you can chain this call.
-
whereContains
public ParseQuery<T> whereContains(java.lang.String key, java.lang.String substring)
Add a constraint for finding string values that contain a provided string.This will be slow for large datasets.
- Parameters:
key
- The key that the string to match is stored in.substring
- The substring that the value must contain.- Returns:
- this, so you can chain this call.
-
whereStartsWith
public ParseQuery<T> whereStartsWith(java.lang.String key, java.lang.String prefix)
Add a constraint for finding string values that start with a provided string.This query will use the backend index, so it will be fast even for large datasets.
- Parameters:
key
- The key that the string to match is stored in.prefix
- The substring that the value must start with.- Returns:
- this, so you can chain this call.
-
whereEndsWith
public ParseQuery<T> whereEndsWith(java.lang.String key, java.lang.String suffix)
Add a constraint for finding string values that end with a provided string.This will be slow for large datasets.
- Parameters:
key
- The key that the string to match is stored in.suffix
- The substring that the value must end with.- Returns:
- this, so you can chain this call.
-
include
public ParseQuery<T> include(java.lang.String key)
Include nestedParseObject
s for the provided key.You can use dot notation to specify which fields in the included object that are also fetched.
- Parameters:
key
- The key that should be included.- Returns:
- this, so you can chain this call.
-
selectKeys
public ParseQuery<T> selectKeys(java.util.Collection<java.lang.String> keys)
Restrict the fields of returnedParseObject
s to only include the provided keys.If this is called multiple times, then all of the keys specified in each of the calls will be included.
Note: This option will be ignored when querying from the local datastore. This is done since all the keys will be in memory anyway and there will be no performance gain from removing them.
- Parameters:
keys
- The set of keys to include in the result.- Returns:
- this, so you can chain this call.
-
whereExists
public ParseQuery<T> whereExists(java.lang.String key)
Add a constraint for finding objects that contain the given key.- Parameters:
key
- The key that should exist.- Returns:
- this, so you can chain this call.
-
whereDoesNotExist
public ParseQuery<T> whereDoesNotExist(java.lang.String key)
Add a constraint for finding objects that do not contain a given key.- Parameters:
key
- The key that should not exist- Returns:
- this, so you can chain this call.
-
orderByAscending
public ParseQuery<T> orderByAscending(java.lang.String key)
Sorts the results in ascending order by the given key.- Parameters:
key
- The key to order by.- Returns:
- this, so you can chain this call.
-
addAscendingOrder
public ParseQuery<T> addAscendingOrder(java.lang.String key)
Also sorts the results in ascending order by the given key.The previous sort keys have precedence over this key.
- Parameters:
key
- The key to order by- Returns:
- this, so you can chain this call.
-
orderByDescending
public ParseQuery<T> orderByDescending(java.lang.String key)
Sorts the results in descending order by the given key.- Parameters:
key
- The key to order by.- Returns:
- this, so you can chain this call.
-
addDescendingOrder
public ParseQuery<T> addDescendingOrder(java.lang.String key)
Also sorts the results in descending order by the given key.The previous sort keys have precedence over this key.
- Parameters:
key
- The key to order by- Returns:
- this, so you can chain this call.
-
getLimit
public int getLimit()
Accessor for the limit.
-
setLimit
public ParseQuery<T> setLimit(int newLimit)
Controls the maximum number of results that are returned.The default limit is
100
, there is no maximum limit.- Parameters:
newLimit
- The new limit.- Returns:
- this, so you can chain this call.
-
getSkip
public int getSkip()
Accessor for the skip value.
-
setSkip
public ParseQuery<T> setSkip(int newSkip)
Controls the number of results to skip before returning any results.This is useful for pagination. Default is to skip zero results.
- Parameters:
newSkip
- The new skip- Returns:
- this, so you can chain this call.
-
getClassName
public java.lang.String getClassName()
Accessor for the class name.
-
clear
public ParseQuery<T> clear(java.lang.String key)
Clears constraints related to the given key, if any was set previously. Order, includes and selected keys are not affected by this operation.- Parameters:
key
- key to be cleared from current constraints.- Returns:
- this, so you can chain this call.
-
setTrace
public ParseQuery<T> setTrace(boolean shouldTrace)
Turn on performance tracing of finds.If performance tracing is already turned on this does nothing. In general you don't need to call trace.
- Returns:
- this, so you can chain this call.
-
-