01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.ejb.query;
12:
13: /**
14: * A join or fetch_join.
15: */
16: public class JoinNode extends Node {
17:
18: private boolean outer;
19: private boolean fetch;
20: private PathNode path;
21: private String identifier;
22:
23: private NavField navField;
24:
25: public JoinNode(boolean left, boolean fetch, PathNode path,
26: String identifier) {
27: this .outer = left;
28: this .fetch = fetch;
29: this .path = path;
30: this .identifier = identifier;
31: }
32:
33: public boolean isOuter() {
34: return outer;
35: }
36:
37: public boolean isFetch() {
38: return fetch;
39: }
40:
41: public PathNode getPath() {
42: return path;
43: }
44:
45: public String getIdentifier() {
46: return identifier;
47: }
48:
49: public Object arrive(NodeVisitor v, Object msg) {
50: return v.arriveJoinNode(this , msg);
51: }
52:
53: public String toStringImp() {
54: StringBuffer s = new StringBuffer();
55: if (outer) {
56: s.append("LEFT OUTER ");
57: }
58: s.append("JOIN ");
59: if (fetch) {
60: s.append("FETCH ");
61: }
62: s.append(path);
63: if (navField != null) {
64: s.append('%');
65: s.append(navField.getFmd().name);
66: }
67: s.append(" AS ");
68: s.append(identifier);
69: return s.toString();
70: }
71:
72: public NavField getNavField() {
73: return navField;
74: }
75:
76: public void resolve(ResolveContext rc) {
77: rc.checkIdVarDoesNotExist(identifier, this );
78: NavBase res = rc.resolveJoinPath(path, outer, fetch);
79: if (!(res instanceof NavField)) {
80: rc.createUserException("Expected field navigation path: "
81: + path.toStringImp(), path);
82: }
83: navField = (NavField) res;
84: }
85:
86: }
|