本文整理汇总了Java中com.alibaba.druid.sql.visitor.SQLEvalVisitor类的典型用法代码示例。如果您正苦于以下问题:Java SQLEvalVisitor类的具体用法?Java SQLEvalVisitor怎么用?Java SQLEvalVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SQLEvalVisitor类属于com.alibaba.druid.sql.visitor包,在下文中一共展示了SQLEvalVisitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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 strValue = param0Value.toString();
int intValue = SQLEvalVisitorUtils.castToInteger(param1Value);
int start = strValue.length() - intValue;
if (start < 0) {
start = 0;
}
String result = strValue.substring(start, strValue.length());
return result;
}
示例2: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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);
}
}
示例3: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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;
}
示例4: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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;
}
}
示例5: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
Object result = null;
for (SQLExpr item : x.getParameters()) {
item.accept(visitor);
Object itemValue = item.getAttributes().get(EVAL_VALUE);
if (result == null) {
result = itemValue;
} else {
if (SQLEvalVisitorUtils.gt(itemValue, result)) {
result = itemValue;
}
}
}
return result;
}
示例6: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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;
}
示例7: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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;
}
示例8: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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();
String result = strValue.toUpperCase();
return result;
}
示例9: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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;
}
示例10: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
if (x.getParameters().size() == 0) {
return SQLEvalVisitor.EVAL_ERROR;
}
SQLExpr param = x.getParameters().get(0);
param.accept(visitor);
Object paramValue = param.getAttributes().get(EVAL_VALUE);
if (paramValue == null) {
return SQLEvalVisitor.EVAL_ERROR;
}
if (paramValue == EVAL_VALUE_NULL) {
return EVAL_VALUE_NULL;
}
String strValue = paramValue.toString();
if (strValue.length() == 0) {
return 0;
}
int ascii = strValue.charAt(0);
return ascii;
}
示例11: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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();
String result = strValue.trim();
return result;
}
示例12: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
Object result = null;
for (SQLExpr item : x.getParameters()) {
item.accept(visitor);
Object itemValue = item.getAttributes().get(EVAL_VALUE);
if (result == null) {
result = itemValue;
} else {
if (SQLEvalVisitorUtils.lt(itemValue, result)) {
result = itemValue;
}
}
}
return result;
}
示例13: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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();
StringBuilder buf = new StringBuilder();
for (int i = strValue.length() - 1; i >= 0; --i) {
buf.append(strValue.charAt(i));
}
String result = buf.toString();
return result;
}
示例14: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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();
String result = strValue.toLowerCase();
return result;
}
示例15: eval
import com.alibaba.druid.sql.visitor.SQLEvalVisitor; //导入依赖的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;
}