Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package cn.leancloud.query;
import cn.leancloud.LCObject;
import cn.leancloud.ops.Utils;
import cn.leancloud.types.LCGeoPoint;
import cn.leancloud.utils.LCUtils;
import cn.leancloud.utils.StringUtil;
import java.util.*;
public class QueryConditions implements Cloneable {
Map> where;
private List include;
private Set selectedKeys;
private int limit;
private boolean trace;
private int skip = -1;
private String order;
private Map parameters;
private boolean includeACL = false;
public QueryConditions() {
where = new HashMap>();
include = new LinkedList();
includeACL = false;
parameters = new HashMap();
}
// It’s also legal to implement clone() without using Object.clone(),
// by manually constructing a new object and copying fields.
public QueryConditions clone() {
QueryConditions condition = new QueryConditions();
condition.where.putAll(this.where);
condition.include.addAll(this.include);
condition.parameters.putAll(this.parameters);
condition.selectKeys(this.selectedKeys);
condition.setLimit(this.limit);
condition.setTrace(this.trace);
condition.setSkip(this.skip);
condition.setOrder(this.order);
condition.includeACL(this.includeACL);
return condition;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public int getSkip() {
return skip;
}
public void setSkip(int skip) {
this.skip = skip;
}
public String getOrder() {
return order;
}
public void setOrder(String order) {
this.order = order;
}
public List getInclude() {
return include;
}
public void setInclude(List include) {
this.include = include;
}
public Set getSelectedKeys() {
return selectedKeys;
}
public void setSelectedKeys(Set selectedKeys) {
this.selectedKeys = selectedKeys;
}
public Map> getWhere() {
return where;
}
public void setWhere(Map> where) {
this.where = where;
}
public Map getParameters() {
return new HashMap(parameters);
}
public void setParameters(Map parameters) {
this.parameters = parameters;
}
public boolean isTrace() {
return trace;
}
public void setTrace(boolean trace) {
this.trace = trace;
}
public void addAscendingOrder(String key) {
if (StringUtil.isEmpty(order)) {
this.orderByAscending(key);
return;
}
order = String.format("%s,%s", order, key);
}
public void orderByAscending(String key) {
order = String.format("%s", key);
}
public void addDescendingOrder(String key) {
if (StringUtil.isEmpty(order)) {
orderByDescending(key);
return;
}
order = String.format("%s,-%s", order, key);
}
public void orderByDescending(String key) {
order = String.format("-%s", key);
}
public void include(String key) {
include.add(key);
}
public void selectKeys(Collection keys) {
if (selectedKeys == null) {
selectedKeys = new HashSet();
}
if (null != keys) {
selectedKeys.addAll(keys);
}
}
/**
* Flag to indicate need ACL returned in result.
* @return include flag.
*/
public boolean isIncludeACL() {
return includeACL;
}
/**
* set include ACL or not.
* @param includeACL Flag to indicate need ACL returned in result.
*/
public void includeACL(boolean includeACL) {
this.includeACL = includeACL;
}
public Map compileWhereOperationMap() {
Map result = new HashMap();
for (Map.Entry> entry : where.entrySet()) {
List ops = entry.getValue();
final String key = entry.getKey();
if (key.equals(QueryOperation.OR_OP)) {
List