Methods Summary |
---|
private void | addGroupByItem(java.lang.Object theNode)INTERNAL
Add an Group By Item to this node
getGroupByItems().add(theNode);
|
public void | addGroupingToQuery(oracle.toplink.essentials.queryframework.ObjectLevelReadQuery theQuery, oracle.toplink.essentials.internal.parsing.GenerationContext context)INTERNAL
Add the grouping expressions to the passed query
if (theQuery.isReportQuery()) {
Iterator iter = getGroupByItems().iterator();
while (iter.hasNext()) {
Node nextNode = (Node)iter.next();
((ReportQuery)theQuery).addGrouping(nextNode.generateExpression(context));
}
}
|
public java.lang.String | getAsString()INTERNAL
Get the string representation of this node.
StringBuffer repr = new StringBuffer();
for (Iterator i = groupByItems.iterator(); i.hasNext(); ) {
Node expr = (Node)i.next();
if (repr.length() > 0) {
repr.append(", ");
}
repr.append(expr.getAsString());
}
return "GROUP BY " + repr.toString();
|
public java.util.List | getGroupByItems()INTERNAL
Return the GROUP BY statements
if (groupByItems == null) {
setGroupByItems(new Vector());
}
return groupByItems;
|
private boolean | isGroupbyItem(oracle.toplink.essentials.internal.parsing.Node expr)INTERNAL
Return true if the specified expr is a groupby item.
if (expr.isDotNode() || expr.isVariableNode()) {
String exprRepr = expr.getAsString();
for (Iterator i = groupByItems.iterator(); i.hasNext();) {
Node item = (Node)i.next();
String itemRepr = item.getAsString();
if (exprRepr.equals(itemRepr)) {
return true;
}
}
}
return false;
|
public boolean | isValidHavingExpr(oracle.toplink.essentials.internal.parsing.Node expr)INTERNAL
Returns true if the sp
if (expr.isDotNode() || expr.isVariableNode()) {
return isGroupbyItem(expr);
} else {
// delegate to child node if any
Node left = expr.getLeft();
Node right = expr.getRight();
return ((left == null) || isValidHavingExpr(left)) &&
((right == null) || isValidHavingExpr(right));
}
|
private boolean | isValidSelectExpr(oracle.toplink.essentials.internal.parsing.Node expr)INTERNAL
Returns true if the specified expr is a valid SELECT clause expression.
if (expr.isAggregateNode()) {
return true;
} else if (expr.isConstructorNode()) {
List args = ((ConstructorNode)expr).getConstructorItems();
for (Iterator i = args.iterator(); i.hasNext(); ) {
Node arg = (Node)i.next();
if (!isValidSelectExpr(arg)) {
return false;
}
}
return true;
}
return isGroupbyItem(expr);
|
public void | setGroupByItems(java.util.List newItems)INTERNAL
Set the GROUP BY statements
groupByItems = newItems;
|
public void | validate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context, oracle.toplink.essentials.internal.parsing.SelectNode selectNode)INTERNAL
Validate the current node.
for (Iterator i = groupByItems.iterator(); i.hasNext(); ) {
Node item = (Node)i.next();
item.validate(context);
}
List selectExprs = selectNode.getSelectExpressions();
// check select expressions
for (Iterator i = selectExprs.iterator(); i.hasNext(); ) {
Node selectExpr = (Node)i.next();
if (!isValidSelectExpr(selectExpr)) {
throw EJBQLException.invalidSelectForGroupByQuery(
context.getQueryInfo(),
selectExpr.getLine(), selectExpr.getColumn(),
selectExpr.getAsString(), getAsString());
}
}
|