use of org.eclipse.rdf4j.query.parser.serql.ast.ASTQueryBody in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public TupleExpr visit(ASTSelectQuery node, Object data) throws VisitorException {
TupleExpr tupleExpr;
ASTQueryBody queryBodyNode = node.getQueryBody();
if (queryBodyNode != null) {
// Build tuple expression for query body
tupleExpr = (TupleExpr) queryBodyNode.jjtAccept(this, null);
} else {
tupleExpr = new SingletonSet();
}
// Apply result ordering
ASTOrderBy orderByNode = node.getOrderBy();
if (orderByNode != null) {
List<OrderElem> orderElemements = (List<OrderElem>) orderByNode.jjtAccept(this, null);
tupleExpr = new Order(tupleExpr, orderElemements);
}
// Apply projection
tupleExpr = (TupleExpr) node.getSelectClause().jjtAccept(this, tupleExpr);
// process limit and offset clauses, if present.
ASTLimit limitNode = node.getLimit();
int limit = -1;
if (limitNode != null) {
limit = (Integer) limitNode.jjtAccept(this, null);
}
ASTOffset offsetNode = node.getOffset();
int offset = -1;
if (offsetNode != null) {
offset = (Integer) offsetNode.jjtAccept(this, null);
}
if (offset >= 1 || limit >= 0) {
tupleExpr = new Slice(tupleExpr, offset, limit);
}
return tupleExpr;
}
Aggregations