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.jdo.query;
12:
13: import com.versant.core.metadata.ClassMetaData;
14:
15: import com.versant.core.common.BindingSupportImpl;
16:
17: /**
18: * This is used to prevent a field with the same name as a parameter or
19: * a variable getting mangled when it is under this (i.e. this.field).
20: */
21: public class ReservedFieldNode extends FieldNavNode {
22:
23: private int type;
24: private ClassMetaData target;
25:
26: public static final int TYPE_THIS = 1;
27:
28: public ReservedFieldNode(int type, String lexeme) {
29: this .type = type;
30: this .lexeme = lexeme;
31: }
32:
33: public Field visit(MemVisitor visitor, Object obj) {
34: return visitor.visitReservedFieldNode(this , obj);
35: }
36:
37: public void normalizeImp() {
38: if (childList != null)
39: childList.normalizeImp();
40: }
41:
42: public void resolve(QueryParser comp, ClassMetaData cmd,
43: boolean ordering) {
44: if (type == TYPE_THIS) {
45: if (childList != null) {
46: parent.replaceChild(this , childList);
47: if (childList instanceof FieldNode) {
48: FieldNode fn = ((FieldNode) childList);
49: fn.resolved = true;
50: fn.useCandidateExtent = true;
51: } else if (childList instanceof FieldNavNode) {
52: ((FieldNavNode) childList).resolved = true;
53: }
54: childList.resolve(comp, cmd, false);
55: } else { // 'this' on its own reference
56: target = cmd;
57: }
58: } else {
59: throw BindingSupportImpl.getInstance().unsupported(
60: "ReservedFieldNode of type " + type
61: + " is not supported");
62: }
63: }
64:
65: public ClassMetaData getTarget() {
66: return target;
67: }
68:
69: public Object arrive(NodeVisitor v, Object msg) {
70: return v.arriveReservedFieldNode(this, msg);
71: }
72: }
|