本文整理汇总了Java中net.sf.jsqlparser.expression.BinaryExpression类的典型用法代码示例。如果您正苦于以下问题:Java BinaryExpression类的具体用法?Java BinaryExpression怎么用?Java BinaryExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BinaryExpression类属于net.sf.jsqlparser.expression包,在下文中一共展示了BinaryExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的package包/类
protected Set<String> parseExpression(Expression expression) {
Set<String> expTableSet = new HashSet<String>();
if (expression instanceof BinaryExpression) {
expTableSet.addAll(parseExpression(((BinaryExpression)expression).getLeftExpression()));
expTableSet.addAll(parseExpression(((BinaryExpression)expression).getRightExpression()));
}
if (expression instanceof InExpression) {
ItemsList itemList = ((InExpression)expression).getRightItemsList();
if (itemList instanceof SubSelect) {
SubSelect subSelect = (SubSelect)itemList;
expTableSet.addAll(parse(subSelect.getSelectBody()));
}
}
return expTableSet;
}
示例2: visit
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的package包/类
@Override
public void visit(PlainSelect plainSelect) {
for (SelectItem item : plainSelect.getSelectItems()) {
item.accept(this);
}
if (itemsExpr.size() > 1) {
BinaryExpression binExpr = createBinaryExpression();
binExpr.setLeftExpression(itemsExpr.get(0).getExpression());
for (int i = 1; i < itemsExpr.size() - 1; i++) {
binExpr.setRightExpression(itemsExpr.get(i).getExpression());
BinaryExpression binExpr2 = createBinaryExpression();
binExpr2.setLeftExpression(binExpr);
binExpr = binExpr2;
}
binExpr.setRightExpression(itemsExpr.get(itemsExpr.size() - 1).getExpression());
SelectExpressionItem sei = new SelectExpressionItem();
sei.setExpression(binExpr);
plainSelect.getSelectItems().clear();
plainSelect.getSelectItems().add(sei);
}
((SelectExpressionItem) plainSelect.getSelectItems().get(0)).setAlias(new Alias(alias));
}
示例3: findConstraintOnColumn
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的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;
}
示例4: findConstraintExpressionOnColumn
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的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;
}
示例5: findIndexAccess
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的package包/类
private static SQLRecordKeyFunction findIndexAccess(Expression where, String[] columnsToMatch, ColumnsList table, String tableAlias, Class<? extends BinaryExpression> expressionType) throws StatementExecutionException {
List<Expression> expressions = new ArrayList<>();
List<String> columns = new ArrayList<>();
for (String pk : columnsToMatch) {
Expression condition = findConstraintOnColumn(where, pk, tableAlias, expressionType);
if (condition == null) {
break;
}
columns.add(pk);
expressions.add(condition);
}
if (expressions.isEmpty()) {
// no match at all, there is no direct constraint on PK
return null;
}
return new SQLRecordKeyFunction(table, columns, expressions);
}
示例6: findFiltersOnPrimaryKey
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的package包/类
private Expression findFiltersOnPrimaryKey(Table table, String tableAlias, Expression where) throws StatementExecutionException {
List<Expression> expressions = new ArrayList<>();
for (String pk : table.primaryKey) {
Expression condition = findConstraintExpressionOnColumn(where, pk, tableAlias, BinaryExpression.class);
if (condition == null) {
break;
}
expressions.add(condition);
}
if (expressions.isEmpty()) {
// no match at all, there is no direct constraint on PK
return null;
} else {
return composeSimpleAndExpressions(expressions);
}
}
示例7: 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);
}
}
示例8: visitBinaryExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的package包/类
protected ISqlExpression visitBinaryExpression(BinaryExpression binaryExpression)
{
binaryExpression.getLeftExpression().accept(this);
ISqlExpression leftParameter = getExpression();
binaryExpression.getRightExpression().accept(this);
ISqlExpression rightParameter = getExpression();
if (binaryExpression instanceof Addition) {
return sSqlFactory.createAdditionExpression(leftParameter, rightParameter);
}
else if (binaryExpression instanceof Subtraction) {
return sSqlFactory.createSubstractExpression(leftParameter, rightParameter);
}
else if (binaryExpression instanceof Multiplication) {
return sSqlFactory.createMultiplyExpression(leftParameter, rightParameter);
}
else if (binaryExpression instanceof Division) {
return sSqlFactory.createDivideExpression(leftParameter, rightParameter);
}
else if (binaryExpression instanceof Concat) {
return sSqlFactory.createConcatExpression(leftParameter, rightParameter);
}
throw new UnsupportedSqlExpressionException(binaryExpression.toString());
}
示例9: visitBinaryExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的package包/类
private void visitBinaryExpression(BinaryExpression binaryExpression, String operator) {
if (binaryExpression.isNot()) {
buffer.append(NOT);
}
binaryExpression.getLeftExpression().accept(this);
buffer.append(operator);
binaryExpression.getRightExpression().accept(this);
}
示例10: 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;
}
示例11: 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;
}
示例12: tryCompileBinaryExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的package包/类
private static CompiledSQLExpression tryCompileBinaryExpression(
String validatedTableAlias,
BinaryExpression binExp,
BinaryExpressionBuilder compiledExpClass) {
CompiledSQLExpression left = compileExpression(validatedTableAlias, binExp.getLeftExpression());
if (left == null) {
return null;
}
CompiledSQLExpression right = compileExpression(validatedTableAlias, binExp.getRightExpression());
if (right == null) {
return null;
}
return compiledExpClass.build(binExp.isNot(), left, right);
}
示例13: 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);
}
示例14: andExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的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;
}
示例15: visitBinaryExpression
import net.sf.jsqlparser.expression.BinaryExpression; //导入依赖的package包/类
private void visitBinaryExpression(BinaryExpression binaryExpression, String operator) {
if (binaryExpression.isNot()) {
buffer.append(binaryExpression.getCommentNot() != null ? " " + binaryExpression.getCommentNot() + ExpressionDeParser.LINE_SEPARATOR : "").append(" not ");
}
binaryExpression.getLeftExpression().accept(this);
buffer.append(operator);
binaryExpression.getRightExpression().accept(this);
}