KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > core > logicalstructures > JDIPlaceholderVariable


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.core.logicalstructures;
12
13 import org.eclipse.core.runtime.PlatformObject;
14 import org.eclipse.debug.core.DebugException;
15 import org.eclipse.debug.core.ILaunch;
16 import org.eclipse.debug.core.model.IDebugTarget;
17 import org.eclipse.debug.core.model.IValue;
18 import org.eclipse.jdt.debug.core.IJavaModifiers;
19 import org.eclipse.jdt.debug.core.IJavaType;
20 import org.eclipse.jdt.debug.core.IJavaValue;
21 import org.eclipse.jdt.debug.core.IJavaVariable;
22
23 /**
24  * Encapsulates a name and a value. Used when a variable is required (such as for
25  * the VariablesView), but we only have a value available (such as the result of
26  * an evaluation for an object browser).
27  *
28  * @since 3.0
29  */

30 public class JDIPlaceholderVariable extends PlatformObject implements IJavaVariable {
31
32     private String JavaDoc fName;
33     private IJavaValue fValue;
34
35     public JDIPlaceholderVariable(String JavaDoc name, IJavaValue value) {
36         fName = name;
37         fValue = value;
38     }
39     
40     /* (non-Javadoc)
41      * @see org.eclipse.jdt.debug.core.IJavaVariable#getSignature()
42      */

43     public String JavaDoc getSignature() throws DebugException {
44         return ((IJavaValue)getValue()).getSignature();
45     }
46
47     /* (non-Javadoc)
48      * @see org.eclipse.jdt.debug.core.IJavaVariable#getGenericSignature()
49      */

50     public String JavaDoc getGenericSignature() throws DebugException {
51         return ((IJavaValue)getValue()).getGenericSignature();
52     }
53     
54     /* (non-Javadoc)
55      * @see org.eclipse.jdt.debug.core.IJavaVariable#getJavaType()
56      */

57     public IJavaType getJavaType() throws DebugException {
58         return ((IJavaValue)getValue()).getJavaType();
59     }
60
61     /* (non-Javadoc)
62      * @see org.eclipse.jdt.debug.core.IJavaVariable#isLocal()
63      */

64     public boolean isLocal() {
65         return false;
66     }
67
68     /* (non-Javadoc)
69      * @see org.eclipse.debug.core.model.IVariable#getValue()
70      */

71     public IValue getValue() {
72         return fValue;
73     }
74
75     /* (non-Javadoc)
76      * @see org.eclipse.debug.core.model.IVariable#getName()
77      */

78     public String JavaDoc getName() {
79         return fName;
80     }
81
82     /* (non-Javadoc)
83      * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
84      */

85     public String JavaDoc getReferenceTypeName() throws DebugException {
86         return ((IJavaValue)getValue()).getReferenceTypeName();
87     }
88
89     /* (non-Javadoc)
90      * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
91      */

92     public boolean hasValueChanged() {
93         return false;
94     }
95
96     /* (non-Javadoc)
97      * @see org.eclipse.jdt.debug.core.IJavaModifiers#isPublic()
98      */

99     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 JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc getAdapter(Class JavaDoc 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 JavaDoc obj) {
214         if (obj instanceof JDIPlaceholderVariable) {
215             JDIPlaceholderVariable var = (JDIPlaceholderVariable)obj;
216             return var.getName().equals(getName()) && var.getValue().equals(getValue());
217         }
218         return false;
219     }
220
221     /* (non-Javadoc)
222      * @see java.lang.Object#hashCode()
223      */

224     public int hashCode() {
225         return fName.hashCode() + fValue.hashCode();
226     }
227
228 }
229
Popular Tags