/************************************************************************
[40] OrderSpec ::= ExprSingle OrderModifier
[41] OrderModifier ::= ("ascending" | "descending")? (<"empty" "greatest"> | <"empty" "least">)? ("collation" URILiteral)?
************************************************************************/
final public OrderSpec parseOrderSpec() throws ParseException, XQueryException {
final OrderSpec spec;
final XQExpression keyExpr;
String collation = null;
keyExpr = parseExprSingle();
spec = new OrderSpec(keyExpr);
locate(spec);
switch(jj_nt.kind) {
case Ascending:
case Descending:
switch(jj_nt.kind) {
case Ascending:
currentToken = jj_consume_token(Ascending);
break;
case Descending:
currentToken = jj_consume_token(Descending);
spec.setDescending(true);
break;
default:
jj_la1[78] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[79] = jj_gen;
;
}
switch(jj_nt.kind) {
case EmptyGreatest:
case EmptyLeast:
switch(jj_nt.kind) {
case EmptyGreatest:
currentToken = jj_consume_token(EmptyGreatest);
spec.setEmptyGreatest(true);
break;
case EmptyLeast:
currentToken = jj_consume_token(EmptyLeast);
break;
default:
jj_la1[80] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[81] = jj_gen;
;
}
switch(jj_nt.kind) {
case Collation:
currentToken = jj_consume_token(Collation);
currentToken = jj_consume_token(URILiteralToOperator);
collation = unquote(currentToken.image);
if(collation != null) {
try {
URI url = new URI(collation);
spec.setCollation(url);
} catch (URISyntaxException e) {
error("err:XQST0046");
}
}
break;