⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 expression.java

📁 hsql是很有名的嵌入式数据库
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            case DIVIDE :                buf.append("DIVIDE ");                break;            case CONCAT :                buf.append("CONCAT ");                break;            case NOT :                buf.append("NOT ");                break;            case EQUAL :                buf.append("EQUAL ");                break;            case BIGGER_EQUAL :                buf.append("BIGGER_EQUAL ");                break;            case BIGGER :                buf.append("BIGGER ");                break;            case SMALLER :                buf.append("SMALLER ");                break;            case SMALLER_EQUAL :                buf.append("SMALLER_EQUAL ");                break;            case NOT_EQUAL :                buf.append("NOT_EQUAL ");                break;            case LIKE :                buf.append("LIKE ");                buf.append(likeObject.describe(session));                break;            case AND :                buf.append("AND ");                break;            case OR :                buf.append("OR ");                break;            case ALL :                buf.append("ALL ");                break;            case ANY :                buf.append("ANY ");                break;            case IN :                buf.append("IN ");                break;            case IS_NULL :                buf.append("IS_NULL ");                break;            case EXISTS :                buf.append("EXISTS ");                break;            case COUNT :                buf.append("COUNT ");                break;            case SUM :                buf.append("SUM ");                break;            case MIN :                buf.append("MIN ");                break;            case MAX :                buf.append("MAX ");                break;            case AVG :                buf.append("AVG ");                break;            case EVERY :                buf.append(Token.T_EVERY).append(' ');                break;            case SOME :                buf.append(Token.T_SOME).append(' ');                break;            case STDDEV_POP :                buf.append(Token.T_STDDEV_POP).append(' ');                break;            case STDDEV_SAMP :                buf.append(Token.T_STDDEV_SAMP).append(' ');                break;            case VAR_POP :                buf.append(Token.T_VAR_POP).append(' ');                break;            case VAR_SAMP :                buf.append(Token.T_VAR_SAMP).append(' ');                break;            case CONVERT :                buf.append("CONVERT ");                buf.append(Types.getTypeString(dataType, precision, scale));                buf.append(' ');                break;            case CASEWHEN :                buf.append("CASEWHEN ");                break;        }        if (isInJoin) {            buf.append(" join");        }        if (eArg != null) {            buf.append(" arg1=[");            buf.append(eArg.describe(session, blanks + 1));            buf.append(']');        }        if (eArg2 != null) {            buf.append(" arg2=[");            buf.append(eArg2.describe(session, blanks + 1));            buf.append(']');        }        return buf.toString();    }    /**     * Set the data type     *     *     * @param type data type     */    void setDataType(int type) {        dataType = type;    }    int oldIType = -1;    /**     * When an Expression is assigned to a TableFilter, a copy is made for use     * there and the original is set to Expression.TRUE     *     */    void setTrue() {        if (oldIType == -1) {            oldIType = exprType;        }        exprType = TRUE;    }    void setNull() {        exprType  = VALUE;        dataType  = Types.NULL;        valueData = null;        eArg      = null;        eArg2     = null;    }    /**     * Check if the given expression defines similar operation as this     * expression. This method is used for ensuring an expression in     * the ORDER BY clause has a matching column in the SELECT list. This check     * is necessary with a SELECT DISTINCT query.<br>     *     * In the future we may perform the test when evaluating the search     * condition to get a more accurate match.     *     * @param exp expression     * @return boolean     */    public boolean similarTo(Expression exp) {        if (exp == null) {            return false;        }        if (exp == this) {            return true;        }        /** @todo fredt - equals() method for valueList, subSelect and function are needed */        return exprType == exp.exprType && dataType == exp.dataType               && equals(valueData, exp.valueData)               && equals(valueList, exp.valueList)               && equals(subQuery, exp.subQuery)               && equals(function, exp.function)               && equals(tableName, exp.tableName)               && equals(columnName, exp.columnName)               && similarTo(eArg, exp.eArg) && similarTo(eArg2, exp.eArg2);    }    static boolean equals(Object o1, Object o2) {        return (o1 == null) ? o2 == null                            : o1.equals(o2);    }    static boolean equals(Expression[] ae1, Expression[] ae2) {        if (ae1 == ae2) {            return true;        }        if (ae1.length != ae2.length) {            return false;        }        int     len    = ae1.length;        boolean equals = true;        for (int i = 0; i < len; i++) {            Expression e1 = ae1[i];            Expression e2 = ae2[i];            equals = (e1 == null) ? e2 == null                                  : e1.equals(e2);        }        return equals;    }    static boolean similarTo(Expression e1, Expression e2) {        return (e1 == null) ? e2 == null                            : e1.similarTo(e2);    }/** @todo fredt - workaround for functions in ORDER BY and GROUP BY needs *  checking the argument of the function to ensure they are valid. */    /**     * Check if this expression can be included in a group by clause.     * <p>     * It can, if itself is a column expression, and it is not an aggregate     * expression.     *     * @return boolean     */    boolean canBeInGroupBy() {        if (exprType == FUNCTION) {            return true;        }        return isColumn() && (!(isAggregate()));    }    /**     * Check if this expression can be included in an order by clause.     * <p>     * It can, if itself is a column expression.     *     * @return boolean     */    boolean canBeInOrderBy() {        return exprType == FUNCTION || joinedTableColumnIndex != -1               || isColumn() || isAggregate();    }    /**     * Check if this expression defines at least one column.     * <p>     * It is, if itself is a column expression, or any the argument     * expressions is a column expression.     *     * @return boolean     */    private boolean isColumn() {        switch (exprType) {            case COLUMN :                return true;            case NEGATE :                return eArg.isColumn();            case ADD :            case SUBTRACT :            case MULTIPLY :            case DIVIDE :            case CONCAT :                return eArg.isColumn() || eArg2.isColumn();        }        return false;    }    /**     * Collect column name used in this expression.     *     * @param columnNames set to be filled     * @return true if a column name is used in this expression     */    boolean collectColumnName(HashSet columnNames) {        boolean result = exprType == COLUMN;        if (result) {            columnNames.add(columnName);        }        return result;    }    /**     * Collect all column names used in this expression or any of nested     * expression.     *     * @param columnNames set to be filled     */    void collectAllColumnNames(HashSet columnNames) {        if (!collectColumnName(columnNames)) {            if (eArg != null) {                eArg.collectAllColumnNames(columnNames);            }            if (eArg2 != null) {                eArg2.collectAllColumnNames(columnNames);            }        }    }    /**     * Check if this expression defines a constant value.     * <p>     * It does, if it is a constant value expression, or all the argument     * expressions define constant values.     *     * @return boolean     */    boolean isConstant() {        switch (exprType) {            case VALUE :                return true;            case NEGATE :                return eArg.isConstant();            case ADD :            case SUBTRACT :            case MULTIPLY :            case DIVIDE :            case CONCAT :                return eArg.isConstant() && eArg2.isConstant();        }        return false;    }    /**     * Check if this expression can be included as a result column in an     * aggregated select statement.     * <p>     * It can, if itself is an aggregate expression, or it results a constant     * value.     *     * @return boolean     */    boolean canBeInAggregate() {        return isAggregate() || isConstant();    }    /**     *  Is this (indirectly) an aggregate expression     *     *  @return boolean     */    boolean isAggregate() {        return aggregateSpec != AGGREGATE_NONE;    }    /**     *  Is this directly an aggregate expression     *     *     *  @return boolean     */    boolean isSelfAggregate() {        return aggregateSpec == AGGREGATE_SELF;    }    static boolean isAggregate(int type) {        switch (type) {            case COUNT :            case MAX :            case MIN :            case SUM :            case AVG :            case EVERY :            case SOME :            case STDDEV_POP :            case STDDEV_SAMP :            case VAR_POP :            case VAR_SAMP :                return true;        }        return false;    }// tony_lai@users having    /**     *  Checks for conditional expression.     *     *     *  @return boolean     */    boolean isConditional() {        switch (exprType) {            case TRUE :            case FALSE :            case EQUAL :            case BIGGER_EQUAL :            case BIGGER :            case SMALLER :            case SMALLER_EQUAL :            case NOT_EQUAL :            case LIKE :            case IN :            case EXISTS :            case IS_NULL :                return true;            case NOT :                return eArg.isConditional();            case AND :            case OR :                return eArg.isConditional() && eArg2.isConditional();            default :                return false;        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -