KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > ejb > query > JoinNode


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.ejb.query;
13
14 /**
15  * A join or fetch_join.
16  */

17 public class JoinNode extends Node {
18
19     private boolean outer;
20     private boolean fetch;
21     private PathNode path;
22     private String JavaDoc identifier;
23
24     private NavField navField;
25
26     public JoinNode(boolean left, boolean fetch, PathNode path,
27             String JavaDoc identifier) {
28         this.outer = left;
29         this.fetch = fetch;
30         this.path = path;
31         this.identifier = identifier;
32     }
33
34     public boolean isOuter() {
35         return outer;
36     }
37
38     public boolean isFetch() {
39         return fetch;
40     }
41
42     public PathNode getPath() {
43         return path;
44     }
45
46     public String JavaDoc getIdentifier() {
47         return identifier;
48     }
49
50     public Object JavaDoc arrive(NodeVisitor v, Object JavaDoc msg) {
51         return v.arriveJoinNode(this, msg);
52     }
53
54     public String JavaDoc toStringImp() {
55         StringBuffer JavaDoc s = new StringBuffer JavaDoc();
56         if (outer) {
57             s.append("LEFT OUTER ");
58         }
59         s.append("JOIN ");
60         if (fetch) {
61             s.append("FETCH ");
62         }
63         s.append(path);
64         if (navField != null) {
65             s.append('%');
66             s.append(navField.getFmd().name);
67         }
68         s.append(" AS ");
69         s.append(identifier);
70         return s.toString();
71     }
72
73     public NavField getNavField() {
74         return navField;
75     }
76
77     public void resolve(ResolveContext rc) {
78         rc.checkIdVarDoesNotExist(identifier, this);
79         NavBase res = rc.resolveJoinPath(path, outer, fetch);
80         if (!(res instanceof NavField)) {
81             rc.createUserException("Expected field navigation path: " +
82                     path.toStringImp(), path);
83         }
84         navField = (NavField)res;
85     }
86
87 }
88
89
Popular Tags