public class LCQuery<T extends LCObject> extends Object implements Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
LCQuery.CachePolicy |
Constructor and Description |
---|
LCQuery(String theClassName)
Constructs a query.
|
Modifier and Type | Method and Description |
---|---|
LCQuery<T> |
addAscendingOrder(String key)
Also sorts the results in ascending order by the given key.
|
LCQuery<T> |
addDescendingOrder(String key)
Also sorts the results in descending order by the given key.
|
protected LCQuery<T> |
addWhereItem(String key,
String op,
Object value) |
static <T extends LCObject> |
and(List<LCQuery<T>> queries)
Constructs a query that is the and of the given queries.
|
protected Map<String,Object> |
assembleJsonParam() |
Map<String,String> |
assembleParameters()
Assemble query parameters.
|
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.
|
LCQuery |
clone()
Clone a new query object, which fully same to this.
|
int |
count()
Get result count in blocking mode.
|
int |
count(LCUser asAuthenticatedUser)
Get result count in blocking mode.
|
io.reactivex.Observable<Integer> |
countInBackground()
Get result count in async mode.
|
io.reactivex.Observable<Integer> |
countInBackground(LCUser asAuthenticatedUser)
Get result count in async mode.
|
void |
deleteAll()
Delete all query result in blocking mode.
|
void |
deleteAll(LCUser asAuthenticatedUser)
Delete all query result in blocking mode.
|
io.reactivex.Observable<LCNull> |
deleteAllInBackground()
Delete all query result in async mode.
|
io.reactivex.Observable<LCNull> |
deleteAllInBackground(LCUser asAuthenticatedUser)
Delete all query result in async mode.
|
List<T> |
find()
Execute query in blocking mode.
|
io.reactivex.Observable<List<T>> |
findInBackground()
Execute query in async mode.
|
io.reactivex.Observable<List<T>> |
findInBackground(LCUser asAuthenticatedUser)
Execute query in async mode.
|
protected io.reactivex.Observable<List<T>> |
findInBackground(LCUser asAuthenticatedUser,
int explicitLimit) |
T |
get(String objectId)
Get Object with specified objectId in blocking mode.
|
LCQuery.CachePolicy |
getCachePolicy()
Accessor for the caching policy.
|
String |
getClassName()
Get class name
|
T |
getFirst()
Get first result in blocking mode.
|
T |
getFirst(LCUser asAuthenticatedUser)
Get first result in blocking mode.
|
io.reactivex.Observable<T> |
getFirstInBackground()
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.
|
int |
getLimit()
Accessor for the limit.
|
long |
getMaxCacheAge()
Gets the maximum age of cached data that will be considered in this query.
|
String |
getOrder()
Get order string.
|
LCQuery.CachePolicy |
getPolicy()
Get cache policy.
|
static <T extends LCObject> |
getQuery(Class<T> clazz)
Create a AVQuery with special sub-class.
|
static <T extends LCObject> |
getQuery(String theClassName)
Constructs a query.
|
int |
getSkip()
Accessor for the skip value.
|
boolean |
hasCachedResult()
Has cached result or not.
|
LCQuery<T> |
include(String key)
Include nested AVObjects for the provided key.
|
LCQuery<T> |
includeACL(boolean includeACL)
set include ACL or not.
|
boolean |
isIncludeACL()
Flag to indicate need ACL returned in result.
|
LCQuery<T> |
limit(int limit) |
static <T extends LCObject> |
or(List<LCQuery<T>> queries)
Constructs a query that is the or of the given queries.
|
LCQuery<T> |
order(String order) |
LCQuery<T> |
orderByAscending(String key)
Sorts the results in ascending order by the given key.
|
LCQuery<T> |
orderByDescending(String key)
Sorts the results in descending order by the given key.
|
LCQuery<T> |
selectKeys(Collection<String> keys)
Restrict the fields of returned AVObjects to only include the provided keys.
|
LCQuery<T> |
setCachePolicy(LCQuery.CachePolicy cachePolicy)
Change the caching policy of this query.
|
LCQuery<T> |
setClassName(String className)
Set class name
|
LCQuery<T> |
setLimit(int limit)
Controls the maximum number of results that are returned.
|
LCQuery<T> |
setMaxCacheAge(long maxCacheAge)
Sets the maximum age of cached data that will be considered in this query.
|
LCQuery<T> |
setOrder(String order)
Set query order fields.
|
LCQuery<T> |
setPolicy(LCQuery.CachePolicy policy)
Change the caching policy of this query.
|
LCQuery<T> |
setSkip(int skip)
Controls the number of results to skip before returning any results.
|
LCQuery<T> |
skip(int skip) |
LCQuery<T> |
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.
|
LCQuery<T> |
whereContains(String key,
String substring)
Add a constraint for finding string values that contain a provided string.
|
LCQuery<T> |
whereContainsAll(String key,
Collection<?> values)
Add a constraint to the query that requires a particular key's value match another AVQuery.
|
LCQuery<T> |
whereDoesNotExist(String key)
Add a constraint for finding objects that do not contain a given key.
|
LCQuery<T> |
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.
|
LCQuery<T> |
whereDoesNotMatchQuery(String key,
LCQuery<?> query)
Add a constraint to the query that requires a particular key's value does not match another
AVQuery.
|
LCQuery<T> |
whereEndsWith(String key,
String suffix)
Add a constraint for finding string values that end with a provided string.
|
LCQuery<T> |
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.
|
LCQuery<T> |
whereExists(String key)
Add a constraint for finding objects that contain the given key.
|
LCQuery<T> |
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.
|
LCQuery<T> |
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.
|
LCQuery<T> |
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.
|
LCQuery<T> |
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.
|
LCQuery<T> |
whereMatches(String key,
String regex)
Add a regular expression constraint for finding string values that match the provided regular
expression.
|
LCQuery<T> |
whereMatches(String key,
String regex,
String modifiers)
Add a regular expression constraint for finding string values that match the provided regular
expression.
|
LCQuery<T> |
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 AVQuery
|
LCQuery<T> |
whereMatchesQuery(String key,
LCQuery<?> query)
Add a constraint to the query that requires a particular key's value match another AVQuery.
|
LCQuery<T> |
whereNear(String key,
LCGeoPoint point)
Add a proximity based constraint for finding objects with key point values near the point
given.
|
LCQuery<T> |
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.
|
LCQuery<T> |
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.
|
LCQuery<T> |
whereSizeEqual(String key,
int size)
添加查询约束条件,查找key类型是数组,该数组的长度匹配提供的数值。
|
LCQuery<T> |
whereStartsWith(String key,
String prefix)
Add a constraint for finding string values that start with a provided string.
|
LCQuery<T> |
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.
|
LCQuery<T> |
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.
|
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.
|
LCQuery<T> |
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.
|
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.
|
LCQuery<T> |
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.
|
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.
|
public LCQuery(String theClassName)
theClassName
- The name of the class to retrieve AVObjects for.public LCQuery clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public static <T extends LCObject> LCQuery<T> getQuery(String theClassName)
T
- template type.theClassName
- The name of the class to retrieve AVObjects for.public static <T extends LCObject> LCQuery<T> getQuery(Class<T> clazz)
T
- template type.clazz
- The AVObject subclasspublic String getClassName()
public LCQuery<T> setClassName(String className)
className
- class name.public LCQuery.CachePolicy getCachePolicy()
public LCQuery<T> setCachePolicy(LCQuery.CachePolicy cachePolicy)
cachePolicy
- cache policy.public LCQuery.CachePolicy getPolicy()
public LCQuery<T> setPolicy(LCQuery.CachePolicy policy)
policy
- cache policy.public long getMaxCacheAge()
public LCQuery<T> setMaxCacheAge(long maxCacheAge)
maxCacheAge
- mac cached age.public static void clearAllCachedResults()
public void clearCachedResult()
public int getLimit()
public LCQuery<T> setLimit(int limit)
limit
- query limit.public LCQuery<T> limit(int limit)
limit
- query limitsetLimit(int)
public LCQuery<T> skip(int skip)
skip
- qury skipsetSkip(int)
public int getSkip()
public LCQuery<T> setSkip(int skip)
skip
- query skip.public String getOrder()
public LCQuery<T> setOrder(String order)
order
- order string.public LCQuery<T> order(String order)
order
- order string.setOrder(String)
public LCQuery<T> addAscendingOrder(String key)
key
- The key to order bypublic LCQuery<T> addDescendingOrder(String key)
key
- The key to order bypublic boolean isIncludeACL()
public LCQuery<T> includeACL(boolean includeACL)
includeACL
- Flag to indicate need ACL returned in result.public LCQuery<T> include(String key)
key
- The key that should be included.public LCQuery<T> selectKeys(Collection<String> keys)
keys
- The set of keys to include in the result.public LCQuery<T> orderByAscending(String key)
key
- The key to order by.public LCQuery<T> orderByDescending(String key)
key
- The key to order by.public LCQuery<T> whereContainedIn(String key, Collection<? extends Object> values)
key
- The key to check.values
- The values that will match.public LCQuery<T> whereContains(String key, String substring)
key
- The key that the string to match is stored in.substring
- The substring that the value must contain.public LCQuery<T> whereSizeEqual(String key, int size)
key
- 查询的keysize
- 数组的长度public LCQuery<T> whereContainsAll(String key, Collection<?> values)
key
- The key to check. This key's value must be an array.values
- The values that will match.public LCQuery<T> whereDoesNotExist(String key)
key
- The key that should not existpublic LCQuery<T> whereEndsWith(String key, String suffix)
key
- The key that the string to match is stored in.suffix
- The substring that the value must end with.public LCQuery<T> whereEqualTo(String key, Object value)
key
- The key to check.value
- The value that the AVObject must contain.public LCQuery<T> whereExists(String key)
key
- The key that should exist.public LCQuery<T> whereGreaterThan(String key, Object value)
key
- The key to check.value
- The value that provides an lower bound.public LCQuery<T> whereGreaterThanOrEqualTo(String key, Object value)
key
- The key to check.value
- The value that provides an lower bound.public LCQuery<T> whereLessThan(String key, Object value)
key
- The key to check.value
- The value that provides an upper bound.public LCQuery<T> whereLessThanOrEqualTo(String key, Object value)
key
- The key to check.value
- The value that provides an lower bound.public LCQuery<T> whereMatches(String key, String regex)
key
- The key that the string to match is stored in.regex
- The regular expression pattern to match.public LCQuery<T> whereMatches(String key, String regex, String modifiers)
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 inputpublic LCQuery<T> whereNear(String key, LCGeoPoint point)
key
- The key that the AVGeoPoint is stored in.point
- The reference AVGeoPoint that is used.public LCQuery<T> whereNotContainedIn(String key, Collection<? extends Object> values)
key
- The key to check.values
- The values that will not match.public LCQuery<T> whereNotEqualTo(String key, Object value)
key
- The key to check.value
- The value that must not be equalled.public LCQuery<T> whereStartsWith(String key, String prefix)
key
- The key that the string to match is stored in.prefix
- The substring that the value must start with.public LCQuery<T> whereWithinGeoBox(String key, LCGeoPoint southwest, LCGeoPoint northeast)
key
- The key to be constrained.southwest
- The lower-left inclusive corner of the box.northeast
- The upper-right inclusive corner of the box.public LCQuery<T> whereWithinKilometers(String key, LCGeoPoint point, double maxDistance)
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.public LCQuery<T> whereWithinKilometers(String key, LCGeoPoint point, double maxDistance, double minDistance)
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 kilometerspublic LCQuery<T> whereWithinMiles(String key, LCGeoPoint point, double maxDistance)
key
- The key that the AVGeoPoint is stored in.maxDistance
- outer radius of the given ring in miles.point
- The reference AVGeoPoint that is used.public LCQuery<T> whereWithinMiles(String key, LCGeoPoint point, double maxDistance, double minDistance)
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.public LCQuery<T> whereWithinRadians(String key, LCGeoPoint point, double maxDistance)
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.public LCQuery<T> whereWithinRadians(String key, LCGeoPoint point, double maxDistance, double minDistance)
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.public LCQuery<T> whereMatchesKeyInQuery(String key, String keyInQuery, LCQuery<?> query)
key
- The key whose value is being checkedkeyInQuery
- The key in the objects from the sub query to look inquery
- The sub query to runpublic LCQuery<T> whereMatchesQuery(String key, LCQuery<?> query)
key
- The key to check.query
- The query that the value should matchpublic LCQuery<T> whereDoesNotMatchKeyInQuery(String key, String keyInQuery, LCQuery<?> query)
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 runpublic LCQuery<T> whereDoesNotMatchQuery(String key, LCQuery<?> query)
key
- The key to check.query
- The query that the value should not matchpublic static <T extends LCObject> LCQuery<T> or(List<LCQuery<T>> queries)
T
- template type.queries
- The list of AVQueries to 'or' togetherpublic static <T extends LCObject> LCQuery<T> and(List<LCQuery<T>> queries)
T
- template type.queries
- The list of AVQueries to 'and' togetherpublic boolean hasCachedResult()
public io.reactivex.Observable<List<T>> findInBackground()
public io.reactivex.Observable<List<T>> findInBackground(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.protected io.reactivex.Observable<List<T>> findInBackground(LCUser asAuthenticatedUser, int explicitLimit)
public T get(String objectId)
objectId
- object id.public io.reactivex.Observable<T> getInBackground(String objectId)
objectId
- object id.public io.reactivex.Observable<T> getInBackground(LCUser asAuthenticatedUser, String objectId)
asAuthenticatedUser
- explicit user for request authentication.objectId
- object id.public T getFirst()
public T getFirst(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.public io.reactivex.Observable<T> getFirstInBackground()
public io.reactivex.Observable<T> getFirstInBackground(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.public int count()
public int count(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.public io.reactivex.Observable<Integer> countInBackground()
public io.reactivex.Observable<Integer> countInBackground(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.public void deleteAll()
public void deleteAll(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.
in general, this method should be invoked in lean engine.public io.reactivex.Observable<LCNull> deleteAllInBackground()
public io.reactivex.Observable<LCNull> deleteAllInBackground(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.public Map<String,String> assembleParameters()
Copyright © 2020, 美味书签(北京)信息技术有限公司 All rights reserved.