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: public class ASTOptPathExprTail extends ASTPathExprTail {
09:
10: public ASTOptPathExprTail(int id) {
11: super (id);
12: }
13:
14: public ASTOptPathExprTail(SyntaxTreeBuilder p, int id) {
15: super (p, id);
16: }
17:
18: @Override
19: public Object jjtAccept(SyntaxTreeBuilderVisitor visitor,
20: Object data) throws VisitorException {
21: return visitor.visit(this , data);
22: }
23:
24: /**
25: * Gets the optional tail part of the path expression.
26: *
27: * @return The optional tail part of the path expression.
28: */
29: public ASTBasicPathExprTail getOptionalTail() {
30: return (ASTBasicPathExprTail) children.get(0);
31: }
32:
33: public boolean hasWhereClause() {
34: return getWhereClause() != null;
35: }
36:
37: /**
38: * Gets the where-clause that constrains the results of the optional path
39: * expression tail, if any.
40: *
41: * @return The where-clause, or <tt>null</tt> if not available.
42: */
43: public ASTWhere getWhereClause() {
44: if (children.size() >= 2) {
45: Node node = children.get(1);
46:
47: if (node instanceof ASTWhere) {
48: return (ASTWhere) node;
49: }
50: }
51:
52: return null;
53: }
54:
55: @Override
56: public ASTPathExprTail getNextTail() {
57: if (children.size() >= 2) {
58: Node node = children.get(children.size() - 1);
59:
60: if (node instanceof ASTPathExprTail) {
61: return (ASTPathExprTail) node;
62: }
63: }
64:
65: return null;
66: }
67: }
|