Package com.redspr.redquerybuilder.core.client.util

Examples of com.redspr.redquerybuilder.core.client.util.StatementBuilder


        return filters;
    }

    public String getSQL(List args) {

        StatementBuilder buff = new StatementBuilder("SELECT ");
        // if (distinct) {
        // buff.append("DISTINCT ");
        // }
        if (expressions != null) {
         for (int i = 0; i < expressions.size(); i++) {
         buff.appendExceptFirst(", ");
         buff.append(expressions.get(i).getSQL(args));
         }
        }
        buff.append("\nFROM ");
        TableFilter filter = null;
        if (filters.size() > 0) {
            filter = filters.get(0);
        }
        if (filter != null) {
            buff.resetCount();
            int i = 0;
            do {
            buff.appendExceptFirst("\n");
            buff.append(filter.getSQL(i++ > 0, args));
            filter = filter.getJoin();
            } while (filter != null);
        } else {
         buff.resetCount();
         int i = 0;
         for (TableFilter f : filters) {
         buff.appendExceptFirst("\n");
         buff.append(f.getSQL(i++ > 0, args));
         }
         }
        if (xcondition.getValue() != null) {
            buff.append("\nWHERE ").append(xcondition.getValue().getSQL(args));
        }
        // if (groupIndex != null) {
        // buff.append("\nGROUP BY ");
        // buff.resetCount();
        // for (int gi : groupIndex) {
        // Expression g = exprList[gi];
        // g = g.getNonAliasExpression();
        // buff.appendExceptFirst(", ");
        // buff.append(StringUtils.unEnclose(g.getSQL()));
        // }
        // }
        // if (group != null) {
        // buff.append("\nGROUP BY ");
        // buff.resetCount();
        // for (Expression g : group) {
        // buff.appendExceptFirst(", ");
        // buff.append(StringUtils.unEnclose(g.getSQL()));
        // }
        // }
        // if (having != null) {
        // // could be set in addGlobalCondition
        // // in this case the query is not run directly, just getPlanSQL is
        // // called
        // Expression h = having;
        // buff.append("\nHAVING ").append(StringUtils.unEnclose(h.getSQL()));
        // } else if (havingIndex >= 0) {
        // Expression h = exprList[havingIndex];
        // buff.append("\nHAVING ").append(StringUtils.unEnclose(h.getSQL()));
        // }
        // if (sort != null) {
        // buff.append("\nORDER BY ").append(sort.getSQL(exprList,
        // visibleColumnCount));
        // }
        // if (orderList != null) {
        // buff.append("\nORDER BY ");
        // buff.resetCount();
        // for (SelectOrderBy o : orderList) {
        // buff.appendExceptFirst(", ");
        // buff.append(StringUtils.unEnclose(o.getSQL()));
        // }
        // }
        // if (limitExpr != null) {
        // buff.append("\nLIMIT ").append(StringUtils.unEnclose(limitExpr.getSQL()));
        // if (offsetExpr != null) {
        // buff.append(" OFFSET ").append(StringUtils.unEnclose(offsetExpr.getSQL()));
        // }
        // }
        // if (isForUpdate) {
        // buff.append("\nFOR UPDATE");
        // }
        // if (isQuickAggregateQuery) {
        // buff.append("\n/* direct lookup */");
        // }
        // if (isDistinctQuery) {
        // buff.append("\n/* distinct */");
        // }
        // if (sortUsingIndex) {
        // buff.append("\n/* index sorted */");
        // }
        // if (isGroupQuery) {
        // if (isGroupSortedQuery) {
        // buff.append("\n/* group sorted */");
        // }
        // }
        return buff.toString();
    }
View Full Code Here


    private SQLException getSyntaxError() {
        if (expectedList == null || expectedList.size() == 0) {
            return Message.getSyntaxError(sqlCommand, parseIndex);
        }
        StatementBuilder buff = new StatementBuilder();
        for (String e : expectedList) {
            buff.appendExceptFirst(", ");
            buff.append(e);
        }
        return Message.getSyntaxError(sqlCommand, parseIndex, buff.toString());
    }
View Full Code Here

TOP

Related Classes of com.redspr.redquerybuilder.core.client.util.StatementBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.