1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 IBM Corporation - Initial implementation
10 Vicente Fernando - www.alfersoft.com.ar
11 Christian Perkonig - cperkonig@gmx.at
12 **********************************************************************/
13 package net.sourceforge.phpdt.internal.debug.core.model;
15 import java.util.Vector;
17 import org.eclipse.core.runtime.Platform;
18 import org.eclipse.debug.core.DebugException;
19 import org.eclipse.debug.core.ILaunch;
20 import org.eclipse.debug.core.model.IDebugTarget;
21 import org.eclipse.debug.core.model.IValue;
22 import org.eclipse.debug.core.model.IVariable;
24 public class PHPVariable implements IVariable {
27 private PHPValue fValue;
29 private PHPStackFrame fStackFrame;
30 private PHPVariable fParent;
31 private String fLongName;
34 this(null,"",null,"",PHPValue.PEVT_UNKNOWN,null);
37 PHPVariable(PHPStackFrame frame,String name, PHPVariable parent,String value,int valueType,Vector subitems)
39 this.fStackFrame=frame;
40 this.fValue=new PHPValue(frame,value,valueType,subitems);
45 private void setName(String name) {
46 if ((fParent==null) || (fParent.getName()=="")) {
51 switch (fParent.getReferenceType()) {
52 case PHPValue.PEVT_ARRAY :
54 fLongName=fParent.getLongName()+fName;
56 case PHPValue.PEVT_OBJECT :
58 fLongName=fParent.getLongName()+"."+fName;
67 * @see org.eclipse.debug.core.model.IVariable#getValue()
69 public IValue getValue() {
74 * @see org.eclipse.debug.core.model.IVariable#getfName()
76 public String getName() {
80 public PHPVariable getParent()
85 public void setParent(PHPVariable parent)
88 fLongName=parent.getLongName()+fName;
91 public String getLongName() {
96 * @see org.eclipse.debug.core.model.IVariable#getReferenceTypefName()
98 public String getReferenceTypeName() {
99 return fValue.getReferenceTypeName();
102 public int getReferenceType() {
103 return fValue.getReferenceType();
106 public int setReferenceType(int type) {
107 return ((PHPValue) getValue()).setReferenceType(type);
111 * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
113 public boolean hasValueChanged() throws DebugException {
114 // TODO Auto-generated method stub
119 * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
121 public String getModelIdentifier() {
122 return getDebugTarget().getModelIdentifier();
126 * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
128 public IDebugTarget getDebugTarget() {
129 return fStackFrame.getDebugTarget();
133 * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
135 public ILaunch getLaunch() {
136 return getDebugTarget().getLaunch();
141 * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
143 public void setValue(String expression) throws DebugException {
145 if(fValue.getReferenceType()==PHPValue.PEVT_STRING)
146 evalString=fLongName+"=\""+expression+"\"";
148 evalString=fLongName+"="+expression;
149 PHPVariable[] vars=fStackFrame.getPHPDBGProxy().eval(fStackFrame,evalString);
150 setValue(vars[0].fValue);
154 * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
156 public void setValue(IValue value) throws DebugException {
157 // TODO Auto-generated method stub
158 this.fValue=(PHPValue)value;
162 * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
164 public boolean supportsValueModification() {
169 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
171 public boolean verifyValue(String expression) throws DebugException {
172 // TODO Auto-generated method stub
177 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
179 public boolean verifyValue(IValue value) throws DebugException {
180 // TODO Auto-generated method stub
185 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
187 public Object getAdapter(Class adapter) {
188 return Platform.getAdapterManager().getAdapter(this, adapter);
191 public String toString() {
195 switch (getReferenceType())
197 case PHPValue.PEVT_ARRAY :
198 int elements=fValue.getVariables().length;
201 str= this.getName() + " [no elements]";
204 str= this.getName() + " [1 element]";
207 str= this.getName() + " [" + elements + " elements]";
211 case PHPValue.PEVT_OBJECT :
212 str =this.getName() + " [class: " + fValue.getValueString() + "]";
214 case PHPValue.PEVT_STRING :
215 str =this.getName() + " = \"" + fValue.getValueString() +"\"" ;
217 case PHPValue.PEVT_SOFTREF :
219 str =this.getName() + " = " + fValue.getValueString();