001: /*******************************************************************************
002: * Copyright (c) 2000, 2005 IBM Corporation and others.
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: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.internal.debug.core.logicalstructures;
011:
012: import org.eclipse.core.runtime.PlatformObject;
013: import org.eclipse.debug.core.DebugException;
014: import org.eclipse.debug.core.ILaunch;
015: import org.eclipse.debug.core.model.IDebugTarget;
016: import org.eclipse.debug.core.model.IValue;
017: import org.eclipse.jdt.debug.core.IJavaModifiers;
018: import org.eclipse.jdt.debug.core.IJavaType;
019: import org.eclipse.jdt.debug.core.IJavaValue;
020: import org.eclipse.jdt.debug.core.IJavaVariable;
021:
022: /**
023: * Encapsulates a name and a value. Used when a variable is required (such as for
024: * the VariablesView), but we only have a value available (such as the result of
025: * an evaluation for an object browser).
026: *
027: * @since 3.0
028: */
029: public class JDIPlaceholderVariable extends PlatformObject implements
030: IJavaVariable {
031:
032: private String fName;
033: private IJavaValue fValue;
034:
035: public JDIPlaceholderVariable(String name, IJavaValue value) {
036: fName = name;
037: fValue = value;
038: }
039:
040: /* (non-Javadoc)
041: * @see org.eclipse.jdt.debug.core.IJavaVariable#getSignature()
042: */
043: public String getSignature() throws DebugException {
044: return ((IJavaValue) getValue()).getSignature();
045: }
046:
047: /* (non-Javadoc)
048: * @see org.eclipse.jdt.debug.core.IJavaVariable#getGenericSignature()
049: */
050: public String getGenericSignature() throws DebugException {
051: return ((IJavaValue) getValue()).getGenericSignature();
052: }
053:
054: /* (non-Javadoc)
055: * @see org.eclipse.jdt.debug.core.IJavaVariable#getJavaType()
056: */
057: public IJavaType getJavaType() throws DebugException {
058: return ((IJavaValue) getValue()).getJavaType();
059: }
060:
061: /* (non-Javadoc)
062: * @see org.eclipse.jdt.debug.core.IJavaVariable#isLocal()
063: */
064: public boolean isLocal() {
065: return false;
066: }
067:
068: /* (non-Javadoc)
069: * @see org.eclipse.debug.core.model.IVariable#getValue()
070: */
071: public IValue getValue() {
072: return fValue;
073: }
074:
075: /* (non-Javadoc)
076: * @see org.eclipse.debug.core.model.IVariable#getName()
077: */
078: public String getName() {
079: return fName;
080: }
081:
082: /* (non-Javadoc)
083: * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
084: */
085: public String getReferenceTypeName() throws DebugException {
086: return ((IJavaValue) getValue()).getReferenceTypeName();
087: }
088:
089: /* (non-Javadoc)
090: * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
091: */
092: public boolean hasValueChanged() {
093: return false;
094: }
095:
096: /* (non-Javadoc)
097: * @see org.eclipse.jdt.debug.core.IJavaModifiers#isPublic()
098: */
099: public boolean isPublic() {
100: return false;
101: }
102:
103: /* (non-Javadoc)
104: * @see org.eclipse.jdt.debug.core.IJavaModifiers#isPrivate()
105: */
106: public boolean isPrivate() {
107: return false;
108: }
109:
110: /* (non-Javadoc)
111: * @see org.eclipse.jdt.debug.core.IJavaModifiers#isProtected()
112: */
113: public boolean isProtected() {
114: return false;
115: }
116:
117: /* (non-Javadoc)
118: * @see org.eclipse.jdt.debug.core.IJavaModifiers#isPackagePrivate()
119: */
120: public boolean isPackagePrivate() {
121: return false;
122: }
123:
124: /* (non-Javadoc)
125: * @see org.eclipse.jdt.debug.core.IJavaModifiers#isFinal()
126: */
127: public boolean isFinal() {
128: return false;
129: }
130:
131: /* (non-Javadoc)
132: * @see org.eclipse.jdt.debug.core.IJavaModifiers#isStatic()
133: */
134: public boolean isStatic() {
135: return false;
136: }
137:
138: /* (non-Javadoc)
139: * @see org.eclipse.jdt.debug.core.IJavaModifiers#isSynthetic()
140: */
141: public boolean isSynthetic() {
142: return false;
143: }
144:
145: /* (non-Javadoc)
146: * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
147: */
148: public String getModelIdentifier() {
149: return getValue().getModelIdentifier();
150: }
151:
152: /* (non-Javadoc)
153: * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
154: */
155: public IDebugTarget getDebugTarget() {
156: return ((IJavaValue) getValue()).getDebugTarget();
157: }
158:
159: /* (non-Javadoc)
160: * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
161: */
162: public ILaunch getLaunch() {
163: return getValue().getLaunch();
164: }
165:
166: /* (non-Javadoc)
167: * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
168: */
169: public void setValue(String expression) {
170: }
171:
172: /* (non-Javadoc)
173: * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
174: */
175: public void setValue(IValue value) {
176: }
177:
178: /* (non-Javadoc)
179: * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
180: */
181: public boolean supportsValueModification() {
182: return false;
183: }
184:
185: /* (non-Javadoc)
186: * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
187: */
188: public boolean verifyValue(String expression) {
189: return false;
190: }
191:
192: /* (non-Javadoc)
193: * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
194: */
195: public boolean verifyValue(IValue value) {
196: return false;
197: }
198:
199: /* (non-Javadoc)
200: * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
201: */
202: public Object getAdapter(Class adapter) {
203: if (IJavaVariable.class.equals(adapter)
204: || IJavaModifiers.class.equals(adapter)) {
205: return this ;
206: }
207: return super .getAdapter(adapter);
208: }
209:
210: /* (non-Javadoc)
211: * @see java.lang.Object#equals(java.lang.Object)
212: */
213: public boolean equals(Object obj) {
214: if (obj instanceof JDIPlaceholderVariable) {
215: JDIPlaceholderVariable var = (JDIPlaceholderVariable) obj;
216: return var.getName().equals(getName())
217: && var.getValue().equals(getValue());
218: }
219: return false;
220: }
221:
222: /* (non-Javadoc)
223: * @see java.lang.Object#hashCode()
224: */
225: public int hashCode() {
226: return fName.hashCode() + fValue.hashCode();
227: }
228:
229: }
|