01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.parser.serql.ast;
07:
08: import java.util.ArrayList;
09: import java.util.List;
10:
11: public class ASTQueryBody extends SimpleNode {
12:
13: public ASTQueryBody(int id) {
14: super (id);
15: }
16:
17: public ASTQueryBody(SyntaxTreeBuilder p, int id) {
18: super (p, id);
19: }
20:
21: @Override
22: public Object jjtAccept(SyntaxTreeBuilderVisitor visitor,
23: Object data) throws VisitorException {
24: return visitor.visit(this , data);
25: }
26:
27: public List<ASTFrom> getFromClauseList() {
28: List<ASTFrom> fromClauseList = new ArrayList<ASTFrom>(children
29: .size());
30:
31: for (Node n : children) {
32: if (n instanceof ASTFrom) {
33: fromClauseList.add((ASTFrom) n);
34: } else {
35: break;
36: }
37: }
38:
39: return fromClauseList;
40: }
41:
42: public boolean hasWhereClause() {
43: return getWhereClause() != null;
44: }
45:
46: public ASTWhere getWhereClause() {
47: for (Node n : children) {
48: if (n instanceof ASTWhere) {
49: return (ASTWhere) n;
50: }
51: }
52:
53: return null;
54: }
55:
56: public boolean hasLimitClause() {
57: return getLimitClause() != null;
58: }
59:
60: public ASTLimit getLimitClause() {
61: for (Node n : children) {
62: if (n instanceof ASTLimit) {
63: return (ASTLimit) n;
64: }
65: }
66:
67: return null;
68: }
69:
70: public boolean hasOffsetClause() {
71: return getOffsetClause() != null;
72: }
73:
74: public ASTOffset getOffsetClause() {
75: for (Node n : children) {
76: if (n instanceof ASTOffset) {
77: return (ASTOffset) n;
78: }
79: }
80:
81: return null;
82: }
83: }
|