当前位置: 首页>>代码示例>>Java>>正文


Java SQLEvalVisitor类代码示例

本文整理汇总了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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:27,代码来源:Right.java

示例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);
    }
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:23,代码来源:If.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:21,代码来源:Bin.java

示例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;
    }
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:18,代码来源:Isnull.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:18,代码来源:Greatest.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:26,代码来源:Elt.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:23,代码来源:Instr.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:19,代码来源:Ucase.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:19,代码来源:Length.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:25,代码来源:Ascii.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:18,代码来源:Trim.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:18,代码来源:Least.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:23,代码来源:Reverse.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:20,代码来源:Lcase.java

示例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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:19,代码来源:BitLength.java


注:本文中的com.alibaba.druid.sql.visitor.SQLEvalVisitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。