• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SelectExpressionItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: visit

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
@Override
public void visit(SelectExpressionItem selectExpressionItem) {
	if (firstRun) {
		if (selectExpressionItem.getAlias() != null) {
			aliases.add(selectExpressionItem.getAlias().getName().toUpperCase());
		}
	} else {
		if (selectExpressionItem.getAlias() == null) {

			while (true) {
				String alias = getNextAlias().toUpperCase();
				if (!aliases.contains(alias)) {
					aliases.add(alias);
					selectExpressionItem.setAlias(new Alias(alias));
					break;
				}
			}
		}
	}
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:21,代码来源:AddAliasesVisitor.java


示例2: countSelectItem

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的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


示例3: visit

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的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));
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:27,代码来源:ConnectExpressionsVisitor.java


示例4: addExpression

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的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


示例5: processPlainSelect

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
/**
 * <p>
 * 处理 PlainSelect
 * </p>
 *
 * @param plainSelect
 * @param addColumn   是否添加租户列,insert into select语句中需要
 */
protected void processPlainSelect(PlainSelect plainSelect, boolean addColumn) {
    FromItem fromItem = plainSelect.getFromItem();
    if (fromItem instanceof Table) {
        Table fromTable = (Table) fromItem;
        if (this.tenantHandler.doTableFilter(fromTable.getName())) {
            // 过滤退出执行
            return;
        }
        plainSelect.setWhere(builderExpression(plainSelect.getWhere(), fromTable));
        if (addColumn) {
            plainSelect.getSelectItems().add(new SelectExpressionItem(new Column(this.tenantHandler.getTenantIdColumn())));
        }
    } else {
        processFromItem(fromItem);
    }
    List<Join> joins = plainSelect.getJoins();
    if (joins != null && joins.size() > 0) {
        for (Join join : joins) {
            processJoin(join);
            processFromItem(join.getRightItem());
        }
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:32,代码来源:TenantSqlParser.java


示例6: createProjections

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
private List<ProjectionItem> createProjections(PlainSelect plainSelect, List<ProjectionItem> fromProjections) throws AmbiguousCoalesceException {
	List<ProjectionItem> projections = Lists.newArrayList();

	List<SelectItem> selectItems = plainSelect.getSelectItems();

	for (SelectItem selectItem : selectItems) {
		if (selectItem instanceof AllColumns) {
			addAllFromProjections(fromProjections, projections);
		} else if (selectItem instanceof AllTableColumns) {
			AllTableColumns allTableColumns = (AllTableColumns) selectItem;
			Table table = allTableColumns.getTable();

			addAllFromProjectionsOfTable(fromProjections, projections, table);
		} else if (selectItem instanceof SelectExpressionItem) {
			SelectExpressionItem selectExpressionItem = (SelectExpressionItem) selectItem;
			Expression expression = selectExpressionItem.getExpression();

			addExpressionProjection(fromProjections, projections, expression, selectExpressionItem.getAlias());
		}
	}
	
	return projections;
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:24,代码来源:QueryTypeExtractor.java


示例7: test

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
@Test
public void test() {
    Select select = select("select max(name),code,min(aa),nvl(ab,0),heh from user where a > 100");
    List<SelectItem> selectItems = ((PlainSelect) select.getSelectBody()).getSelectItems();
    for (SelectItem item : selectItems) {
        if (item instanceof SelectExpressionItem) {
            Expression exp = ((SelectExpressionItem) item).getExpression();
            if (exp instanceof Function) {
                System.out.println("Function:" + item.toString());
            } else {
                System.out.println("Not a function:" + exp.toString());
            }
        } else {
            System.out.println("Not a function:" + item.toString());
        }
    }
}
 
开发者ID:pagehelper,项目名称:Mybatis-PageHelper,代码行数:18,代码来源:FunctionCountTest.java


示例8: visit

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
@Override
public void visit(SelectExpressionItem selectExpressionItem) {
    selectExpressionItem.getExpression().accept(expressionVisitor);
    if (selectExpressionItem.getAlias() != null) {
        buffer.append(selectExpressionItem.getAlias().toString());
    }

}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:9,代码来源:SelectDeParser.java


示例9: buildSelectFromTableAndExpressions

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
/**
 * Builds select expr1, expr2 from table.
 * @param table
 * @param expr
 * @return 
 */
public static Select buildSelectFromTableAndExpressions(Table table, Expression ... expr) {
	SelectItem[] list = new SelectItem[expr.length];
	for (int i=0;i<expr.length;i++) {
		list[i]=new SelectExpressionItem(expr[i]);
	}
	return buildSelectFromTableAndSelectItems(table, list);
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:14,代码来源:SelectUtils.java


示例10: SQLAggregator

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
public SQLAggregator(List<SelectItem> selectItems, List<Expression> groupByColumnReferences, RecordSetFactory recordSetFactory) throws StatementExecutionException {
    this.recordSetFactory = recordSetFactory;
    this.selectItems = selectItems;
    this.groupByColumnReferences = groupByColumnReferences != null ? groupByColumnReferences : Collections.emptyList();

    for (SelectItem item : selectItems) {
        boolean done = false;
        if (item instanceof SelectExpressionItem) {
            SelectExpressionItem sei = (SelectExpressionItem) item;
            Expression expression = sei.getExpression();
            if (expression instanceof Function) {
                Function f = (Function) expression;
                if (BuiltinFunctions.isAggregateFunction(f.getName())) {
                    done = true;
                }
            } else if (expression instanceof net.sf.jsqlparser.schema.Column) {
                net.sf.jsqlparser.schema.Column c = (net.sf.jsqlparser.schema.Column) expression;
                for (Expression ex : this.groupByColumnReferences) {
                    if (ex instanceof net.sf.jsqlparser.schema.Column) {
                        net.sf.jsqlparser.schema.Column cex = (net.sf.jsqlparser.schema.Column) ex;
                        if (cex.getColumnName().equals(c.getColumnName())) {
                            done = true;
                            break;
                        }
                    }
                }
            }
        }
        if (!done) {
            throw new StatementExecutionException("field " + item + " MUST appear in GROUP BY clause");
        }
    }

}
 
开发者ID:diennea,项目名称:herddb,代码行数:35,代码来源:SQLAggregator.java


示例11: countSelectItem

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
/**
 * <p>
 * 获取jsqlparser中count的SelectItem
 * </p>
 */
private static List<SelectItem> 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);
    List<SelectItem> selectItems = new ArrayList<>();
    SelectExpressionItem selectExpressionItem = new SelectExpressionItem(function);
    selectItems.add(selectExpressionItem);
    return selectItems;
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:20,代码来源:JsqlParserCountOptimize.java


示例12: countSelectItem

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的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<Expression>();
    LongValue longValue = new LongValue(0);
    ExpressionList expressionList = new ExpressionList();
    expressions.add(longValue);
    expressionList.setExpressions(expressions);
    function.setParameters(expressionList);
    countSelectItem = new ArrayList<SelectItem>();
    SelectExpressionItem selectExpressionItem = new SelectExpressionItem(function);
    countSelectItem.add(selectExpressionItem);
    return countSelectItem;
}
 
开发者ID:baomidou,项目名称:hibernate-plus,代码行数:23,代码来源:SqlUtils.java


示例13: testDistinct

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
public void testDistinct() throws JSQLParserException {
	String statement = "SELECT DISTINCT ON (myid) myid, mycol FROM mytable WHERE mytable.col = 9";
	PlainSelect plainSelect = (PlainSelect) ((Select) parserManager.parse(new StringReader(statement))).getSelectBody();
	assertEquals(
		"myid",
		((Column) ((SelectExpressionItem) plainSelect.getDistinct().getOnSelectItems().get(0)).getExpression()).getColumnName());
	assertEquals("mycol", ((Column) ((SelectExpressionItem) plainSelect.getSelectItems().get(1)).getExpression()).getColumnName());
	assertEquals(statement.toUpperCase(), plainSelect.toString().toUpperCase());
}
 
开发者ID:UBOdin,项目名称:jsqlparser,代码行数:10,代码来源:SelectTest.java


示例14: visit

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
@Override
public void visit(SelectExpressionItem item) {
	ColumnParser columnParser = new ColumnParser();
	item.getExpression().accept(columnParser);
	if (columnParser.isSimple()) {
		String columnName = columnParser.getColumnName();
		simpleColumnNames.add(columnName);
		if(item.getAlias() != null){
		    aliases.put(columnName, StringUtils.strip(item.getAlias().getName(), "`").toUpperCase());
		}
	}
}
 
开发者ID:coastland,项目名称:gsp-dba-maven-plugin,代码行数:13,代码来源:ViewAnalyzer.java


示例15: visit

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
public void visit(SelectExpressionItem selectExpressionItem) {
    selectExpressionItem.getExpression().accept(expressionVisitor);
    if (selectExpressionItem.getAlias() != null) {
        buffer.append(" ").append(selectExpressionItem.getAlias().toString());
    }

}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:8,代码来源:SelectDeParser.java


示例16: testDistinct

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
@Test
public void testDistinct() throws JSQLParserException {
    String statement = "SELECT DISTINCT ON (myid) myid, mycol FROM mytable WHERE mytable.col = 9";
    PlainSelect plainSelect = (PlainSelect) ((Select) parserManager.parse(new StringReader(statement))).getSelectBody();
    assertEquals(
            "myid",
            ((Column) ((SelectExpressionItem) plainSelect.getDistinct().getOnSelectItems().get(0)).getExpression()).getColumnName());
    assertEquals("mycol", ((Column) ((SelectExpressionItem) plainSelect.getSelectItems().get(1)).getExpression()).getColumnName());
    assertEquals(statement.toUpperCase(), plainSelect.toString().toUpperCase());
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:11,代码来源:SelectTest.java


示例17: visit

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
@Override
public void visit(SelectExpressionItem selectExpressionItem)
{
   selectExpressionItem.getExpression().accept(this);
   ISqlExpression expression = getExpression();
   SqlSelectItem selectItem = new SqlSelectItem(expression);
   Alias alias = selectExpressionItem.getAlias();
   if (alias != null) {
      String aliasName = removeQuotesIfAny(alias.getName());
      selectItem.setAliasName(aliasName);
   }
   mSelectItems.add(selectItem);
}
 
开发者ID:obidea,项目名称:semantika,代码行数:14,代码来源:SelectItemHandler.java


示例18: getAliasName

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
private String getAliasName(SelectExpressionItem selectExpressionItem)
{
   Alias alias = selectExpressionItem.getAlias();
   if (alias != null) {
      return removeQuotesIfAny(alias.getName());
   }
   return ""; //$NON-NLS-1$ // empty alias name
}
 
开发者ID:obidea,项目名称:semantika,代码行数:9,代码来源:UserQueryHandler.java


示例19: visit

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
@Override
public void visit(SelectExpressionItem sei) {
    String alias = sei.getAlias() != null ? sei.getAlias().getName() : null;
    if (alias != null) {
        selectDef.getColumns().add(alias);
    } else {
        if (sei.getExpression() instanceof Column) {
            Column col = (Column) sei.getExpression();
            selectDef.getColumns().add(CheckExpressionParser.fixColumnName(col.getColumnName()));
        } else {
            throw new QueryException("Complex return expressions must have alias defined: %s", sei.getExpression());
        }
    }
    sei.getExpression().accept(expParser);
}
 
开发者ID:valdasraps,项目名称:resthub,代码行数:16,代码来源:CheckSelectParser.java


示例20: visit

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入依赖的package包/类
@Override
public void visit(SelectExpressionItem selectExpressionItem)
{
	invalid = true;
	super.visit(selectExpressionItem);
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:7,代码来源:DMLWhereClauseVisitorAdapter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ItemReader类代码示例发布时间:2022-05-21
下一篇:
Java Graph类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap