本文整理汇总了Java中net.sf.jsqlparser.expression.operators.conditional.AndExpression类的典型用法代码示例。如果您正苦于以下问题:Java AndExpression类的具体用法?Java AndExpression怎么用?Java AndExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AndExpression类属于net.sf.jsqlparser.expression.operators.conditional包,在下文中一共展示了AndExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeExpression
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
public double computeExpression(Expression exp, DataRow data) {
//TODO all cases
if (exp instanceof ComparisonOperator) {
return computeComparisonOperator((ComparisonOperator) exp, data);
}
if (exp instanceof AndExpression) {
return computeAnd((AndExpression) exp, data);
}
if (exp instanceof OrExpression) {
return computeOr((OrExpression) exp, data);
}
if( exp instanceof IsNullExpression){
return computeIsNull((IsNullExpression) exp, data);
}
if(exp instanceof InExpression){
return computeInExpression((InExpression) exp, data);
}
if(exp instanceof Parenthesis){
return computeExpression(((Parenthesis) exp).getExpression(), data);
}
return cannotHandle(exp);
}
示例2: findConstraintOnColumn
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
private static Expression findConstraintOnColumn(Expression where, String columnName, String tableAlias, Class<? extends BinaryExpression> expressionType) throws StatementExecutionException {
if (where instanceof AndExpression) {
AndExpression and = (AndExpression) where;
Expression keyOnLeft = findConstraintOnColumn(and.getLeftExpression(), columnName, tableAlias, expressionType);
if (keyOnLeft != null) {
return keyOnLeft;
}
Expression keyOnRight = findConstraintOnColumn(and.getRightExpression(), columnName, tableAlias,
expressionType);
if (keyOnRight != null) {
return keyOnRight;
}
} else if (expressionType.isAssignableFrom(where.getClass())) {
Expression keyDirect = validateColumnConstaintToExpression(where, columnName, tableAlias, expressionType);
if (keyDirect != null) {
return keyDirect;
}
}
return null;
}
示例3: findConstraintExpressionOnColumn
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
private Expression findConstraintExpressionOnColumn(Expression where, String columnName, String tableAlias, Class<? extends BinaryExpression> expressionType) throws StatementExecutionException {
if (where instanceof AndExpression) {
AndExpression and = (AndExpression) where;
Expression keyOnLeft = findConstraintExpressionOnColumn(and.getLeftExpression(), columnName, tableAlias, expressionType);
if (keyOnLeft != null) {
return keyOnLeft;
}
Expression keyOnRight = findConstraintExpressionOnColumn(and.getRightExpression(), columnName, tableAlias,
expressionType);
if (keyOnRight != null) {
return keyOnRight;
}
} else if (expressionType.isAssignableFrom(where.getClass())) {
Expression keyDirect = validateColumnConstaintExpressionToExpression(where, columnName, tableAlias, expressionType);
if (keyDirect != null) {
return keyDirect;
}
}
return null;
}
示例4: builderExpression
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
/**
* 处理条件
*/
protected Expression builderExpression(Expression expression, Table table) {
//生成字段名
EqualsTo equalsTo = new EqualsTo();
equalsTo.setLeftExpression(this.getAliasColumn(table));
equalsTo.setRightExpression(tenantHandler.getTenantId());
//加入判断防止条件为空时生成 "and null" 导致查询结果为空
if (expression == null) {
return equalsTo;
} else {
if (expression instanceof BinaryExpression) {
BinaryExpression binaryExpression = (BinaryExpression) expression;
if (binaryExpression.getLeftExpression() instanceof FromItem) {
processFromItem((FromItem) binaryExpression.getLeftExpression());
}
if (binaryExpression.getRightExpression() instanceof FromItem) {
processFromItem((FromItem) binaryExpression.getRightExpression());
}
}
return new AndExpression(equalsTo, expression);
}
}
示例5: visit
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
@Override
public void visit(AndExpression expression)
{
expression.getLeftExpression().accept(this);
expression.getRightExpression().accept(this);
if (mOpenParenthesisCount != 0) {
ISqlExpression rightExpression = mFilterExpressions.pop();
ISqlExpression leftExpression = mFilterExpressions.pop();
ISqlExpression andExpression = sSqlFactory.createAndExpression(leftExpression, rightExpression);
mFilterExpressions.push(andExpression);
}
if (mOpenParenthesisCount != 0) {
decreaseOpenParenthesisCount();
}
}
示例6: computeAnd
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
private double computeAnd(AndExpression exp, DataRow data) {
double a = computeExpression(exp.getLeftExpression(), data);
double b = computeExpression(exp.getRightExpression(), data);
double sum = a + b;
if (sum < Math.max(a, b)) {
//overflow
return Double.MAX_VALUE;
} else {
return sum;
}
}
示例7: checkJSqlParserFeature
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
/**
* To make ddal-jsqlparser work well, JSqlParser should include the feature of 'support getting jdbc parameter index'.
* And this feature is provided on the version of {@link <a href="https://github.com/JSQLParser/JSqlParser/releases/tag/jsqlparser-0.9.7">0.9.7</a>}.
* This method is designed to check the necessary feature.
*/
private static void checkJSqlParserFeature() throws JSQLParserException {
CCJSqlParserManager parserManager = new CCJSqlParserManager();
String sql = "SELECT * FROM tab_1 WHERE tab_1.col_1 = ? AND col_2 IN (SELECT DISTINCT col_2 FROM tab_2 WHERE col_3 LIKE ? AND col_4 > ?) LIMIT ?, ?";
Select select = (Select) parserManager.parse(new StringReader(sql));
PlainSelect selectBody = (PlainSelect) select.getSelectBody();
//
AndExpression andExpression = (AndExpression) selectBody.getWhere();
EqualsTo equalsTo = (EqualsTo) andExpression.getLeftExpression();
JdbcParameter jdbcParameter = (JdbcParameter) equalsTo.getRightExpression();
Integer index1 = jdbcParameter.getIndex();
if (index1 != 1) {
throw new IllegalStateException("Current version of JSQLParser doesn't support the feature of 'support "
+ "get jdbc parameter index'");
}
//
InExpression inExpression = (InExpression) andExpression.getRightExpression();
SubSelect subSelect = (SubSelect) inExpression.getRightItemsList();
PlainSelect subSelectBody = (PlainSelect) subSelect.getSelectBody();
AndExpression subAndExpression = (AndExpression) subSelectBody.getWhere();
LikeExpression likeExpression = (LikeExpression) subAndExpression.getLeftExpression();
if (((JdbcParameter) likeExpression.getRightExpression()).getIndex() != 2) {
throw new IllegalStateException(
"Current version of JSQLParser doesn't support the feature of 'support get jdbc parameter index'");
}
//
GreaterThan greaterThan = (GreaterThan) subAndExpression.getRightExpression();
if (((JdbcParameter) greaterThan.getRightExpression()).getIndex() != 3) {
throw new IllegalStateException(
"Current version of JSQLParser doesn't support the feature of 'support get jdbc parameter index'");
}
//
Expression offset = selectBody.getLimit().getOffset();
Expression rowCount = selectBody.getLimit().getRowCount();
if (((JdbcParameter) offset).getIndex() != 4 || ((JdbcParameter) rowCount).getIndex() != 5) {
throw new IllegalStateException(
"Current version of JSQLParser doesn't support the feature of 'support get jdbc parameter index'");
}
}
示例8: validateColumnConstaintToExpression
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
private static Expression validateColumnConstaintToExpression(Expression testExpression, String columnName, String tableAlias, Class<? extends BinaryExpression> expressionType) throws StatementExecutionException {
Expression result = null;
if (expressionType.isAssignableFrom(testExpression.getClass())) {
BinaryExpression e = (BinaryExpression) testExpression;
if (e.getLeftExpression() instanceof net.sf.jsqlparser.schema.Column) {
net.sf.jsqlparser.schema.Column c = (net.sf.jsqlparser.schema.Column) e.getLeftExpression();
boolean okAlias = true;
if (c.getTable() != null && c.getTable().getName() != null && !c.getTable().getName().equals(tableAlias)) {
okAlias = false;
}
if (okAlias && columnName.equalsIgnoreCase(c.getColumnName())
&& SQLRecordPredicate.isConstant(e.getRightExpression())) {
return e.getRightExpression();
}
} else if (e.getLeftExpression() instanceof AndExpression) {
result = findConstraintOnColumn(e.getLeftExpression(), columnName, tableAlias, expressionType);
if (result != null) {
return result;
}
} else if (e.getRightExpression() instanceof AndExpression) {
result = findConstraintOnColumn(e.getRightExpression(), columnName, tableAlias, expressionType);
if (result != null) {
return result;
}
}
}
return result;
}
示例9: validateColumnConstaintExpressionToExpression
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
private Expression validateColumnConstaintExpressionToExpression(Expression testExpression, String columnName, String tableAlias, Class<? extends BinaryExpression> expressionType) throws StatementExecutionException {
Expression result = null;
if (expressionType.isAssignableFrom(testExpression.getClass())) {
BinaryExpression e = (BinaryExpression) testExpression;
if (e.getLeftExpression() instanceof net.sf.jsqlparser.schema.Column) {
net.sf.jsqlparser.schema.Column c = (net.sf.jsqlparser.schema.Column) e.getLeftExpression();
boolean okAlias = true;
if (c.getTable() != null && c.getTable().getName() != null && !c.getTable().getName().equals(tableAlias)) {
okAlias = false;
}
if (okAlias && columnName.equalsIgnoreCase(c.getColumnName())
&& SQLRecordPredicate.isConstant(e.getRightExpression())) {
return e;
}
} else if (e.getLeftExpression() instanceof AndExpression) {
result = findConstraintExpressionOnColumn(e.getLeftExpression(), columnName, tableAlias, expressionType);
if (result != null) {
return result;
}
} else if (e.getRightExpression() instanceof AndExpression) {
result = findConstraintExpressionOnColumn(e.getRightExpression(), columnName, tableAlias, expressionType);
if (result != null) {
return result;
}
}
}
return result;
}
示例10: collectConditionsForAlias
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
private Expression collectConditionsForAlias(String alias, Expression expression,
List<ColumnReferencesDiscovery> conditionsOnJoinedResult, String mainTableName) throws StatementExecutionException {
if (expression == null) {
// no constraint on table
return null;
}
ColumnReferencesDiscovery discoveredMainAlias = discoverMainTableAlias(expression);
String mainAlias = discoveredMainAlias.getMainTableAlias();
if (!discoveredMainAlias.isContainsMixedAliases() && alias.equals(mainAlias)) {
return expression;
} else if (expression instanceof AndExpression) {
AndExpression be = (AndExpression) expression;
ColumnReferencesDiscovery discoveredMainAliasLeft = discoverMainTableAlias(be.getLeftExpression());
String mainAliasLeft = discoveredMainAliasLeft.isContainsMixedAliases()
? null : discoveredMainAliasLeft.getMainTableAlias();
ColumnReferencesDiscovery discoveredMainAliasright = discoverMainTableAlias(be.getRightExpression());
String mainAliasRight = discoveredMainAliasright.isContainsMixedAliases()
? null : discoveredMainAliasright.getMainTableAlias();
if (alias.equals(mainAliasLeft)) {
if (alias.equals(mainAliasRight)) {
return expression;
} else {
return be.getLeftExpression();
}
} else if (alias.equals(mainAliasRight)) {
return be.getRightExpression();
} else {
// no constraint on table
return null;
}
} else {
conditionsOnJoinedResult.add(discoveredMainAlias);
return null;
}
}
示例11: andExpression
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
/**
* <p>
* delete update 语句 where 处理
* </p>
*/
protected BinaryExpression andExpression(Table table, Expression where) {
//获得where条件表达式
EqualsTo equalsTo = new EqualsTo();
if (null != where) {
equalsTo.setLeftExpression(new Column(this.tenantHandler.getTenantIdColumn()));
equalsTo.setRightExpression(tenantHandler.getTenantId());
return new AndExpression(equalsTo, where);
}
equalsTo.setLeftExpression(this.getAliasColumn(table));
equalsTo.setRightExpression(tenantHandler.getTenantId());
return equalsTo;
}
示例12: visit
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
@Override
public void visit(AndExpression expr) {
visitBinaryExpression(expr);
}
示例13: visit
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
@Override
public void visit(AndExpression andExpression) {
visitBinaryExpression(andExpression, " AND ");
}
示例14: visit
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
@Override
public void visit(AndExpression andExpression) {
visitBinaryExpression(andExpression);
}
示例15: visit
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; //导入依赖的package包/类
public void visit(AndExpression andExpression) {
andExpression.getLeftExpression().accept(this);
andExpression.getRightExpression().accept(this);
}