当前位置: 首页>>代码示例>>Java>>正文


Java Expression类代码示例

本文整理汇总了Java中net.sf.jsqlparser.expression.Expression的典型用法代码示例。如果您正苦于以下问题:Java Expression类的具体用法?Java Expression怎么用?Java Expression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Expression类属于net.sf.jsqlparser.expression包,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createUpdateMutation

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
private Mutation createUpdateMutation(Update update, boolean generateParameterMetaData) throws SQLException
{
	if (update.getTables().isEmpty())
		throw new CloudSpannerSQLException("No table found in update statement", Code.INVALID_ARGUMENT);
	if (update.getTables().size() > 1)
		throw new CloudSpannerSQLException("Update statements for multiple tables at once are not supported",
				Code.INVALID_ARGUMENT);
	String table = unquoteIdentifier(update.getTables().get(0).getFullyQualifiedName());
	getParameterStore().setTable(table);
	List<Expression> expressions = update.getExpressions();
	WriteBuilder builder = Mutation.newUpdateBuilder(table);
	int index = 0;
	for (Column col : update.getColumns())
	{
		String columnName = unquoteIdentifier(col.getFullyQualifiedName());
		expressions.get(index).accept(new ValueBinderExpressionVisitorAdapter<>(getParameterStore(),
				builder.set(columnName), columnName));
		index++;
	}
	visitUpdateWhereClause(update.getWhere(), builder, generateParameterMetaData);

	return builder.build();
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:24,代码来源:CloudSpannerPreparedStatement.java

示例2: createDeleteMutation

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
private Mutation createDeleteMutation(Delete delete, boolean generateParameterMetaData) throws SQLException
{
	String table = unquoteIdentifier(delete.getTable().getFullyQualifiedName());
	getParameterStore().setTable(table);
	Expression where = delete.getWhere();
	if (where == null)
	{
		// Delete all
		return Mutation.delete(table, KeySet.all());
	}
	else
	{
		// Delete one
		DeleteKeyBuilder keyBuilder = new DeleteKeyBuilder(getConnection().getTable(table),
				generateParameterMetaData);
		visitDeleteWhereClause(where, keyBuilder, generateParameterMetaData);
		return Mutation.delete(table, keyBuilder.getKeyBuilder().build());
	}
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:20,代码来源:CloudSpannerPreparedStatement.java

示例3: visitDeleteWhereClause

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
private void visitDeleteWhereClause(Expression where, DeleteKeyBuilder keyBuilder,
		boolean generateParameterMetaData) throws SQLException
{
	if (where != null)
	{
		DMLWhereClauseVisitor whereClauseVisitor = new DMLWhereClauseVisitor(getParameterStore())
		{

			@Override
			protected void visitExpression(Column col, Expression expression)
			{
				String columnName = unquoteIdentifier(col.getFullyQualifiedName());
				keyBuilder.set(columnName);
				expression.accept(
						new KeyBuilderExpressionVisitorAdapter(getParameterStore(), columnName, keyBuilder));
			}

		};
		where.accept(whereClauseVisitor);
		if (!generateParameterMetaData && !whereClauseVisitor.isValid())
		{
			throw new CloudSpannerSQLException(INVALID_WHERE_CLAUSE_DELETE_MESSAGE, Code.INVALID_ARGUMENT);
		}
	}
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:26,代码来源:CloudSpannerPreparedStatement.java

示例4: isSingleRowWhereClause

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
private boolean isSingleRowWhereClause(TableKeyMetaData table, Expression where)
{
	if (where != null)
	{
		SingleRowWhereClauseValidator validator = new SingleRowWhereClauseValidator(table);
		DMLWhereClauseVisitor whereClauseVisitor = new DMLWhereClauseVisitor(getParameterStore())
		{

			@Override
			protected void visitExpression(Column col, Expression expression)
			{
				String columnName = unquoteIdentifier(col.getFullyQualifiedName());
				validator.set(columnName);
				expression.accept(
						new SingleRowWhereClauseValidatorExpressionVisitorAdapter(getParameterStore(), validator));
			}

		};
		where.accept(whereClauseVisitor);
		return whereClauseVisitor.isValid() && validator.isValid();
	}
	return false;
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:24,代码来源:CloudSpannerPreparedStatement.java

示例5: findBindArgsExpressions

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
/**
 * 找到所有绑定变量
 *
 * @param sql
 * @return
 */
protected static Set<Expression> findBindArgsExpressions(String sql) {
    if (sql == null || sql.startsWith("PRAGMA") || !sql.contains("?")) {
        return new LinkedHashSet<>();
    }

    KbSqlParserManager pm = new KbSqlParserManager();

    try {
        Statement statement = pm.parse(sql);

        Set<Expression> expressionSet = findBindArgsExpressions(statement);

        return expressionSet;
    } catch (JSQLParserException e) {
        e.printStackTrace();
    }
    return new LinkedHashSet<>();
}
 
开发者ID:kkmike999,项目名称:YuiHatano,代码行数:25,代码来源:KbSqlParser.java

示例6: countSelectItem

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
/**
 * 获取jsqlparser中count的SelectItem
 *
 * @return
 */
private static List<SelectItem> countSelectItem() {
    if (CollectionUtils.isNotEmpty(countSelectItem)) {
        return countSelectItem;
    }
    Function function = new Function();
    function.setName("COUNT");
    List<Expression> expressions = new ArrayList<>();
    LongValue longValue = new LongValue(1);
    ExpressionList expressionList = new ExpressionList();
    expressions.add(longValue);
    expressionList.setExpressions(expressions);
    function.setParameters(expressionList);
    countSelectItem = new ArrayList<>();
    SelectExpressionItem selectExpressionItem = new SelectExpressionItem(function);
    countSelectItem.add(selectExpressionItem);
    return countSelectItem;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:23,代码来源:JsqlParserUtils.java

示例7: getGroups

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
/**
     * 解析group by的语义,并保存到GoupBy 中
     *
     * @param defalutTable 默认的表名
     * @param plainSelect  SQL
     */
    private void getGroups(String defalutTable, PlainSelect plainSelect) {
        List<Expression> groupExps = plainSelect.getGroupByColumnReferences();
        if (groupExps != null) {
            for (Expression item : groupExps) {
                Column column = (Column) item;
                TCItem tcItem = new TCItem();
                tcItem.setColName(column.getColumnName());
                if (column.getTable().getName() == null || column.getTable().getName().isEmpty()) {
                    tcItem.setTableName(defalutTable);
                } else {
                    tcItem.setTableName(column.getTable().getName());
                }
                GroupBy.groupList.add(tcItem);
            }
        }
//        assertEquals(2,GroupBy.groupList.size());
    }
 
开发者ID:bigdataFlySQL,项目名称:SQLonStorm,代码行数:24,代码来源:ParsingSQL.java

示例8: addJoin

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
/**
 * Adds a simple join to a select statement. The introduced join is returned for
 * more configuration settings on it (e.g. left join, right join).
 * @param select
 * @param table
 * @param onExpression
 * @return 
 */
public static Join addJoin(Select select, final Table table, final Expression onExpression) {
	if (select.getSelectBody() instanceof PlainSelect) {
		PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
		List<Join> joins = plainSelect.getJoins();
		if (joins == null) {
			joins = new ArrayList<Join>();
			plainSelect.setJoins(joins);
		}
		Join join = new Join();
		join.setRightItem(table);
		join.setOnExpression(onExpression);
		joins.add(join);
		return join;
	}
	throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:25,代码来源:SelectUtils.java

示例9: addExpression

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
/**
 * Adds an expression to select statements. E.g. a simple column is an
 * expression.
 *
 * @param select
 * @param expr
 */
public static void addExpression(Select select, final Expression expr) {
	select.getSelectBody().accept(new SelectVisitor() {

		@Override
		public void visit(PlainSelect plainSelect) {
			plainSelect.getSelectItems().add(new SelectExpressionItem(expr));
		}

		@Override
		public void visit(SetOperationList setOpList) {
			throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
		}

		@Override
		public void visit(WithItem withItem) {
			throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
		}
	});
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:27,代码来源:SelectUtils.java

示例10: visit

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
@Override
public void visit(ExpressionList expressionList) {
    if (useBracketsInExprList) {
        buffer.append("(");
    }
    for (Iterator<Expression> iter = expressionList.getExpressions().iterator(); iter.hasNext();) {
        Expression expression = iter.next();
        expression.accept(this);
        if (iter.hasNext()) {
            buffer.append(", ");
        }
    }
    if (useBracketsInExprList) {
        buffer.append(")");
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:17,代码来源:ExpressionDeParser.java

示例11: parseToValue

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
private static Expression parseToValue(Object arg) {
    if (arg instanceof Long || arg instanceof Integer) {
        return new LongValue(arg.toString());
    } else if (arg instanceof Double || arg instanceof Float) {
        return new DoubleValue(arg.toString());
    }

    return new StringValue(arg.toString());
}
 
开发者ID:kkmike999,项目名称:KBUnitTest,代码行数:10,代码来源:KbSqlParser.java

示例12: setWhereParameters

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
private void setWhereParameters(Expression where, com.google.cloud.spanner.Statement.Builder builder)
{
	if (where != null)
	{
		where.accept(new ExpressionVisitorAdapter()
		{
			private String currentCol = null;

			@Override
			public void visit(Column col)
			{
				currentCol = unquoteIdentifier(col.getFullyQualifiedName());
			}

			@Override
			public void visit(JdbcParameter parameter)
			{
				parameter.accept(new ValueBinderExpressionVisitorAdapter<>(getParameterStore(),
						builder.bind("p" + parameter.getIndex()), currentCol));
				currentCol = null;
			}

			@Override
			public void visit(SubSelect subSelect)
			{
				setSelectParameters(subSelect.getSelectBody(), builder);
			}

		});
	}
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:32,代码来源:CloudSpannerPreparedStatement.java

示例13: visitUpdateWhereClause

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
private void visitUpdateWhereClause(Expression where, WriteBuilder builder, boolean generateParameterMetaData)
		throws SQLException
{
	if (where != null)
	{
		DMLWhereClauseVisitor whereClauseVisitor = new DMLWhereClauseVisitor(getParameterStore())
		{

			@Override
			protected void visitExpression(Column col, Expression expression)
			{
				String columnName = unquoteIdentifier(col.getFullyQualifiedName());
				expression.accept(new ValueBinderExpressionVisitorAdapter<>(getParameterStore(),
						builder.set(columnName), columnName));
			}

		};
		where.accept(whereClauseVisitor);
		if (!generateParameterMetaData && !whereClauseVisitor.isValid())
		{
			throw new CloudSpannerSQLException(INVALID_WHERE_CLAUSE_UPDATE_MESSAGE, Code.INVALID_ARGUMENT);
		}
	}
	else
	{
		throw new SQLException(INVALID_WHERE_CLAUSE_UPDATE_MESSAGE);
	}
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:29,代码来源:CloudSpannerPreparedStatement.java

示例14: visit

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
@Override
public void visit(ExpressionList expressionList) {
    for (Iterator<?> iter = expressionList.getExpressions().iterator();iter.hasNext();) {
        Expression expression = (Expression) iter.next();
        expression.accept(this);
    }
}
 
开发者ID:devpage,项目名称:sharding-quickstart,代码行数:8,代码来源:TablesNamesFinder.java

示例15: getBindArgsCount

import net.sf.jsqlparser.expression.Expression; //导入依赖的package包/类
protected static int getBindArgsCount(String sql) {
    Set<Expression> expressionSet = findBindArgsExpressions(sql);

    int count = 0;

    for (Expression expression : expressionSet) {
        count += getBindArgsCount(expression);
    }

    return count;
}
 
开发者ID:kkmike999,项目名称:KBUnitTest,代码行数:12,代码来源:KbSqlParser.java


注:本文中的net.sf.jsqlparser.expression.Expression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。