net.sf.jsqlparser.expression.Alias类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(474)

本文整理了Java中net.sf.jsqlparser.expression.Alias类的一些代码示例,展示了Alias类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Alias类的具体详情如下:
包路径:net.sf.jsqlparser.expression.Alias
类名称:Alias

Alias介绍

暂无

代码示例

代码示例来源:origin: baomidou/mybatis-plus

/**
   * 租户字段别名设置
   * <p>tableName.tenantId 或 tableAlias.tenantId</p>
   *
   * @param table 表对象
   * @return 字段
   */
  protected Column getAliasColumn(Table table) {
    StringBuilder column = new StringBuilder();
    if (null == table.getAlias()) {
      column.append(table.getName());
    } else {
      column.append(table.getAlias().getName());
    }
    column.append(StringPool.DOT);
    column.append(tenantHandler.getTenantIdColumn());
    return new Column(column.toString());
  }
}

代码示例来源:origin: JSQLParser/JSqlParser

@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;
        }
      }
    }
  }
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-obdalib-core

@Override
  public void visit(SelectExpressionItem selectExpr) {
    Alias alias = selectExpr.getAlias();
    if (alias  != null) {
      Expression e = selectExpr.getExpression();
      e.accept(expressionVisitor);
      
      // NORMALIZE EXPRESSION ALIAS NAME
      QuotedID aliasName = idfac.createAttributeID(alias.getName());
      alias.setName(aliasName.getSQLRendering());
      aliasMap.put(aliasName, e);
    }
    // ELSE
    // ROMAN (27 Sep 2015): set an error flag -- each complex expression must have a name (alias)
  }
};

代码示例来源:origin: Quetzal-RDF/quetzal

res.getAlias().setUseAs(useASInTableAlias);
    res.getAlias().setUseAs(useASInTableAlias);
      } else {
        assert plainSelect.getFromItem().getAlias()!=null;
        leftTable = new Table(plainSelect.getFromItem().getAlias().getName());
      } else {
        assert join.getRightItem().getAlias()!=null;
        rightTable = new Table(join.getRightItem().getAlias().getName());

代码示例来源:origin: JSQLParser/JSqlParser

@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));
}

代码示例来源:origin: diennea/herddb

@Override
public void visit(Table tableName) {
  if (tableName == null) {
    return;
  }
  String name = tableName.getName();
  if (name != null) {
    tableName.setName(CompatibilityUtils.fixMySqlName(name.toLowerCase()));
  }
  Alias alias = tableName.getAlias();
  if (alias != null) {
    String aliasName = alias.getName();
    if (aliasName != null) {
      alias.setName(CompatibilityUtils.fixMySqlName(aliasName.toLowerCase()));
    }
  }
}

代码示例来源:origin: pagehelper/Mybatis-PageHelper

/**
 * 包装SetOperationList
 *
 * @param setOperationList
 * @return
 */
protected SelectBody wrapSetOperationList(SetOperationList setOperationList) {
  //获取最后一个plainSelect
  SelectBody setSelectBody = setOperationList.getSelects().get(setOperationList.getSelects().size() - 1);
  if (!(setSelectBody instanceof PlainSelect)) {
    throw new PageException("目前无法处理该SQL,您可以将该SQL发送给abel533@gmail.com协助作者解决!");
  }
  PlainSelect plainSelect = (PlainSelect) setSelectBody;
  PlainSelect selectBody = new PlainSelect();
  List<SelectItem> selectItems = getSelectItems(plainSelect);
  selectBody.setSelectItems(selectItems);
  //设置fromIterm
  SubSelect fromItem = new SubSelect();
  fromItem.setSelectBody(setOperationList);
  fromItem.setAlias(new Alias(WRAP_TABLE));
  selectBody.setFromItem(fromItem);
  //order by
  if (isNotEmptyList(plainSelect.getOrderByElements())) {
    selectBody.setOrderByElements(plainSelect.getOrderByElements());
    plainSelect.setOrderByElements(null);
  }
  return selectBody;
}

代码示例来源:origin: JSQLParser/JSqlParser

/**
 * Get name with out without using aliases.
 *
 * @param aliases
 * @return
 */
public String getName(boolean aliases) {
  StringBuilder fqn = new StringBuilder();
  if (table != null) {
    if (table.getAlias() != null && aliases) {
      fqn.append(table.getAlias().getName());
    } else {
      fqn.append(table.getFullyQualifiedName());
    }
  }
  if (fqn.length() > 0) {
    fqn.append('.');
  }
  if (columnName != null) {
    fqn.append(columnName);
  }
  return fqn.toString();
}

代码示例来源:origin: pagehelper/Mybatis-PageHelper

aliases.add(alias.getName());
Alias alias = selectExpressionItem.getAlias();
if (alias != null) { // 查询列含有别名时用查询列别名
  iterator.set(cloneOrderByElement(orderByElement, alias.getName()));
item.setAlias(new Alias(aliasName));
autoItems.add(item);

代码示例来源:origin: JSQLParser/JSqlParser

throw new ParseException();
return new Alias(name,useAs);

代码示例来源:origin: JSQLParser/JSqlParser

@Override
public void visit(Column tableColumn) {
  final Table table = tableColumn.getTable();
  String tableName = null;
  if (table != null) {
    if (table.getAlias() != null) {
      tableName = table.getAlias().getName();
    } else {
      tableName = table.getFullyQualifiedName();
    }
  }
  if (tableName != null && !tableName.isEmpty()) {
    buffer.append(tableName).append(".");
  }
  buffer.append(tableColumn.getColumnName());
}

代码示例来源:origin: com.github.jsqlparser/jsqlparser

@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;
        }
      }
    }
  }
}

代码示例来源:origin: JSQLParser/JSqlParser

table.setAlias(new Alias(name,useAs));
   break;

代码示例来源:origin: pagehelper/Mybatis-PageHelper

if (selectExpressionItem.getAlias() != null) {
  Column column = new Column(selectExpressionItem.getAlias().getName());
  SelectExpressionItem expressionItem = new SelectExpressionItem(column);
  selectItems.add(expressionItem);

代码示例来源:origin: com.hand.hap.cloud/hap-mybatis-mapper-starter

aliases.add(alias.getName());
Alias alias = selectExpressionItem.getAlias();
if (alias != null) { // 查询列含有别名时用查询列别名
  iterator.set(cloneOrderByElement(orderByElement, alias.getName()));
item.setAlias(new Alias(aliasName));
autoItems.add(item);

代码示例来源:origin: com.github.jsqlparser/jsqlparser

@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));
}

代码示例来源:origin: baomidou/mybatis-plus

Expression rightExpression = ((BinaryExpression) expression).getRightExpression();
if (joinTable != null && rightExpression instanceof Column) {
  if (Objects.equals(((Column) rightExpression).getTable().getName(), table.getAlias().getName())) {
    validUseIndex(table, ((Column) rightExpression).getColumnName(), connection);
    validUseIndex(joinTable, ((Column) leftExpression).getColumnName(), connection);

代码示例来源:origin: com.github.pagehelper/pagehelper

aliases.add(alias.getName());
Alias alias = selectExpressionItem.getAlias();
if (alias != null) { // 查询列含有别名时用查询列别名
  iterator.set(cloneOrderByElement(orderByElement, alias.getName()));
item.setAlias(new Alias(aliasName));
autoItems.add(item);

代码示例来源:origin: com.intoverflow.booster/booster-core

@Override
  public void visit(Column column) {
    Table table = column.getTable();
    if (table == null || StringUtils.isBlank(table.getName())) {
      Table t = new Table(tableName);
      if (tableAlias != null) {
        t.setAlias(new Alias(tableAlias, false));
      }
      column.setTable(t);
    }
  }
});

代码示例来源:origin: Blazebit/blaze-persistence

private Table findTable(List<Table> tables, String alias) {
  for (Table t : tables) {
    if (alias.equals(t.getAlias().getName())) {
      return t;
    }
  }
  return null;
}

相关文章