KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > query > ReservedFieldNode


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.jdo.query;
13
14 import com.versant.core.metadata.ClassMetaData;
15
16 import com.versant.core.common.BindingSupportImpl;
17
18 /**
19  * This is used to prevent a field with the same name as a parameter or
20  * a variable getting mangled when it is under this (i.e. this.field).
21  */

22 public class ReservedFieldNode extends FieldNavNode {
23
24     private int type;
25     private ClassMetaData target;
26
27     public static final int TYPE_THIS = 1;
28
29     public ReservedFieldNode(int type, String JavaDoc lexeme) {
30         this.type = type;
31         this.lexeme = lexeme;
32     }
33
34     public Field visit(MemVisitor visitor, Object JavaDoc obj) {
35         return visitor.visitReservedFieldNode(this, obj);
36     }
37
38     public void normalizeImp() {
39         if (childList != null) childList.normalizeImp();
40     }
41
42     public void resolve(QueryParser comp, ClassMetaData cmd, boolean ordering) {
43         if (type == TYPE_THIS) {
44             if (childList != null) {
45                 parent.replaceChild(this, childList);
46                 if (childList instanceof FieldNode) {
47                     FieldNode fn = ((FieldNode)childList);
48                     fn.resolved = true;
49                     fn.useCandidateExtent = true;
50                 } else if (childList instanceof FieldNavNode) {
51                     ((FieldNavNode)childList).resolved = true;
52                 }
53                 childList.resolve(comp, cmd, false);
54             } else { // 'this' on its own reference
55
target = cmd;
56             }
57         } else {
58             throw BindingSupportImpl.getInstance().unsupported("ReservedFieldNode of type " +
59                     type + " is not supported");
60         }
61     }
62
63     public ClassMetaData getTarget() {
64         return target;
65     }
66
67     public Object JavaDoc arrive(NodeVisitor v, Object JavaDoc msg) {
68         return v.arriveReservedFieldNode(this, msg);
69     }
70 }
71
72
Popular Tags