• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Function类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.sf.jsqlparser.expression.Function的典型用法代码示例。如果您正苦于以下问题:Java Function类的具体用法?Java Function怎么用?Java Function使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Function类属于net.sf.jsqlparser.expression包,在下文中一共展示了Function类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: countSelectItem

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
/**
 * 获取jsqlparser中count的SelectItem
 *
 * @return
 */
private static List<SelectItem> countSelectItem() {
    if (CollectionUtils.isNotEmpty(countSelectItem)) {
        return countSelectItem;
    }
    Function function = new Function();
    function.setName("COUNT");
    List<Expression> expressions = new ArrayList<>();
    LongValue longValue = new LongValue(1);
    ExpressionList expressionList = new ExpressionList();
    expressions.add(longValue);
    expressionList.setExpressions(expressions);
    function.setParameters(expressionList);
    countSelectItem = new ArrayList<>();
    SelectExpressionItem selectExpressionItem = new SelectExpressionItem(function);
    countSelectItem.add(selectExpressionItem);
    return countSelectItem;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:23,代码来源:JsqlParserUtils.java


示例2: isSimpleCount

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
/**
 * 是否可以用简单的count查询方式
 *
 * @param select
 * @return
 */
public static boolean isSimpleCount(PlainSelect select) {
    //包含group by的时候不可以
    if (select.getGroupByColumnReferences() != null) {
        return false;
    }
    //包含distinct的时候不可以
    if (select.getDistinct() != null) {
        return false;
    }
    for (SelectItem item : select.getSelectItems()) {
        //select列中包含参数的时候不可以,否则会引起参数个数错误
        if (item.toString().contains("?")) {
            return false;
        }
        //如果查询列中包含函数,也不可以,函数可能会聚合列
        if (item instanceof SelectExpressionItem) {
            if (((SelectExpressionItem) item).getExpression() instanceof Function) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:xushaomin,项目名称:apple-orm,代码行数:30,代码来源:SqlParser.java


示例3: isSimpleCount

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
/**
 * 是否可以用简单的count查询方式
 *
 * @param select
 * @return
 */
public boolean isSimpleCount(PlainSelect select) {
    //包含group by的时候不可以
    if (select.getGroupByColumnReferences() != null) {
        return false;
    }
    //包含distinct的时候不可以
    if (select.getDistinct() != null) {
        return false;
    }
    for (SelectItem item : select.getSelectItems()) {
        //select列中包含参数的时候不可以,否则会引起参数个数错误
        if (item.toString().contains("?")) {
            return false;
        }
        //如果查询列中包含函数,也不可以,函数可能会聚合列
        if (item instanceof SelectExpressionItem) {
            if (((SelectExpressionItem) item).getExpression() instanceof Function) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:xushaomin,项目名称:apple-orm,代码行数:30,代码来源:SqlParser.java


示例4: visit

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
public void visit(Function function) {
    if (function.isEscaped()) {
        buffer.append(function.getCommentBeginEscaped() != null ? function.getCommentBeginEscaped() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append("{fn ");
    }
    buffer.append(function.getCommentName() != null ? function.getCommentName() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append(function.getName());
    if (function.isAllColumns()) {
        buffer.append(function.getCommentBeginEscaped() != null ? function.getCommentBeginBracket() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append("(").append(function.getCommentBeginEscaped() != null ? function.getCommentAllColumns() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append("*").append(function.getCommentBeginEscaped() != null ? function.getCommentEndBracket() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append(")");
    } else if (function.getParameters() == null) {
        buffer.append(function.getCommentBeginEscaped() != null ? function.getCommentBeginBracket() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append("(").append(function.getCommentEndEscaped() != null ? function.getCommentEndBracket() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append(")");
    } else {
        boolean oldUseBracketsInExprList = useBracketsInExprList;
        if (function.isDistinct()) {
            useBracketsInExprList = false;
            buffer.append(function.getCommentBeginEscaped() != null ? function.getCommentBeginBracket() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append("(").append(function.getCommentDistinct() != null ? function.getCommentDistinct() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append("Distinct ");
        }
        visit(function.getParameters());
        useBracketsInExprList = oldUseBracketsInExprList;
        if (function.isDistinct()) {
            buffer.append(function.getCommentBeginEscaped() != null ? function.getCommentEndBracket() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append(")");
        }
    }
    if (function.isEscaped()) {
        buffer.append(function.getCommentEndEscaped() != null ? function.getCommentEndEscaped() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append("}");
    }
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:26,代码来源:ExpressionDeParser.java


示例5: test

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
@Test
public void test() {
    Select select = select("select max(name),code,min(aa),nvl(ab,0),heh from user where a > 100");
    List<SelectItem> selectItems = ((PlainSelect) select.getSelectBody()).getSelectItems();
    for (SelectItem item : selectItems) {
        if (item instanceof SelectExpressionItem) {
            Expression exp = ((SelectExpressionItem) item).getExpression();
            if (exp instanceof Function) {
                System.out.println("Function:" + item.toString());
            } else {
                System.out.println("Not a function:" + exp.toString());
            }
        } else {
            System.out.println("Not a function:" + item.toString());
        }
    }
}
 
开发者ID:pagehelper,项目名称:Mybatis-PageHelper,代码行数:18,代码来源:FunctionCountTest.java


示例6: removeOperations

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
public static String removeOperations(String select){

        Select stmt = asStatement(select);
        SelectBody selectBody = stmt.getSelectBody();

        if (selectBody instanceof PlainSelect) {
            PlainSelect plainSelect = (PlainSelect) selectBody;

            plainSelect.getSelectItems()
                    .removeIf(item ->
                            ((SelectExpressionItem)item).getExpression() instanceof Function);
        }

        return stmt.toString();
    }
 
开发者ID:EMResearch,项目名称:EvoMaster,代码行数:16,代码来源:SelectHeuristics.java


示例7: isAggregateFunction

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
private boolean isAggregateFunction(Expression expression) throws StatementExecutionException {
    if (!(expression instanceof Function)) {
        return false;
    }
    Function function = (Function) expression;
    String name = function.getName().toLowerCase();
    if (BuiltinFunctions.isAggregateFunction(function.getName())) {
        return true;
    }
    if (BuiltinFunctions.isScalarFunction(function.getName())) {
        return false;
    }
    throw new StatementExecutionException("unsupported function " + name);
}
 
开发者ID:diennea,项目名称:herddb,代码行数:15,代码来源:SQLPlanner.java


示例8: SQLAggregator

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
public SQLAggregator(List<SelectItem> selectItems, List<Expression> groupByColumnReferences, RecordSetFactory recordSetFactory) throws StatementExecutionException {
    this.recordSetFactory = recordSetFactory;
    this.selectItems = selectItems;
    this.groupByColumnReferences = groupByColumnReferences != null ? groupByColumnReferences : Collections.emptyList();

    for (SelectItem item : selectItems) {
        boolean done = false;
        if (item instanceof SelectExpressionItem) {
            SelectExpressionItem sei = (SelectExpressionItem) item;
            Expression expression = sei.getExpression();
            if (expression instanceof Function) {
                Function f = (Function) expression;
                if (BuiltinFunctions.isAggregateFunction(f.getName())) {
                    done = true;
                }
            } else if (expression instanceof net.sf.jsqlparser.schema.Column) {
                net.sf.jsqlparser.schema.Column c = (net.sf.jsqlparser.schema.Column) expression;
                for (Expression ex : this.groupByColumnReferences) {
                    if (ex instanceof net.sf.jsqlparser.schema.Column) {
                        net.sf.jsqlparser.schema.Column cex = (net.sf.jsqlparser.schema.Column) ex;
                        if (cex.getColumnName().equals(c.getColumnName())) {
                            done = true;
                            break;
                        }
                    }
                }
            }
        }
        if (!done) {
            throw new StatementExecutionException("field " + item + " MUST appear in GROUP BY clause");
        }
    }

}
 
开发者ID:diennea,项目名称:herddb,代码行数:35,代码来源:SQLAggregator.java


示例9: visit

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
@Override
public void visit(Function function) {
    function.setName(function.getName().toLowerCase());
    if (function.getParameters() != null) {
        function.getParameters().accept(this);
    }
}
 
开发者ID:diennea,项目名称:herddb,代码行数:8,代码来源:JdbcQueryRewriter.java


示例10: toAggregatedOutputColumn

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
public static Column toAggregatedOutputColumn(String fieldName, Function f) {
    if (f.getName().equalsIgnoreCase(BuiltinFunctions.COUNT)) {
        return Column.column(fieldName, ColumnTypes.LONG);
    }
    if (f.getName().equalsIgnoreCase(BuiltinFunctions.SUM) && f.getParameters() != null && f.getParameters().getExpressions() != null && f.getParameters().getExpressions().size() == 1) {
        return Column.column(fieldName, ColumnTypes.LONG);
    }
    if (f.getName().equalsIgnoreCase(BuiltinFunctions.MIN) && f.getParameters() != null && f.getParameters().getExpressions() != null && f.getParameters().getExpressions().size() == 1) {
        return Column.column(fieldName, ColumnTypes.LONG);
    }
    if (f.getName().equalsIgnoreCase(BuiltinFunctions.MAX) && f.getParameters() != null && f.getParameters().getExpressions() != null && f.getParameters().getExpressions().size() == 1) {
        return Column.column(fieldName, ColumnTypes.LONG);
    }
    return null;
}
 
开发者ID:diennea,项目名称:herddb,代码行数:16,代码来源:BuiltinFunctions.java


示例11: getColumnCalculator

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
public static AggregatedColumnCalculator getColumnCalculator(Function f, String fieldName,
    StatementEvaluationContext context) throws StatementExecutionException {
    String functionName = f.getName();
    CompiledSQLExpression firstParam = f.getParameters() == null || f.getParameters().getExpressions() == null || f.getParameters().getExpressions().isEmpty() ? null
        : SQLExpressionCompiler.compileExpression(null, f.getParameters().getExpressions().get(0));
    return getColumnCalculator(functionName, fieldName, firstParam, context);
}
 
开发者ID:diennea,项目名称:herddb,代码行数:8,代码来源:BuiltinFunctions.java


示例12: countSelectItem

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
/**
 * <p>
 * 获取jsqlparser中count的SelectItem
 * </p>
 */
private static List<SelectItem> countSelectItem() {
    Function function = new Function();
    function.setName("COUNT");
    List<Expression> expressions = new ArrayList<>();
    LongValue longValue = new LongValue(1);
    ExpressionList expressionList = new ExpressionList();
    expressions.add(longValue);
    expressionList.setExpressions(expressions);
    function.setParameters(expressionList);
    List<SelectItem> selectItems = new ArrayList<>();
    SelectExpressionItem selectExpressionItem = new SelectExpressionItem(function);
    selectItems.add(selectExpressionItem);
    return selectItems;
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:20,代码来源:JsqlParserCountOptimize.java


示例13: countSelectItem

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
/**
 * 获取jsqlparser中count的SelectItem
 *
 * @return
 */
private static List<SelectItem> countSelectItem() {
    if (CollectionUtils.isNotEmpty(countSelectItem)) {
        return countSelectItem;
    }
    Function function = new Function();
    function.setName("COUNT");
    List<Expression> expressions = new ArrayList<Expression>();
    LongValue longValue = new LongValue(0);
    ExpressionList expressionList = new ExpressionList();
    expressions.add(longValue);
    expressionList.setExpressions(expressions);
    function.setParameters(expressionList);
    countSelectItem = new ArrayList<SelectItem>();
    SelectExpressionItem selectExpressionItem = new SelectExpressionItem(function);
    countSelectItem.add(selectExpressionItem);
    return countSelectItem;
}
 
开发者ID:baomidou,项目名称:hibernate-plus,代码行数:23,代码来源:SqlUtils.java


示例14: getInstance

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
public static Projector getInstance(Expression expression, String alias, QueryTypeExtractor queryTypeExtractor) {
	Projector instance = null;
	if (expression instanceof net.sf.jsqlparser.schema.Column) {
		instance = new ColumnProjector((net.sf.jsqlparser.schema.Column) expression, alias, queryTypeExtractor);
	} else if (expression instanceof Function) {
		instance = new FunctionProjector((Function) expression, alias, queryTypeExtractor);
	} else if (expression instanceof BinaryExpression) {
		instance = new BinaryExpressionProjector((BinaryExpression) expression, alias, queryTypeExtractor);
	} else if (expression instanceof LongValue) {
		instance = new LongProjector(expression, alias, queryTypeExtractor);
	} else if (expression instanceof StringValue) {
		instance = new StringProjector(expression, alias, queryTypeExtractor);
	} else if (expression instanceof DoubleValue) {
		instance = new DoubleProjector(expression, alias, queryTypeExtractor);
	} else if (expression instanceof Parenthesis) {
		instance = new ParenthesisProjector((Parenthesis) expression, queryTypeExtractor);
	} else if (expression instanceof JdbcParameter) {
		instance = new JdbcParameterProjector(queryTypeExtractor);
	} else if (expression instanceof SubSelect) {
		instance = new SubSelectProjector((SubSelect) expression, alias, queryTypeExtractor);
	} else {
		throw new RuntimeException("Not supported");
	}
	
	return instance;
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:27,代码来源:Projector.java


示例15: visit

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
@Override
public void visit(Function fnctn) {
    if (fnctn.getParameters() != null) {
        for (Iterator it = fnctn.getParameters().getExpressions().iterator(); it.hasNext();) {
            ((Expression) it.next()).accept(this);
        }
    }
}
 
开发者ID:valdasraps,项目名称:resthub,代码行数:9,代码来源:AbstractAllParser.java


示例16: visit

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
@Override
public void visit(Function f) {
    super.visit(f);
    if (!ALLOWED_FUNCTIONS.contains(f.getName().trim().toUpperCase())) {
        throw new QueryException("Function is not in the allowed functions list: %s", f.getName());
    }
}
 
开发者ID:valdasraps,项目名称:resthub,代码行数:8,代码来源:CheckExpressionParser.java


示例17: test2

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
@Test
public void test2() {
    Select select = select("select distinct(name) from user where a > 100");
    List<SelectItem> selectItems = ((PlainSelect) select.getSelectBody()).getSelectItems();
    for (SelectItem item : selectItems) {
        if (item instanceof Function) {
            System.out.println("Function:" + item.toString());
        } else {
            System.out.println("Not a function:" + item.toString());
        }
    }
}
 
开发者ID:pagehelper,项目名称:Mybatis-PageHelper,代码行数:13,代码来源:FunctionCountTest.java


示例18: visit

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
@Override
public void visit(Function function)
{
	invalid = true;
	super.visit(function);
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:7,代码来源:DMLWhereClauseVisitorAdapter.java


示例19: getFunction

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
public Function getFunction() {
    return function;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:4,代码来源:FunctionItem.java


示例20: setFunction

import net.sf.jsqlparser.expression.Function; //导入依赖的package包/类
public void setFunction(Function function) {
    this.function = function;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:4,代码来源:FunctionItem.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultObjectWrapperBuilder类代码示例发布时间:2022-05-21
下一篇:
Java GenericParser类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap