mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
87 lines
2.2 KiB
Java
87 lines
2.2 KiB
Java
package com.avaje.ebeaninternal.util;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
|
import com.avaje.ebeaninternal.server.core.SpiOrmQueryRequest;
|
|
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
|
import com.avaje.ebeaninternal.server.deploy.DeployParser;
|
|
|
|
public class DefaultExpressionRequest implements SpiExpressionRequest {
|
|
|
|
private final SpiOrmQueryRequest<?> queryRequest;
|
|
|
|
private final BeanDescriptor<?> beanDescriptor;
|
|
|
|
private final StringBuilder sb = new StringBuilder();
|
|
|
|
private final ArrayList<Object> bindValues = new ArrayList<Object>();
|
|
|
|
private final DeployParser deployParser;
|
|
|
|
private int paramIndex;
|
|
|
|
public DefaultExpressionRequest(SpiOrmQueryRequest<?> queryRequest, DeployParser deployParser) {
|
|
this.queryRequest = queryRequest;
|
|
this.beanDescriptor = queryRequest.getBeanDescriptor();
|
|
this.deployParser = deployParser;
|
|
}
|
|
|
|
// public DefaultExpressionRequest(SpiOrmQueryRequest<?> queryRequest, LIndex
|
|
// index) {
|
|
// this.queryRequest = queryRequest;
|
|
// this.beanDescriptor = queryRequest.getBeanDescriptor();
|
|
// this.deployParser = null;
|
|
// this.luceneIndex = index;
|
|
// }
|
|
|
|
public DefaultExpressionRequest(BeanDescriptor<?> beanDescriptor) {
|
|
this.beanDescriptor = beanDescriptor;
|
|
this.queryRequest = null;
|
|
this.deployParser = null;
|
|
}
|
|
|
|
public String parseDeploy(String logicalProp) {
|
|
|
|
String s = deployParser.getDeployWord(logicalProp);
|
|
return s == null ? logicalProp : s;
|
|
}
|
|
|
|
/**
|
|
* Increments the parameter index and returns that value.
|
|
*/
|
|
public int nextParameter() {
|
|
return ++paramIndex;
|
|
}
|
|
|
|
public BeanDescriptor<?> getBeanDescriptor() {
|
|
return beanDescriptor;
|
|
}
|
|
|
|
public SpiOrmQueryRequest<?> getQueryRequest() {
|
|
return queryRequest;
|
|
}
|
|
|
|
public SpiExpressionRequest append(String sql) {
|
|
sb.append(sql);
|
|
return this;
|
|
}
|
|
|
|
public void addBindValue(Object bindValue) {
|
|
bindValues.add(bindValue);
|
|
}
|
|
|
|
public boolean includeProperty(String propertyName) {
|
|
return true;
|
|
}
|
|
|
|
public String getSql() {
|
|
return sb.toString();
|
|
}
|
|
|
|
public ArrayList<Object> getBindValues() {
|
|
return bindValues;
|
|
}
|
|
|
|
}
|