>>> [EMAIL PROTECTED] 8/31/2004 6:12:18 PM >>>
>My view of the code for ParseTreeWalker indicates why there is an
>exception thrown: if you have an ORDER BY clause, but the child nodes
>(in my case UPPER(description) ASC and beginDate DESC and
>lastUpdatedDate DESC) are not present, the STringBuffer created has
no
>content. What is not clear is why this information would be present
>initially, but lost later on.
Can you please refine above statemenrt ? Pr more specifically, what do
you mean when saying 'are not present' ?
*****
Werner -
Thanx for the response.
By "not present", I mean that the only way the StringIndexOutOfBounds
exception can surface is if in the parsed OQL tree there is a ParseNode
of type ORDER BY with no children. Here is the code I am looking at in
ParseTreeWalker:
private String getOrderClause(ParseTreeNode orderClause) {
StringBuffer sb = new StringBuffer();
for (Enumeration e = orderClause.children(); e.hasMoreElements(); )
{
sb.append(", ");
ParseTreeNode curChild = (ParseTreeNode) e.nextElement();
int tokenType = curChild.getToken().getTokenType();
switch ( tokenType ) {
case KEYWORD_ASC:
sb.append( getSQLExpr( curChild.getChild(0) ) ).append( " ASC
" );
break;
case KEYWORD_DESC:
sb.append( getSQLExpr( curChild.getChild(0) ) ).append( "
DESC " );
break;
case DOT: case IDENTIFIER:
sb.append( getSQLExpr( curChild ) ).append( " " );
break;
}
}
//remove the additional comma space at the beginning
sb.deleteCharAt(0).deleteCharAt(0);
return sb.toString();
}
The StringIndexOOB exception is occurring at the line
"sb.deleteCharAt(..." because, obviously, the StringBuffer has had
nothing appended to it. The only way for sb to be empty is if
orderClause.children() has no elements in it - there were no child
nodes. The fact that I get a StringIndexOOB exception is not really the
root cause, just the proximal effect of the OQL parse tree somehow being
in a bad state. Am I missing something in my thinking?
jeff
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user