1 2 12 package com.versant.core.ejb.query; 13 14 import com.versant.core.metadata.ClassMetaData; 15 16 19 public class IdentificationVarNode extends Node { 20 21 private String abstractSchemaName; 22 private String identifier; 23 private JoinNode joinList; 24 25 private NavRoot navRoot; 26 27 public IdentificationVarNode(String schemaName, String identifier, 28 JoinNode joinList) { 29 this.abstractSchemaName = schemaName; 30 this.identifier = identifier; 31 this.joinList = joinList; 32 } 33 34 public String getAbstractSchemaName() { 35 return abstractSchemaName; 36 } 37 38 public String getIdentifier() { 39 return identifier; 40 } 41 42 public JoinNode getJoinList() { 43 return joinList; 44 } 45 46 public Object arrive(NodeVisitor v, Object msg) { 47 return v.arriveIdentificationVarNode(this, msg); 48 } 49 50 public String toStringImp() { 51 StringBuffer s = new StringBuffer (); 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 |