本文整理汇总了Java中net.sf.jsqlparser.statement.select.SelectExpressionItem.getExpression方法的典型用法代码示例。如果您正苦于以下问题:Java SelectExpressionItem.getExpression方法的具体用法?Java SelectExpressionItem.getExpression怎么用?Java SelectExpressionItem.getExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jsqlparser.statement.select.SelectExpressionItem
的用法示例。
在下文中一共展示了SelectExpressionItem.getExpression方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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");
}
}
}
示例3: 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);
}
示例4: createOutputColumns
import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入方法依赖的package包/类
private static Column[] createOutputColumns(List<SelectItem> selectItems, DataScanner wrapped) throws StatementExecutionException {
Column[] columns = new Column[selectItems.size()];
int i = 0;
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;
String fieldName = f.toString();
if (sei.getAlias() != null && sei.getAlias().getName() != null) {
fieldName = sei.getAlias().getName();
}
if (fieldName == null) {
fieldName = "field" + i;
}
Column aggregated = BuiltinFunctions.toAggregatedOutputColumn(fieldName, f);
if (aggregated != null) {
columns[i] = aggregated;
done = true;
}
} else if (expression instanceof net.sf.jsqlparser.schema.Column) {
net.sf.jsqlparser.schema.Column c = (net.sf.jsqlparser.schema.Column) expression;
String name = c.getColumnName();
boolean found = false;
for (Column co : wrapped.getSchema()) {
if (co.name.equals(name)) {
columns[i] = co;
found = true;
break;
}
}
if (!found) {
throw new StatementExecutionException("cannot find column " + name + " is upstream scanner");
}
done = true;
} else {
throw new StatementExecutionException("unhandled aggregate query selectable item:" + expression);
}
}
i++;
if (!done) {
throw new StatementExecutionException("unhandled aggregate function " + item);
}
}
return columns;
}