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


Java PlainSelect.getSelectItems方法代码示例

本文整理汇总了Java中net.sf.jsqlparser.statement.select.PlainSelect.getSelectItems方法的典型用法代码示例。如果您正苦于以下问题:Java PlainSelect.getSelectItems方法的具体用法?Java PlainSelect.getSelectItems怎么用?Java PlainSelect.getSelectItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.jsqlparser.statement.select.PlainSelect的用法示例。


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

示例1: visit

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

示例2: visit

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
@Override
public void visit(PlainSelect plainSelect) {
    if (plainSelect.getSelectItems() != null) {
        for (SelectItem item : plainSelect.getSelectItems()) {
            item.accept(this);
        }
    }

    if (plainSelect.getFromItem() != null) {
        plainSelect.getFromItem().accept(this);
    }

    if (plainSelect.getJoins() != null) {
        for (Join join : plainSelect.getJoins()) {
            join.getRightItem().accept(this);
        }
    }
    if (plainSelect.getWhere() != null) {
        plainSelect.getWhere().accept(this);
    }
    if (plainSelect.getOracleHierarchical() != null) {
        plainSelect.getOracleHierarchical().accept(this);
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:25,代码来源:TablesNamesFinder.java

示例3: visit

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
public void visit(PlainSelect plainSelect) {
	List<SelectItem> cols = plainSelect.getSelectItems();
	for(SelectItem col : cols){
		col.accept(this);
	}

	if(plainSelect.getFromItem()!=null){
		plainSelect.getFromItem().accept(this);
	}

	if (plainSelect.getJoins() != null) {
		for (Iterator joinsIt = plainSelect.getJoins().iterator(); joinsIt.hasNext();) {
			Join join = (Join) joinsIt.next();
			join.getRightItem().accept(this);
		}
	}
	if (plainSelect.getWhere() != null)
		plainSelect.getWhere().accept(this);

}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:21,代码来源:TableFinder.java

示例4: createProjections

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

示例5: visit

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
@Override
public void visit(PlainSelect plainSelect) {
    if (plainSelect.getDistinct() != null && plainSelect.getDistinct().getOnSelectItems() != null) {
        plainSelect.getDistinct().getOnSelectItems().forEach(s -> s.accept(this));
    }
    if (plainSelect.getFromItem() != null) {
        plainSelect.getFromItem().accept(this);
    }
    if (plainSelect.getGroupByColumnReferences() != null) {
        plainSelect.getGroupByColumnReferences().forEach(s -> s.accept(this));
    }
    if (plainSelect.getHaving() != null) {
        plainSelect.getHaving().accept(this);
    }
    if (plainSelect.getJoins() != null) {
        plainSelect.getJoins().forEach(
            j -> {
                visitJoin(j);
            }
        );
    }
    if (plainSelect.getOrderByElements() != null) {
        plainSelect.getOrderByElements().forEach(s -> s.accept(this));
    }
    if (plainSelect.getSelectItems() != null) {
        plainSelect.getSelectItems().forEach(s -> s.accept(this));
    }
    if (plainSelect.getTop() != null) {
        plainSelect.getTop().getExpression().accept(this);
    }
    if (plainSelect.getWhere() != null) {
        plainSelect.getWhere().accept(this);
    }
    if (plainSelect.getLimit() != null) {
        visitLimit(plainSelect.getLimit());
    }

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

示例6: optimizeSql

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
@Override
public SqlInfo optimizeSql(MetaObject metaObject, String sql) {
    if (logger.isDebugEnabled()) {
        logger.debug(" JsqlParserCountOptimize sql=" + sql);
    }
    SqlInfo sqlInfo = SqlInfo.newInstance();
    try {
        Select selectStatement = (Select) CCJSqlParserUtil.parse(sql);
        PlainSelect plainSelect = (PlainSelect) selectStatement.getSelectBody();
        Distinct distinct = plainSelect.getDistinct();
        List<Expression> groupBy = plainSelect.getGroupByColumnReferences();
        List<OrderByElement> orderBy = plainSelect.getOrderByElements();

        // 添加包含groupBy 不去除orderBy
        if (CollectionUtils.isEmpty(groupBy) && CollectionUtils.isNotEmpty(orderBy)) {
            plainSelect.setOrderByElements(null);
            sqlInfo.setOrderBy(false);
        }
        //#95 Github, selectItems contains #{} ${}, which will be translated to ?, and it may be in a function: power(#{myInt},2)
        for (SelectItem item : plainSelect.getSelectItems()) {
            if (item.toString().contains("?")) {
                sqlInfo.setSql(String.format(SqlUtils.SQL_BASE_COUNT, selectStatement.toString()));
                return sqlInfo;
            }
        }
        // 包含 distinct、groupBy不优化
        if (distinct != null || CollectionUtils.isNotEmpty(groupBy)) {
            sqlInfo.setSql(String.format(SqlUtils.SQL_BASE_COUNT, selectStatement.toString()));
            return sqlInfo;
        }
        // 优化 SQL
        plainSelect.setSelectItems(countSelectItem);
        sqlInfo.setSql(selectStatement.toString());
        return sqlInfo;
    } catch (Throwable e) {
        // 无法优化使用原 SQL
        sqlInfo.setSql(String.format(SqlUtils.SQL_BASE_COUNT, sql));
        return sqlInfo;
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:41,代码来源:JsqlParserCountOptimize.java

示例7: visit

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void visit(PlainSelect select) {
	if (!CollectionUtils.isEmpty(select.getGroupByColumnReferences())
		|| !CollectionUtils.isEmpty(select.getJoins())) {
		isSimple = false;
	} else {
		select.getFromItem().accept(this);
		for (SelectItem item : (List<SelectItem>) select.getSelectItems()) {
			item.accept(this);
		}
	}
}
 
开发者ID:coastland,项目名称:gsp-dba-maven-plugin,代码行数:14,代码来源:ViewAnalyzer.java

示例8: visit

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
@Override
public void visit(PlainSelect plainSelect) {
    for (Object oItem : plainSelect.getSelectItems()) {
        SelectItem item = (SelectItem) oItem;
        item.accept(this);
    }
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:8,代码来源:ResultsFinder.java

示例9: getSelectItem

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
private SelectItemList getSelectItem(PlainSelect plainSelect)
{
   mSelectItems = new SelectItemList();
   List<SelectItem> selectItemExpressions = plainSelect.getSelectItems();
   for (SelectItem selectItem : selectItemExpressions) {
      selectItem.accept(this);
   }
   return mSelectItems;
}
 
开发者ID:obidea,项目名称:semantika,代码行数:10,代码来源:UserQueryHandler.java

示例10: visit

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
@Override
public void visit(PlainSelect plainSelect)
{
   /*
    * Check if the query uses DISTINCT flag
    */
   checkContainDistinct(plainSelect);
   
   FromItem fromItem = plainSelect.getFromItem();
   visitFromItemExpression(fromItem);
   
   /*
    * Collect the tables in the JOIN statement
    */
   List<Join> joins = plainSelect.getJoins();
   if (joins != null) {
      for (Join join : joins) {
         visitJoinExpression(join);
      }
   }
   
   /*
    * Collect the filter expressions in WHERE statement
    */
   Expression expr = plainSelect.getWhere();
   if (expr != null) {
      visitWhereExpression(expr);
   }
   
   /*
    * Collect the select item expressions in SELECT statement.
    */
   List<SelectItem> selectItemExpressions = plainSelect.getSelectItems();
   SelectItemHandler selectItemHandler = new SelectItemHandler(this);
   selectItemHandler.parse(selectItemExpressions);
}
 
开发者ID:obidea,项目名称:semantika,代码行数:37,代码来源:SelectStatementHandler.java

示例11: visitColumns

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
public void visitColumns(PlainSelect plainSelect){
    columns = plainSelect.getSelectItems();
}
 
开发者ID:qafedev,项目名称:qafe-platform,代码行数:4,代码来源:SelectItemFinder.java

示例12: visitColumns

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
protected void visitColumns(PlainSelect plainSelect){
    columns = plainSelect.getSelectItems();
}
 
开发者ID:qafedev,项目名称:qafe-platform,代码行数:4,代码来源:AbstractItemFinder.java

示例13: visit

import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
/**
 * SelectVisitor
 * @param ps
 */
@Override
public void visit(PlainSelect ps) {
    
    // First collect FROM and JOIN items
    
    ps.getFromItem().accept(this);
    
    if (ps.getJoins() != null) {
        for (Join j : ps.getJoins()) {
            j.getRightItem().accept(this);
            if (j.getOnExpression() != null) {
                j.getOnExpression().accept(expParser);
            }
            if (j.getUsingColumns() != null) {
                for (Iterator<?> it1 = j.getUsingColumns().iterator(); it1.hasNext();) {
                    ((Expression) it1.next()).accept(expParser);
                }
            }
        }
    }
    
   // Next iterate over SELECT, WHERE and ORDER BY items
    
    for (Object o: ps.getSelectItems()) {
        if (o instanceof SelectExpressionItem) {
            ((SelectExpressionItem) o).accept(this);
        }
        if (o instanceof AllColumns) {
            ((AllColumns) o).accept(this);
        }
        if (o instanceof AllTableColumns) {
            ((AllTableColumns) o).accept(this);
        }
    }

    if (ps.getWhere() != null) {
        ps.getWhere().accept(expParser);
    }
    
    if (ps.getOrderByElements() != null) {
        for (Iterator<?> it = ps.getOrderByElements().iterator(); it.hasNext();) {
            ((OrderByElement) it.next()).accept(this);
        }
    }
    
    if (ps.getOracleHierarchical() != null) {
        ps.getOracleHierarchical().accept(expParser);
    }
    
}
 
开发者ID:valdasraps,项目名称:resthub,代码行数:55,代码来源:CheckSelectParser.java


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