本文整理汇总了Java中com.alibaba.druid.sql.ast.SQLOrderingSpecification类的典型用法代码示例。如果您正苦于以下问题:Java SQLOrderingSpecification类的具体用法?Java SQLOrderingSpecification怎么用?Java SQLOrderingSpecification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLOrderingSpecification类属于com.alibaba.druid.sql.ast包,在下文中一共展示了SQLOrderingSpecification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildOrderByCols
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
protected LinkedHashMap<String, Integer> buildOrderByCols(List<SQLSelectOrderByItem> orderByItems,Map<String, String> aliaColumns) {
LinkedHashMap<String, Integer> map = new LinkedHashMap<String, Integer>();
for(int i= 0; i < orderByItems.size(); i++) {
SQLOrderingSpecification type = orderByItems.get(i).getType();
//orderColumn只记录字段名称,因为返回的结果集是不带表名的。
SQLExpr expr = orderByItems.get(i).getExpr();
String col;
if (expr instanceof SQLName) {
col = ((SQLName)expr).getSimpleName();
}
else {
col =expr.toString();
}
if(type == null) {
type = SQLOrderingSpecification.ASC;
}
col=getAliaColumn(aliaColumns,col);//此步骤得到的col必须是不带.的,有别名的用别名,无别名的用字段名
map.put(col, type == SQLOrderingSpecification.ASC ? OrderCol.COL_ORDER_TYPE_ASC : OrderCol.COL_ORDER_TYPE_DESC);
}
return map;
}
示例2: TwoTableComparator
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public TwoTableComparator(List<FieldPacket> fps1, List<FieldPacket> fps2, List<Order> leftOrders,
List<Order> rightOrders, boolean isAllPushDown, DMLResponseHandler.HandlerType type) {
this.leftFields = HandlerTool.createFields(fps1);
this.rightFields = HandlerTool.createFields(fps2);
ascList = new ArrayList<>();
for (Order order : leftOrders) {
ascList.add(order.getSortOrder() == SQLOrderingSpecification.ASC);
}
comparators = new ArrayList<>();
for (int index = 0; index < ascList.size(); index++) {
Order leftOrder = leftOrders.get(index);
Order rightOrder = rightOrders.get(index);
Item leftCmpItem = HandlerTool.createItem(leftOrder.getItem(), leftFields, 0, isAllPushDown, type);
Item rightCmpItem = HandlerTool.createItem(rightOrder.getItem(), rightFields, 0, isAllPushDown,
type);
ArgComparator comparator = new ArgComparator(leftCmpItem, rightCmpItem);
comparator.setCmpFunc(null, leftCmpItem, rightCmpItem, false);
comparators.add(comparator);
}
}
示例3: RowDataComparator
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public RowDataComparator(List<FieldPacket> fps, List<Order> orders, boolean allPushDown, DMLResponseHandler.HandlerType type) {
sourceFields = HandlerTool.createFields(fps);
if (orders != null && orders.size() > 0) {
ascList = new ArrayList<>();
cmpFields = new ArrayList<>();
cmpItems = new ArrayList<>();
for (Order order : orders) {
Item cmpItem = HandlerTool.createItem(order.getItem(), sourceFields, 0, allPushDown, type);
cmpItems.add(cmpItem);
FieldPacket tmpFp = new FieldPacket();
cmpItem.makeField(tmpFp);
Field cmpField = HandlerTool.createField(tmpFp);
cmpFields.add(cmpField);
ascList.add(order.getSortOrder() == SQLOrderingSpecification.ASC);
}
}
}
示例4: reverseAppendTo
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
private void reverseAppendTo(SQLSelectOrderByItem order, SQLServerOutputVisitor visitor, String tmpTableAlias, List<SQLSelectItem> items) {
SQLExpr expression=order.getExpr();
if(expression instanceof SQLPropertyExpr){
SQLPropertyExpr c=(SQLPropertyExpr)expression;
if(items!=null){
fixWithSelects(c,items);
}
if(c.getOwner()!=null){
c.setOwner(new SQLIdentifierExpr(tmpTableAlias));
}
}
expression.accept(visitor);
if(order.getType()==SQLOrderingSpecification.ASC || order.getType()==null){
try {
visitor.getAppender().append(" DESC");
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例5: getSQLExprToAsc
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
private String getSQLExprToAsc(SQLOrderingSpecification ASC){
if (ASC==null ) {
return " ASC ";
}
if (ASC==SQLOrderingSpecification.DESC){
return " DESC ";
}
else {
return " ASC ";
}
}
示例6: getSQLExprToAsc
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
private int getSQLExprToAsc(SQLOrderingSpecification ASC){
if (ASC==null ) {
return 1;
}
if (ASC==SQLOrderingSpecification.DESC){
return -1;
}
else {
return 1;
}
}
示例7: orderBy
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public PlanNode orderBy(Item c, SQLOrderingSpecification sortOrder) {
if (sortOrder == null) {
sortOrder = SQLOrderingSpecification.ASC;
}
Order order = new Order(c, sortOrder);
if (!this.orderBys.contains(order)) {
this.orderBys.add(order);
}
return this;
}
示例8: makeOrder
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
/**
* make order by from distinct
*
* @param selects
* @return
*/
public static List<Order> makeOrder(List<Item> selects) {
List<Order> orders = new ArrayList<>();
for (Item sel : selects) {
Order order = new Order(sel, SQLOrderingSpecification.ASC);
orders.add(order);
}
return orders;
}
示例9: buildOrderbyType
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public static OrderbyType buildOrderbyType(SQLOrderingSpecification type){
if (SQLOrderingSpecification.ASC == type){
return OrderbyType.ASC;
}
if (SQLOrderingSpecification.DESC == type){
return OrderbyType.DESC;
}
return OrderbyType.ASC;
}
示例10: getType
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public SQLOrderingSpecification getType() {
return this.type;
}
示例11: setType
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public void setType(SQLOrderingSpecification type) {
this.type = type;
}
示例12: MySqlOrderingExpr
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public MySqlOrderingExpr(SQLExpr expr, SQLOrderingSpecification type){
super();
setExpr(expr);
this.type = type;
}
示例13: getType
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public SQLOrderingSpecification getType() {
return type;
}
示例14: Order
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public Order(Item item) {
this(item, SQLOrderingSpecification.ASC);
}
示例15: getSortOrder
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public SQLOrderingSpecification getSortOrder() {
return sortOrder;
}