001: /*
002: * Copyright (c) 1998 - 2005 Versant Corporation
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * Versant Corporation - initial API and implementation
010: */
011: package com.versant.core.jdo.query;
012:
013: import com.versant.core.metadata.ClassMetaData;
014: import com.versant.core.common.Debug;
015:
016: /**
017: * This node is created when the value of a parameter is required as part
018: * of an expression.
019: */
020: public class ParamNode extends LeafNode {
021:
022: private String type;
023: private String identifier;
024: private Class cls;
025: private ClassMetaData cmd;
026: private Object value;
027: /**
028: * This is the index of the parameter in the declared parameter list.
029: */
030: private int index;
031:
032: /**
033: * The store specific usage list for this node.
034: */
035: public Object usageList;
036:
037: public ParamNode() {
038: }
039:
040: public Object accept(NodeVisitor visitor, Object[] results) {
041: return visitor.visitParamNode(this , results);
042: }
043:
044: public String toString() {
045: StringBuffer s = new StringBuffer();
046: s.append(super .toString());
047: s.append(' ');
048: if (cls != null)
049: s.append(cls);
050: else
051: s.append(type);
052: s.append(' ');
053: s.append(identifier);
054: s.append(" index ");
055: s.append(index);
056: return s.toString();
057: }
058:
059: /**
060: * Resolve field refs and so on relative to the compiler. This must
061: * recursively resolve any child nodes.
062: */
063: public void resolve(QueryParser comp, ClassMetaData cmd,
064: boolean ordering) {
065: if (Debug.DEBUG)
066: System.out.println("### ParamNode.resolve " + this );
067: if (cls == null)
068: cls = comp.resolveParamType(type);
069: }
070:
071: public Field visit(MemVisitor visitor, Object obj) {
072: return visitor.visitParamNode(this , obj);
073: }
074:
075: public String getType() {
076: return type;
077: }
078:
079: public void setType(String type) {
080: this .type = type;
081: }
082:
083: public String getIdentifier() {
084: return identifier;
085: }
086:
087: public void setIdentifier(String identifier) {
088: this .identifier = identifier;
089: }
090:
091: public Class getCls() {
092: return cls;
093: }
094:
095: public void setCls(Class cls) {
096: this .cls = cls;
097: }
098:
099: public ClassMetaData getCmd() {
100: return cmd;
101: }
102:
103: public void setCmd(ClassMetaData cmd) {
104: this .cmd = cmd;
105: }
106:
107: public Object getValue() {
108: return value;
109: }
110:
111: public void setValue(Object value) {
112: this .value = value;
113: }
114:
115: public int getIndex() {
116: return index;
117: }
118:
119: public void setIndex(int index) {
120: this .index = index;
121: }
122:
123: public Object getUsageList() {
124: return usageList;
125: }
126:
127: public void clearSqlUsageList() {
128: usageList = null;
129: }
130:
131: public Object arrive(NodeVisitor v, Object msg) {
132: return v.arriveParamNode(this, msg);
133: }
134:
135: }
|