本文整理汇总了Java中net.sf.jsqlparser.statement.select.FromItem类的典型用法代码示例。如果您正苦于以下问题:Java FromItem类的具体用法?Java FromItem怎么用?Java FromItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FromItem类属于net.sf.jsqlparser.statement.select包,在下文中一共展示了FromItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processPlainSelect
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的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());
}
}
}
示例2: builderExpression
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的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);
}
}
示例3: getEntityAlias
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
protected static String getEntityAlias(String entityName, PlainSelect query) {
FromItem fromItem = query.getFromItem();
if (hasEntityAlias(entityName, fromItem)) {
return fromItem.getAlias();
}
if (query.getJoins() != null) {
for (Object o : query.getJoins()) {
Join join = (Join) o;
if (hasEntityAlias(entityName, join.getRightItem())) {
return join.getRightItem().getAlias();
}
}
}
logger.debug("Alias from entity " + entityName + " not found in query " + query);
return null;
}
示例4: SubJoin
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
final public FromItem SubJoin() throws ParseException {
FromItem fromItem = null;
Join join = null;
SubJoin subJoin = new SubJoin();
fromItem = FromItem();
subJoin.setLeft(fromItem);
join = JoinerExpression();
subJoin.setJoin(join);
{if (true) return subJoin;}
throw new Error("Missing return statement in function");
}
示例5: parseTable
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
private Set<String> parseTable(FromItem fromItem) {
Set<String> tableSet = new HashSet<String>();
if (fromItem instanceof Table) {
Table table = (Table) fromItem;
tableSet.add(table.getName());
} else if (fromItem instanceof SubSelect) {
SubSelect subSelect = (SubSelect) fromItem;
tableSet.addAll(parse(subSelect.getSelectBody()));
}
return tableSet;
}
示例6: SubJoin
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
final public SubJoin SubJoin() throws ParseException {FromItem fromItem = null;
Join join = null;
SubJoin subJoin = new SubJoin();
fromItem = FromItem();
subJoin.setLeft(fromItem);
join = JoinerExpression();
subJoin.setJoin(join);
{if ("" != null) return subJoin;}
throw new Error("Missing return statement in function");
}
示例7: getFromProjectionItems
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
private List<ProjectionItem> getFromProjectionItems(FromItem fromItem, List<Join> joins) throws NoSuchTableException, AmbiguousCoalesceException {
List<ProjectionItem> fromProjections = Lists.newArrayList();
List<FromItem> fromSources = Lists.newArrayList();
fromSources.add(fromItem);
// add the joins
if (joins != null) {
for (Join join : joins) {
fromSources.add(join.getRightItem());
}
}
for (FromItem fromSource : fromSources) {
if (fromSource instanceof Table) {
fromProjections.addAll(getColumnsFromTable((Table) fromSource));
} else if (fromSource instanceof SubSelect) {
fromProjections.addAll(getColumnsFromSubSelect((SubSelect) fromSource));
} else if (fromSource == null) {
// do nothing
} else {
throw new RuntimeException("Not supported");
}
}
return fromProjections;
}
示例8: visit
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的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);
}
示例9: SubJoin
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
final public FromItem SubJoin() throws ParseException {
/* @bgen(jjtree) SubJoin */
SimpleNode jjtn000 = new SimpleNode(JJTSUBJOIN);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
FromItem fromItem = null;
Join join = null;
SubJoin subJoin = new SubJoin();
try {
fromItem = FromItem();
subJoin.setLeft(fromItem);
join = JoinerExpression();
subJoin.setJoin(join);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
{
if (true)
return subJoin;
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{
if (true)
throw (RuntimeException) jjte000;
}
}
if (jjte000 instanceof ParseException) {
{
if (true)
throw (ParseException) jjte000;
}
}
{
if (true)
throw (Error) jjte000;
}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
throw new Error("Missing return statement in function");
}
示例10: getFromItem
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
public FromItem getFromItem() {
return fromItem;
}
示例11: setFromItem
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
public void setFromItem(FromItem fromItem) {
this.fromItem = fromItem;
}
示例12: deparseJoin
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
public void deparseJoin(Join join) {
if (join.isSimple()) {
buffer.append(", ");
} else {
if (join.isRight()) {
buffer.append(" RIGHT");
} else if (join.isNatural()) {
buffer.append(" NATURAL");
} else if (join.isFull()) {
buffer.append(" FULL");
} else if (join.isLeft()) {
buffer.append(" LEFT");
} else if (join.isCross()) {
buffer.append(" CROSS");
}
if (join.isOuter()) {
buffer.append(" OUTER");
} else if (join.isInner()) {
buffer.append(" INNER");
} else if (join.isSemi()) {
buffer.append(" SEMI");
}
buffer.append(" JOIN ");
}
FromItem fromItem = join.getRightItem();
fromItem.accept(this);
if (join.getOnExpression() != null) {
buffer.append(" ON ");
join.getOnExpression().accept(expressionVisitor);
}
if (join.getUsingColumns() != null) {
buffer.append(" USING (");
for (Iterator<Column> iterator = join.getUsingColumns().iterator(); iterator.hasNext();) {
Column column = iterator.next();
buffer.append(column.toString());
if (iterator.hasNext()) {
buffer.append(", ");
}
}
buffer.append(")");
}
}
示例13: FromItem
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
final public FromItem FromItem() throws ParseException {
FromItem fromItem = null;
String alias = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 80:
jj_consume_token(80);
if (jj_2_7(2147483647)) {
fromItem = SubJoin();
} else {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case K_SELECT:
case 80:
fromItem = SubSelect();
break;
default:
jj_la1[58] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
jj_consume_token(81);
break;
case K_KEY:
case K_END:
case K_BEGIN:
case S_IDENTIFIER:
case S_QUOTED_IDENTIFIER:
fromItem = Table();
break;
default:
jj_la1[59] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case K_AS:
case K_KEY:
case K_END:
case K_BEGIN:
case S_IDENTIFIER:
case S_QUOTED_IDENTIFIER:
alias = Alias();
fromItem.setAlias(alias);
break;
default:
jj_la1[60] = jj_gen;
;
}
{if (true) return fromItem;}
throw new Error("Missing return statement in function");
}
示例14: FromItem
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
final public FromItem FromItem() throws ParseException {FromItem fromItem = null;
Alias alias = null;
String commentBeginBrakcet = null;
Token tk = null;
SubJoin subJoin = null;
SubSelect subSel = null;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LPAREN:{
tk = jj_consume_token(LPAREN);
if (tk.specialToken != null) {
commentBeginBrakcet=tk.specialToken.image;
}
if (jj_2_7(2147483647)) {
subJoin = SubJoin();
subJoin.setCommentBeginBracket(commentBeginBrakcet);
} else {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case K_SELECT:
case LPAREN:{
subSel = SubSelect();
subSel.setCommentBeginBracket(commentBeginBrakcet);
break;
}
default:
jj_la1[62] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
tk = jj_consume_token(RPAREN);
if (tk.specialToken != null) {
if (subJoin != null) {
subJoin.setCommentEndBracket(tk.specialToken.image);
} else {
if (subSel != null) {
subSel.setCommentEndBracket(tk.specialToken.image);
}
}
}
fromItem = subJoin != null ? subJoin : subSel;
break;
}
case S_IDENTIFIER:
case S_QUOTED_IDENTIFIER:{
fromItem = Table();
break;
}
default:
jj_la1[63] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case K_AS:
case S_IDENTIFIER:
case S_QUOTED_IDENTIFIER:{
alias = Alias();
fromItem.setAlias(alias);
break;
}
default:
jj_la1[64] = jj_gen;
;
}
{if ("" != null) return fromItem;}
throw new Error("Missing return statement in function");
}
示例15: getSourcesMap
import net.sf.jsqlparser.statement.select.FromItem; //导入依赖的package包/类
public static Map<String, FromItem> getSourcesMap(TO_CASE toCase, SelectBody aSelectBody) {
SourcesFinder instance = new SourcesFinder(toCase);
aSelectBody.accept(instance);
return instance.sources;
}