本文整理汇总了Java中com.alibaba.druid.sql.ast.SQLExpr.accept方法的典型用法代码示例。如果您正苦于以下问题:Java SQLExpr.accept方法的具体用法?Java SQLExpr.accept怎么用?Java SQLExpr.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.druid.sql.ast.SQLExpr
的用法示例。
在下文中一共展示了SQLExpr.accept方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
@Override
public boolean visit(PGTypeCastExpr x) {
SQLExpr expr = x.getExpr();
if (expr != null) {
if (expr instanceof SQLBinaryOpExpr) {
print('(');
expr.accept(this);
print(')');
} else {
expr.accept(this);
}
}
print0("::");
x.getDataType().accept(this);
return false;
}
示例2: printGrantPrivileges
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
protected void printGrantPrivileges(SQLGrantStatement x) {
List<SQLExpr> privileges = x.getPrivileges();
int i = 0;
for (SQLExpr privilege : privileges) {
if (i != 0) {
print(", ");
}
if (privilege instanceof SQLIdentifierExpr) {
String name = ((SQLIdentifierExpr) privilege).getName();
if ("RESOURCE".equalsIgnoreCase(name)) {
continue;
}
}
privilege.accept(this);
i++;
}
}
示例3: testGroupbyOrder
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
@Test
public void testGroupbyOrder() {
MySqlSelectQueryBlock query = getQuery("select col1,col2 from table1 group by col1 desc,col2 asc ");
SQLSelectGroupByClause groupBy = query.getGroupBy();
int i = 0;
for (SQLExpr p : groupBy.getItems()) {
i++;
String groupCol = "col" + i;
MySqlOrderingExpr groupitem = (MySqlOrderingExpr) p;
SQLExpr q = groupitem.getExpr();
MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset, null);
q.accept(v);
Item item = v.getItem();
Assert.assertEquals(true, groupCol.equals(item.getItemName()));
}
}
示例4: eval
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
final List<SQLExpr> parameters = x.getParameters();
if (parameters.size() == 0) {
return EVAL_ERROR;
}
SQLExpr condition = parameters.get(0);
condition.accept(visitor);
Object itemValue = condition.getAttributes().get(EVAL_VALUE);
if (itemValue == null) {
return null;
}
if (Boolean.TRUE == itemValue || !SQLEvalVisitorUtils.eq(itemValue, 0)) {
SQLExpr trueExpr = parameters.get(1);
trueExpr.accept(visitor);
return trueExpr.getAttributes().get(EVAL_VALUE);
} else {
SQLExpr falseExpr = parameters.get(2);
falseExpr.accept(visitor);
return falseExpr.getAttributes().get(EVAL_VALUE);
}
}
示例5: eval
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
if (x.getParameters().size() != 1) {
return SQLEvalVisitor.EVAL_ERROR;
}
SQLExpr param0 = x.getParameters().get(0);
param0.accept(visitor);
Object param0Value = param0.getAttributes().get(EVAL_VALUE);
if (param0Value == null) {
return SQLEvalVisitor.EVAL_ERROR;
}
if (param0Value instanceof Number) {
long longValue = ((Number) param0Value).longValue();
String result = Long.toString(longValue, 2);
return result;
}
return SQLEvalVisitor.EVAL_ERROR;
}
示例6: eval
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
final List<SQLExpr> parameters = x.getParameters();
if (parameters.size() == 0) {
return EVAL_ERROR;
}
SQLExpr condition = parameters.get(0);
condition.accept(visitor);
Object itemValue = condition.getAttributes().get(EVAL_VALUE);
if (itemValue == EVAL_VALUE_NULL) {
return Boolean.TRUE;
} else if (itemValue == null) {
return null;
} else {
return Boolean.FALSE;
}
}
示例7: eval
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
if (x.getParameters().size() != 1) {
return SQLEvalVisitor.EVAL_ERROR;
}
SQLExpr param0 = x.getParameters().get(0);
param0.accept(visitor);
Object param0Value = param0.getAttributes().get(EVAL_VALUE);
if (param0Value == null) {
return SQLEvalVisitor.EVAL_ERROR;
}
if (param0Value instanceof String) {
return ((String) param0Value).getBytes().length * 8;
}
return SQLEvalVisitor.EVAL_ERROR;
}
示例8: eval
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
if (x.getParameters().size() <= 1) {
return SQLEvalVisitor.EVAL_ERROR;
}
SQLExpr param0 = x.getParameters().get(0);
param0.accept(visitor);
Object param0Value = param0.getAttributes().get(EVAL_VALUE);
int param0IntValue;
if (!(param0Value instanceof Number)) {
return SQLEvalVisitor.EVAL_ERROR;
}
param0IntValue = ((Number) param0Value).intValue();
if (param0IntValue >= x.getParameters().size()) {
return null;
}
SQLExpr item = x.getParameters().get(param0IntValue);
item.accept(visitor);
Object itemValue = item.getAttributes().get(EVAL_VALUE);
return itemValue;
}
示例9: eval
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
if (x.getParameters().size() != 2) {
return SQLEvalVisitor.EVAL_ERROR;
}
SQLExpr param0 = x.getParameters().get(0);
SQLExpr param1 = x.getParameters().get(1);
param0.accept(visitor);
param1.accept(visitor);
Object param0Value = param0.getAttributes().get(EVAL_VALUE);
Object param1Value = param1.getAttributes().get(EVAL_VALUE);
if (param0Value == null || param1Value == null) {
return SQLEvalVisitor.EVAL_ERROR;
}
String strValue0 = param0Value.toString();
String strValue1 = param1Value.toString();
int result = strValue0.indexOf(strValue1) + 1;
return result;
}
示例10: eval
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
if (x.getParameters().size() != 1) {
return SQLEvalVisitor.EVAL_ERROR;
}
SQLExpr param0 = x.getParameters().get(0);
param0.accept(visitor);
Object param0Value = param0.getAttributes().get(EVAL_VALUE);
if (param0Value == null) {
return SQLEvalVisitor.EVAL_ERROR;
}
String strValue = param0Value.toString();
int result = strValue.length();
return result;
}
示例11: getItemName
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public final String getItemName() {
if (itemName == null || itemName.length() == 0) {
SQLExpr expr = toExpression();
StringBuilder sb = new StringBuilder();
MySqlOutputVisitor ov = new MySqlOutputVisitor(sb);
expr.accept(ov);
itemName = sb.toString();
}
return itemName;
}
示例12: visit
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public static boolean visit(SQLEvalVisitor visitor, SQLBetweenExpr x) {
SQLExpr testExpr = unwrap(x.getTestExpr());
testExpr.accept(visitor);
if (!testExpr.getAttributes().containsKey(EVAL_VALUE)) {
return false;
}
Object value = testExpr.getAttribute(EVAL_VALUE);
SQLExpr beginExpr = unwrap(x.getBeginExpr());
beginExpr.accept(visitor);
if (!beginExpr.getAttributes().containsKey(EVAL_VALUE)) {
return false;
}
Object begin = beginExpr.getAttribute(EVAL_VALUE);
if (lt(value, begin)) {
x.getAttributes().put(EVAL_VALUE, x.isNot() ? true : false);
return false;
}
SQLExpr endExpr = unwrap(x.getEndExpr());
endExpr.accept(visitor);
if (!endExpr.getAttributes().containsKey(EVAL_VALUE)) {
return false;
}
Object end = endExpr.getAttribute(EVAL_VALUE);
if (gt(value, end)) {
x.getAttributes().put(EVAL_VALUE, x.isNot() ? true : false);
return false;
}
x.getAttributes().put(EVAL_VALUE, x.isNot() ? false : true);
return false;
}
示例13: testOrderby
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
@Test
public void testOrderby() {
MySqlSelectQueryBlock query = getQuery("select col1,col2 from table1 order by col1 asc, col2 desc ");
SQLOrderBy orderBy = query.getOrderBy();
int i = 0;
for (SQLSelectOrderByItem p : orderBy.getItems()) {
i++;
String orderCol = "col" + i;
SQLExpr expr = p.getExpr();
MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset, null);
expr.accept(v);
Item item = v.getItem();
Assert.assertEquals(true, orderCol.equals(item.getItemName()));
}
}
示例14: isNoSharding
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public static boolean isNoSharding(ServerConnection source, SQLExpr sqlExpr, String contextSchema, StringPtr sqlSchema)
throws SQLException {
SubQueryTableVisitor subQueryTableVisitor = new SubQueryTableVisitor();
sqlExpr.accept(subQueryTableVisitor);
SQLSelect sqlSelect = subQueryTableVisitor.getSQLSelect();
return sqlSelect == null || isNoSharding(source, sqlSelect.getQuery(), new SQLSelectStatement(sqlSelect), contextSchema, sqlSchema);
}
示例15: eval
import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
List<SQLExpr> params = x.getParameters();
int paramSize = params.size();
if (paramSize != 3) {
return SQLEvalVisitor.EVAL_ERROR;
}
SQLExpr param0 = params.get(0);
SQLExpr param1 = params.get(1);
SQLExpr param2 = params.get(2);
param0.accept(visitor);
param1.accept(visitor);
param2.accept(visitor);
Object param0Value = param0.getAttributes().get(EVAL_VALUE);
Object param1Value = param1.getAttributes().get(EVAL_VALUE);
Object param2Value = param2.getAttributes().get(EVAL_VALUE);
if (param0Value == null || param1Value == null || param2Value == null) {
return SQLEvalVisitor.EVAL_ERROR;
}
String strValue0 = param0Value.toString();
int len = ((Number) param1Value).intValue();
String strValue1 = param2Value.toString();
String result = strValue0;
if (result.length() > len) {
return result.substring(0, len);
}
while (result.length() < len) {
result = strValue1 + result;
}
return result;
}