Package cn.leancloud
Class LCQuery<T extends LCObject>
java.lang.Object
cn.leancloud.LCQuery<T>
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
LCStatusQuery
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAscendingOrder(String key) Also sorts the results in ascending order by the given key.addDescendingOrder(String key) Also sorts the results in descending order by the given key.addWhereItem(String key, String op, Object value) Constructs a query that is the and of the given queries.Assemble query parameters.static voidClears the cached result for all queries.voidRemoves the previously cached result for this query, forcing the next find() to hit the network.clone()Clone a new query object, which fully same to this.intcount()Get result count in blocking mode.intGet result count in blocking mode.io.reactivex.Observable<Integer> Get result count in async mode.io.reactivex.Observable<Integer> countInBackground(LCUser asAuthenticatedUser) Get result count in async mode.voidDelete all query result in blocking mode.voidDelete all query result in blocking mode.io.reactivex.Observable<LCNull> Delete all query result in async mode.io.reactivex.Observable<LCNull> deleteAllInBackground(LCUser asAuthenticatedUser) Delete all query result in async mode.find()Execute query in blocking mode.Execute query in async mode.findInBackground(LCUser asAuthenticatedUser) Execute query in async mode.findInBackground(LCUser asAuthenticatedUser, int explicitLimit) Get Object with specified objectId in blocking mode.Accessor for the caching policy.Get class namegetFirst()Get first result in blocking mode.Get first result in blocking mode.io.reactivex.Observable<T> Get first result in async mode.io.reactivex.Observable<T> getFirstInBackground(LCUser asAuthenticatedUser) Get first result in async mode.io.reactivex.Observable<T> getInBackground(LCUser asAuthenticatedUser, String objectId) Get Object with specified objectId in async mode.io.reactivex.Observable<T> getInBackground(String objectId) Get Object with specified objectId in async mode.intgetLimit()Accessor for the limit.longGets the maximum age of cached data that will be considered in this query.getOrder()Get order string.Get cache policy.Create a AVQuery with special sub-class.Constructs a query.intgetSkip()Accessor for the skip value.booleanHas cached result or not.Include nested AVObjects for the provided key.includeACL(boolean includeACL) set include ACL or not.booleanFlag to indicate need ACL returned in result.limit(int limit) Constructs a query that is the or of the given queries.orderByAscending(String key) Sorts the results in ascending order by the given key.orderByDescending(String key) Sorts the results in descending order by the given key.selectKeys(Collection<String> keys) Restrict the fields of returned AVObjects to only include the provided keys.setCachePolicy(LCQuery.CachePolicy cachePolicy) Change the caching policy of this query.setClassName(String className) Set class namesetLimit(int limit) Controls the maximum number of results that are returned.setMaxCacheAge(long maxCacheAge) Sets the maximum age of cached data that will be considered in this query.Set query order fields.setPolicy(LCQuery.CachePolicy policy) Change the caching policy of this query.setSkip(int skip) Controls the number of results to skip before returning any results.skip(int skip) whereContainedIn(String key, Collection<? extends Object> values) Add a constraint to the query that requires a particular key's value to be contained in the provided list of values.whereContains(String key, String substring) Add a constraint for finding string values that contain a provided string.whereContainsAll(String key, Collection<?> values) Add a constraint to the query that requires a particular key's value match another AVQuery.whereDoesNotExist(String key) Add a constraint for finding objects that do not contain a given key.whereDoesNotMatchKeyInQuery(String key, String keyInQuery, LCQuery<?> 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 another AVQuery.whereDoesNotMatchQuery(String key, LCQuery<?> query) Add a constraint to the query that requires a particular key's value does not match another AVQuery.whereEndsWith(String key, String suffix) Add a constraint for finding string values that end with a provided string.whereEqualTo(String key, Object value) Add a constraint to the query that requires a particular key's value to be equal to the provided value.whereExists(String key) Add a constraint for finding objects that contain the given key.whereGreaterThan(String key, Object value) Add a constraint to the query that requires a particular key's value to be greater than the provided value.whereGreaterThanOrEqualTo(String key, Object value) Add a constraint to the query that requires a particular key's value to be greater or equal to than the provided value.whereLessThan(String key, Object value) Add a constraint to the query that requires a particular key's value to be less than the provided value.whereLessThanOrEqualTo(String key, Object value) Add a constraint to the query that requires a particular key's value to be less or equal to than the provided value.whereMatches(String key, String regex) Add a regular expression constraint for finding string values that match the provided regular expression.whereMatches(String key, String regex, String modifiers) Add a regular expression constraint for finding string values that match the provided regular expression.whereMatchesKeyInQuery(String key, String keyInQuery, LCQuery<?> query) Add a constraint to the query that requires a particular key's value matches a value for a key in the results of another AVQuerywhereMatchesQuery(String key, LCQuery<?> query) Add a constraint to the query that requires a particular key's value match another AVQuery.whereNear(String key, LCGeoPoint point) Add a proximity based constraint for finding objects with key point values near the point given.whereNotContainedIn(String key, Collection<? extends Object> values) Add a constraint to the query that requires a particular key's value not be contained in the provided list of values.whereNotEqualTo(String key, Object value) Add a constraint to the query that requires a particular key's value to be not equal to the provided value.whereSizeEqual(String key, int size) 添加查询约束条件,查找key类型是数组,该数组的长度匹配提供的数值。whereStartsWith(String key, String prefix) Add a constraint for finding string values that start with a provided string.whereWithinGeoBox(String key, LCGeoPoint southwest, LCGeoPoint northeast) Add a constraint to the query that requires a particular key's coordinates be contained within a given rectangular geographic bounding box.whereWithinKilometers(String key, LCGeoPoint 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.whereWithinKilometers(String key, LCGeoPoint point, double maxDistance, double minDistance) Add a proximity based constraint for finding objects with key point values near the point given and within the given ring area Radius of earth used is 6371.0 kilometers.whereWithinMiles(String key, LCGeoPoint 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.whereWithinMiles(String key, LCGeoPoint point, double maxDistance, double minDistance) Add a proximity based constraint for finding objects with key point values near the point given and within the given ring.whereWithinRadians(String key, LCGeoPoint 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.whereWithinRadians(String key, LCGeoPoint point, double maxDistance, double minDistance) Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.
-
Constructor Details
-
LCQuery
Constructs a query. A default query with no further parameters will retrieve all AVObjects of the provided class.- Parameters:
theClassName- The name of the class to retrieve AVObjects for.
-
-
Method Details
-
clone
Clone a new query object, which fully same to this.- Overrides:
clonein classObject- Returns:
- a new AVQuery object.
- Throws:
CloneNotSupportedException
-
getQuery
Constructs a query. A default query with no further parameters will retrieve all AVObjects of the provided class.- Type Parameters:
T- template type.- Parameters:
theClassName- The name of the class to retrieve AVObjects for.- Returns:
- the query object.
-
getQuery
Create a AVQuery with special sub-class.- Type Parameters:
T- template type.- Parameters:
clazz- The AVObject subclass- Returns:
- The AVQuery
-
getClassName
Get class name- Returns:
- class name.
-
setClassName
Set class name- Parameters:
className- class name.- Returns:
- current instance.
-
getCachePolicy
Accessor for the caching policy.- Returns:
- cache policy
-
setCachePolicy
Change the caching policy of this query.- Parameters:
cachePolicy- cache policy.- Returns:
- this query.
-
getPolicy
Get cache policy.- Returns:
- cache policy.
-
setPolicy
Change the caching policy of this query.- Parameters:
policy- cache policy.- Returns:
- this query.
-
getMaxCacheAge
public long getMaxCacheAge()Gets the maximum age of cached data that will be considered in this query. The returned value is in milliseconds- Returns:
- max cache age(milliseconds).
-
setMaxCacheAge
Sets the maximum age of cached data that will be considered in this query.- Parameters:
maxCacheAge- mac cached age.- Returns:
- this query.
-
clearAllCachedResults
public static void clearAllCachedResults()Clears the cached result for all queries. -
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. -
getLimit
public int getLimit()Accessor for the limit.- Returns:
- query limit.
-
setLimit
Controls the maximum number of results that are returned. Setting a negative limit denotes retrieval without a limit. The default limit is 100, with a maximum of 1000 results being returned at a time.- Parameters:
limit- query limit.- Returns:
- this query.
-
limit
- Parameters:
limit- query limit- Returns:
- this query.
- See Also:
-
skip
- Parameters:
skip- qury skip- Returns:
- this query.
- See Also:
-
getSkip
public int getSkip()Accessor for the skip value.- Returns:
- current skip value.
-
setSkip
Controls the number of results to skip before returning any results. This is useful for pagination. Default is to skip zero results.- Parameters:
skip- query skip.- Returns:
- this query
-
getOrder
Get order string.- Returns:
- order string.
-
setOrder
Set query order fields.- Parameters:
order- order string.- Returns:
- this query.
-
order
- Parameters:
order- order string.- Returns:
- this query.
- See Also:
-
addAscendingOrder
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:
- Returns the query so you can chain this call.
-
addDescendingOrder
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:
- Returns the query so you can chain this call.
-
isIncludeACL
public boolean isIncludeACL()Flag to indicate need ACL returned in result.- Returns:
- include flag.
-
includeACL
set include ACL or not.- Parameters:
includeACL- Flag to indicate need ACL returned in result.- Returns:
- this query.
-
include
Include nested AVObjects 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 query.
-
selectKeys
Restrict the fields of returned AVObjects 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.- Parameters:
keys- The set of keys to include in the result.- Returns:
- this query.
-
orderByAscending
Sorts the results in ascending order by the given key.- Parameters:
key- The key to order by.- Returns:
- Returns the query, so you can chain this call.
-
orderByDescending
Sorts the results in descending order by the given key.- Parameters:
key- The key to order by.- Returns:
- Returns the query, so you can chain this call.
-
whereContainedIn
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:
- Returns the query, so you can chain this call.
-
whereContains
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:
- Returns the query, so you can chain this call.
-
whereSizeEqual
添加查询约束条件,查找key类型是数组,该数组的长度匹配提供的数值。- Parameters:
key- 查询的keysize- 数组的长度- Returns:
- this query.
- Since:
- 2.0.2
-
whereContainsAll
Add a constraint to the query that requires a particular key's value match another AVQuery. This only works on keys whose values are AVObjects or lists of AVObjects. 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:
- Returns the query, so you can chain this call.
-
whereDoesNotExist
Add a constraint for finding objects that do not contain a given key.- Parameters:
key- The key that should not exist- Returns:
- this query.
-
whereEndsWith
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:
- Returns the query, so you can chain this call.
-
whereEqualTo
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 the AVObject must contain.- Returns:
- Returns the query, so you can chain this call.
-
addWhereItem
-
whereExists
Add a constraint for finding objects that contain the given key.- Parameters:
key- The key that should exist.- Returns:
- this query.
-
whereGreaterThan
Add a constraint to the query that requires a particular key's value to be greater than the provided value. w- Parameters:
key- The key to check.value- The value that provides an lower bound.- Returns:
- Returns the query, so you can chain this call.
-
whereGreaterThanOrEqualTo
Add a constraint to the query that requires a particular key's value to be greater or equal to than the provided value.- Parameters:
key- The key to check.value- The value that provides an lower bound.- Returns:
- Returns the query, so you can chain this call.
-
whereLessThan
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:
- Returns the query, so you can chain this call.
-
whereLessThanOrEqualTo
Add a constraint to the query that requires a particular key's value to be less or equal to than the provided value.- Parameters:
key- The key to check.value- The value that provides an lower bound.- Returns:
- Returns the query, so you can chain this call.
-
whereMatches
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:
- Returns the query, so you can chain this call.
-
whereMatches
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 query.
-
whereNear
Add a proximity based constraint for finding objects with key point values near the point given.- Parameters:
key- The key that the AVGeoPoint is stored in.point- The reference AVGeoPoint that is used.- Returns:
- Returns the query, so you can chain this call.
-
whereNotContainedIn
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:
- Returns the query, so you can chain this call.
-
whereNotEqualTo
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:
- Returns the query, so you can chain this call.
-
whereStartsWith
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:
- Returns the query, so you can chain this call.
-
whereWithinGeoBox
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:
- Returns the query, so you can chain this call.
-
whereWithinKilometers
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 the AVGeoPoint is stored in.point- The reference AVGeoPoint that is used.maxDistance- Maximum distance (in kilometers) of results to return.- Returns:
- Returns the query, so you can chain this call.
-
whereWithinKilometers
public LCQuery<T> whereWithinKilometers(String key, LCGeoPoint point, double maxDistance, double minDistance) Add a proximity based constraint for finding objects with key point values near the point given and within the given ring area Radius of earth used is 6371.0 kilometers.- Parameters:
key- The key that the AVGeoPoint is stored in.point- The reference AVGeoPoint that is used.maxDistance- outer radius of the given ring in kilometersminDistance- inner radius of the given ring in kilometers- Returns:
- Returns the query, so you can chain this call.
-
whereWithinMiles
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 the AVGeoPoint is stored in.point- The reference AVGeoPoint that is used.maxDistance- outer radius of the given ring in miles.- Returns:
- Returns the query, so you can chain this call.
-
whereWithinMiles
public LCQuery<T> whereWithinMiles(String key, LCGeoPoint point, double maxDistance, double minDistance) Add a proximity based constraint for finding objects with key point values near the point given and within the given ring. Radius of earth used is 3958.8 miles.- Parameters:
key- The key that the AVGeoPoint is stored in.point- The reference AVGeoPoint that is used.maxDistance- outer radius of the given ring in miles.minDistance- inner radius of the given ring in miles.- Returns:
- Returns the query, so you can chain this call.
-
whereWithinRadians
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 the AVGeoPoint is stored in.point- The reference AVGeoPoint that is used.maxDistance- Maximum distance (in radians) of results to return.- Returns:
- Returns the query, so you can chain this call.
-
whereWithinRadians
public LCQuery<T> whereWithinRadians(String key, LCGeoPoint point, double maxDistance, double minDistance) 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 the AVGeoPoint is stored in.point- The reference AVGeoPoint that is used.maxDistance- outer radius of the given radians.minDistance- inner radius of the given radians.- Returns:
- Returns the query, so you can chain this call.
-
whereMatchesKeyInQuery
Add a constraint to the query that requires a particular key's value matches a value for a key in the results of another AVQuery- 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:
- Returns the query so you can chain this call.
-
whereMatchesQuery
Add a constraint to the query that requires a particular key's value match another AVQuery. This only works on keys whose values are AVObjects or lists of AVObjects.- Parameters:
key- The key to check.query- The query that the value should match- Returns:
- Returns the query so you can chain this call.
-
whereDoesNotMatchKeyInQuery
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 another AVQuery.- 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:
- Returns the query so you can chain this call.
-
whereDoesNotMatchQuery
Add a constraint to the query that requires a particular key's value does not match another AVQuery. This only works on keys whose values are AVObjects or lists of AVObjects.- Parameters:
key- The key to check.query- The query that the value should not match- Returns:
- Returns the query so you can chain this call.
-
or
Constructs a query that is the or of the given queries.- Type Parameters:
T- template type.- Parameters:
queries- The list of AVQueries to 'or' together- Returns:
- A AVQuery that is the 'or' of the passed in queries
-
and
Constructs a query that is the and of the given queries.- Type Parameters:
T- template type.- Parameters:
queries- The list of AVQueries to 'and' together- Returns:
- A AVQuery that is the 'and' of the passed in queries
-
hasCachedResult
public boolean hasCachedResult()Has cached result or not.- Returns:
- cache result existed or not.
-
find
Execute query in blocking mode.- Returns:
- result of list.
-
findInBackground
Execute query in async mode.- Returns:
- observable instance.
-
findInBackground
Execute query in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
findInBackground
-
get
Get Object with specified objectId in blocking mode.- Parameters:
objectId- object id.- Returns:
- object instance.
-
getInBackground
Get Object with specified objectId in async mode.- Parameters:
objectId- object id.- Returns:
- observable instance.
-
getInBackground
Get Object with specified objectId in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.objectId- object id.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
getFirst
Get first result in blocking mode.- Returns:
- first result.
-
getFirst
Get first result in blocking mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Returns:
- first result. in general, this method should be invoked in lean engine.
-
getFirstInBackground
Get first result in async mode.- Returns:
- observable instance.
-
getFirstInBackground
Get first result in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
count
public int count()Get result count in blocking mode.- Returns:
- result count.
-
count
Get result count in blocking mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Returns:
- result count. in general, this method should be invoked in lean engine.
-
countInBackground
Get result count in async mode.- Returns:
- observable instance.
-
countInBackground
Get result count in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
deleteAll
public void deleteAll()Delete all query result in blocking mode. -
deleteAll
Delete all query result in blocking mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication. in general, this method should be invoked in lean engine.
-
deleteAllInBackground
Delete all query result in async mode.- Returns:
- observable instance.
-
deleteAllInBackground
Delete all query result in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
assembleParameters
Assemble query parameters.- Returns:
- map of query parameters.
-
assembleJsonParam
-