public OrderByClause(String query) throws NoTokenFoundException, QueryExpressionException { String clause = Util.clauseIdentifier(query, tokenBefore, tokenAfter).trim(); if (clause.equals("")) throw new QueryExpressionException("Reference of ORDER BY clause exists, but is empty"); int pos = -1; if ((pos = clause.indexOf(" desc")) != -1) this.orderType = DESC_ORDER; else { pos = clause.indexOf(" asc"); this.orderType = ASC_ORDER; } clause = pos == -1 ? clause : clause.substring(0, pos).trim(); // extraindo o ASC ou DESC, se existir ArrayList<String> clauseItem = Util.stringToArrayList(clause.trim(), ','); this.columnItem = new ArrayList<ColumnItem>(); for (int i = 0; i < clauseItem.size(); i++) { // preenche a lista de ColumnItem try { this.columnItem.add(new ColumnItem(clauseItem.get(i))); } catch (InvalidColumnItemException e) { // é constValue, não admitido aqui throw new QueryExpressionException("Invalid ColumnItem in ORDER BY clause"); } } }
public HavingClause(String query) throws NoTokenFoundException, QueryExpressionException { String clause = Util.clauseIdentifier(query, tokenBefore, tokenAfter).trim(); if (clause.equals("")) throw new QueryExpressionException("Reference of HAVING clause exists, but is empty"); this.buildList(clause); }