本文整理汇总了Java中net.sf.jsqlparser.expression.BinaryExpression.getLeftExpression方法的典型用法代码示例。如果您正苦于以下问题:Java BinaryExpression.getLeftExpression方法的具体用法?Java BinaryExpression.getLeftExpression怎么用?Java BinaryExpression.getLeftExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jsqlparser.expression.BinaryExpression
的用法示例。
在下文中一共展示了BinaryExpression.getLeftExpression方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: builderExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入方法依赖的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);
}
}
示例2: validateColumnConstaintToExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入方法依赖的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;
}
示例3: validateColumnConstaintExpressionToExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入方法依赖的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;
}
示例4: visitBinaryExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入方法依赖的package包/类
private void visitBinaryExpression(BinaryExpression e) {
if (e.getLeftExpression() instanceof JdbcParameter) {
e.setLeftExpression(ImmutableExpressionsCache.internOrFixJdbcParameterExpression((JdbcParameter) e.getLeftExpression()));
}
if (e.getRightExpression() instanceof JdbcParameter) {
e.setRightExpression(ImmutableExpressionsCache.internOrFixJdbcParameterExpression((JdbcParameter) e.getRightExpression()));
}
e.getLeftExpression().accept(this);
e.getRightExpression().accept(this);
}
示例5: compileSpecialBinaryExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入方法依赖的package包/类
private static CompiledSQLExpression compileSpecialBinaryExpression(String validatedTableAlias, Expression exp) {
BinaryExpression be = (BinaryExpression) exp;
// MOST frequent expressions "TABLE.COLUMNNAME OPERATOR ?", we can hardcode the access to the column and to the JDBC parameter
if (be.getLeftExpression() instanceof net.sf.jsqlparser.schema.Column) {
net.sf.jsqlparser.schema.Column c = (net.sf.jsqlparser.schema.Column) be.getLeftExpression();
if (validatedTableAlias != null) {
if (c.getTable() != null && c.getTable().getName() != null
&& !c.getTable().getName().equals(validatedTableAlias)) {
return null;
}
}
String columnName = c.getColumnName();
switch (columnName) {
case BuiltinFunctions.BOOLEAN_TRUE:
return null;
case BuiltinFunctions.BOOLEAN_FALSE:
return null;
default:
// OK !
break;
}
if (be.getRightExpression() instanceof JdbcParameter) {
JdbcParameter jdbcParam = (JdbcParameter) be.getRightExpression();
int jdbcIndex = jdbcParam.getIndex() - 1;
if (be instanceof EqualsTo) {
return new ColumnEqualsJdbcParameter(be.isNot(), columnName, jdbcIndex);
} else if (be instanceof NotEqualsTo) {
return new ColumnNotEqualsJdbcParameter(be.isNot(), columnName, jdbcIndex);
} else if (be instanceof GreaterThanEquals) {
return new ColumnGreaterThanEqualsJdbcParameter(be.isNot(), columnName, jdbcIndex);
} else if (be instanceof GreaterThan) {
return new ColumnGreaterThanJdbcParameter(be.isNot(), columnName, jdbcIndex);
} else if (be instanceof MinorThan) {
return new ColumnMinorThanJdbcParameter(be.isNot(), columnName, jdbcIndex);
} else if (be instanceof MinorThanEquals) {
return new ColumnMinorThanEqualsJdbcParameter(be.isNot(), columnName, jdbcIndex);
}
} // TODO handle "TABLE.COLUMNNAME OPERATOR CONSTANT"
}
return null;
}
示例6: parseWhere
import net.sf.jsqlparser.expression.BinaryExpression; //导入方法依赖的package包/类
private void parseWhere(Expression where, int sequence) {
log.debug("parse WHERE expression " + where);
if (where == null) {
log.info("No WHERE clause. Seems not to be a primary key condition");
} else if (where instanceof AndExpression) {
AndExpression and = (AndExpression) where;
parseWhere(and.getLeftExpression(), sequence);
parseWhere(and.getRightExpression(), sequence + 1);
} else if (where instanceof BinaryExpression) {
BinaryExpression exp = (BinaryExpression) where;
if (!(exp.getLeftExpression() instanceof Column)) {
if (log.isDebugEnabled()) {
log.debug(exp.getLeftExpression().toString()
+ exp.getStringExpression() + exp.getRightExpression()
+ " is not a unique condition for the primary key column");
}
return;
}
List<SqlParameter> paramList = parameterMap.get(sql);
if (paramList == null) {
paramList = new ArrayList<SqlParameter>();
parameterMap.put(sql, paramList);
}
findPrimaryKeyColumn();
SqlExpressionParser expParser = new SqlExpressionParser();
exp.getRightExpression().accept(expParser);
Object value = expParser.getValue();
String colName = ((Column) exp.getLeftExpression()).getColumnName();
SqlParameter sqlParam = new SqlParameter(colName, value);
if ("?".equals(value)) {
sequence++;
sqlParam.setSequence(sequence);
}
if (colName.equalsIgnoreCase(primaryKeyColumn)
&& exp instanceof EqualsTo) {
primaryKeys.put(sql, sqlParam);
}
paramList.add(sqlParam);
if (log.isDebugEnabled()) {
log.debug("parse WHERE column " + sqlParam);
}
} else {
log.info("WHERE clause does not contain a unique primary key condition.");
}
}