本文整理汇总了Java中com.alibaba.druid.sql.visitor.SQLEvalVisitor.EVAL_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java SQLEvalVisitor.EVAL_ERROR属性的具体用法?Java SQLEvalVisitor.EVAL_ERROR怎么用?Java SQLEvalVisitor.EVAL_ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.alibaba.druid.sql.visitor.SQLEvalVisitor
的用法示例。
在下文中一共展示了SQLEvalVisitor.EVAL_ERROR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eval
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
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;
}
示例3: eval
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;
}
示例4: eval
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;
}
示例5: eval
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;
}
示例6: eval
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;
}
示例7: eval
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;
}
示例8: eval
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;
}
示例9: eval
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;
}
示例10: eval
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;
}
示例11: eval
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;
}
示例12: eval
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 index = -1;
for (int i = 0; i < strValue.length(); ++i) {
if (!Character.isWhitespace(strValue.charAt(i))) {
index = i;
break;
}
}
if (index <= 0) {
return strValue;
} else {
return strValue.substring(index);
}
}
示例13: eval
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);
if (intValue > strValue.length()) {
return SQLEvalVisitor.EVAL_ERROR;
}
String result = strValue.substring(0, intValue);
return result;
}
示例14: eval
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;
}
示例15: eval
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
if (x.getParameters().size() != 4) {
return SQLEvalVisitor.EVAL_ERROR;
}
SQLExpr param0 = x.getParameters().get(0);
SQLExpr param1 = x.getParameters().get(1);
SQLExpr param2 = x.getParameters().get(2);
SQLExpr param3 = x.getParameters().get(3);
param0.accept(visitor);
param1.accept(visitor);
param2.accept(visitor);
param3.accept(visitor);
Object param0Value = param0.getAttributes().get(EVAL_VALUE);
Object param1Value = param1.getAttributes().get(EVAL_VALUE);
Object param2Value = param2.getAttributes().get(EVAL_VALUE);
Object param3Value = param3.getAttributes().get(EVAL_VALUE);
if (!(param0Value instanceof String)) {
return SQLEvalVisitor.EVAL_ERROR;
}
if (!(param1Value instanceof Number)) {
return SQLEvalVisitor.EVAL_ERROR;
}
if (!(param2Value instanceof Number)) {
return SQLEvalVisitor.EVAL_ERROR;
}
if (!(param3Value instanceof String)) {
return SQLEvalVisitor.EVAL_ERROR;
}
String str = (String) param0Value;
int pos = ((Number) param1Value).intValue();
int len = ((Number) param2Value).intValue();
String newstr = (String) param3Value;
if (pos <= 0) {
return str;
}
if (pos == 1) {
if (len > str.length()) {
return newstr;
}
return newstr + str.substring(len);
}
String first = str.substring(0, pos - 1);
if (pos + len - 1 > str.length()) {
return first + newstr;
}
return first + newstr + str.substring(pos + len - 1);
}