KickJava   Java API By Example, From Geeks To Geeks.

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


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 import com.versant.core.metadata.ClassMetaData;
15
16 /**
17  * For identification_variable_declaration.
18  */

19 public class IdentificationVarNode extends Node {
20
21     private String JavaDoc abstractSchemaName;
22     private String JavaDoc identifier;
23     private JoinNode joinList;
24
25     private NavRoot navRoot;
26
27     public IdentificationVarNode(String JavaDoc schemaName, String JavaDoc identifier,
28             JoinNode joinList) {
29         this.abstractSchemaName = schemaName;
30         this.identifier = identifier;
31         this.joinList = joinList;
32     }
33
34     public String JavaDoc getAbstractSchemaName() {
35         return abstractSchemaName;
36     }
37
38     public String JavaDoc getIdentifier() {
39         return identifier;
40     }
41
42     public JoinNode getJoinList() {
43         return joinList;
44     }
45
46     public Object JavaDoc arrive(NodeVisitor v, Object JavaDoc msg) {
47         return v.arriveIdentificationVarNode(this, msg);
48     }
49
50     public String JavaDoc toStringImp() {
51         StringBuffer JavaDoc s = new StringBuffer JavaDoc();
52         s.append(abstractSchemaName);
53         if (navRoot != null) {
54             s.append('%');
55             s.append(navRoot.getNavClassMetaData().qname);
56         }
57         s.append(" AS ");
58         s.append(identifier);
59         for (Node e = joinList; e != null; e = e.getNext()) {
60             s.append(' ');
61             s.append(e);
62         }
63         return s.toString();
64     }
65
66     public void resolve(ResolveContext rc) {
67         checkIdVarDoesNotExist(rc);
68         ClassMetaData cmd = rc.getModelMetaData().getClassMetaByASN(abstractSchemaName);
69         if (cmd == null) {
70             throw rc.createUserException("Unknown abstract schema name: " +
71                     abstractSchemaName, this);
72         }
73         navRoot = new NavRoot(this, cmd);
74         rc.addIdVar(identifier, navRoot);
75         resolve(joinList, rc);
76     }
77
78     private void checkIdVarDoesNotExist(ResolveContext rc) {
79         NavBase dup = rc.getIdVar(identifier);
80         if (dup != null) {
81             throw rc.createUserException("Duplicate identification variable: " +
82                     identifier, this);
83         }
84     }
85
86     public NavRoot getNavRoot() {
87         return navRoot;
88     }
89
90 }
91
92
Popular Tags