2 * Created on 23.11.2004
4 * TODO To change the template for this generated file go to
5 * Window - Preferences - Java - Code Style - Code Templates
7 package net.sourceforge.phpeclipse.xdebug.php.model;
9 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
11 import org.eclipse.debug.core.DebugEvent;
12 import org.eclipse.debug.core.DebugException;
13 import org.eclipse.debug.core.model.IValue;
14 import org.eclipse.debug.core.model.IVariable;
15 import org.w3c.dom.Node;
20 * TODO To change the template for this generated type comment go to Window -
21 * Preferences - Java - Code Style - Code Templates
23 public class XDebugVariable extends XDebugElement implements IVariable {
25 public static final int VARTYPE_UNKNOWN = -1;
27 public static final int VARTYPE_UNINITIALIZED = 0;
29 public static final int VARTYPE_STRING = 1;
31 public static final int VARTYPE_INT = 2;
33 public static final int VARTYPE_FLOAT = 3;
35 public static final int VARTYPE_ARRAY = 8;
37 public static final int VARTYPE_HASH = 9;
39 public static final int VARTYPE_OBJECT = 10;
44 private XDebugStackFrame fFrame;
46 private String fFullName;
48 // private String fTypeName;
50 private XDebugAbstractValue fValue;
52 private String fEncoding;
54 private int fNumChildren;
56 // private Node fVariableNode;
59 * Constructs a variable contained in the given stack frame with the given
67 public XDebugVariable(XDebugStackFrame frame, Node property) {
68 super((XDebugTarget) frame.getDebugTarget());
74 private void init(Node property) {
75 fFullName = PHPDebugUtils.getAttributeValue(property, "fullname");
76 fName = PHPDebugUtils.getAttributeValue(property, "name");
77 fEncoding = PHPDebugUtils.getAttributeValue(property, "encoding");
78 if (PHPDebugUtils.getAttributeValue(property, "numchildren").equals(""))
81 fNumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(
82 property, "numchildren"));
84 String typeName = PHPDebugUtils.getAttributeValue(property, "type");
86 // if (typeName.equals("uninitialized") )
87 // fValue= new XDebugValue(this,property,typeName);
88 if (typeName.equals("int"))
89 fValue = new XDebugIntValue(this, property, typeName);
90 else if (typeName.equals("float"))
91 fValue = new XDebugFloatValue(this, property, typeName);
92 else if (typeName.equals("bool"))
93 fValue = new XDebugBooleanValue(this, property, typeName);
94 else if (typeName.equals("string"))
95 fValue = new XDebugStringValue(this, property, typeName);
96 else if (typeName.equals("array"))
97 fValue = new XDebugArrayValue(this, property, typeName);
98 else if (typeName.equals("hash"))
99 fValue = new XDebugArrayValue(this, property, typeName);
100 else if (typeName.equals("object"))
101 fValue = new XDebugArrayValue(this, property, typeName);
103 fValue = new XDebugValue(this, property, typeName);
105 // else if (typeName.equals("float") )
106 // fTypeName= VARTYPE_FLOAT;
107 // else if (typeName.equals("string") )
108 // fTypeName= VARTYPE_STRING;
109 // else if (typeName.equals("hash") )
110 // fTypeName= VARTYPE_HASH;
111 // else if (typeName.equals("array") )
112 // fTypeName= VARTYPE_ARRAY;
113 // else if (typeName.equals("object") )
114 // fTypeName= VARTYPE_OBJECT;
118 // fValue= new XDebugValue(this,property);
124 * @see org.eclipse.debug.core.model.IVariable#getValue()
126 public IValue getValue() throws DebugException {
128 // return ((XDebugTarget)getDebugTarget()).getVariableValue(this);
134 * @see org.eclipse.debug.core.model.IVariable#getName()
136 public String getName() throws DebugException {
137 if (fFullName.endsWith("]"))
138 return fFullName.substring(fFullName.lastIndexOf('['));
146 * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
148 public String getReferenceTypeName() throws DebugException {
149 return fValue.getReferenceTypeName();
155 * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
157 public boolean hasValueChanged() throws DebugException {
158 // TODO Auto-generated method stub
165 * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
167 public void setValue(String expression) throws DebugException {
168 if (fValue.setValue(expression))
169 fireEvent(new DebugEvent(this, DebugEvent.CHANGE,
170 DebugEvent.CONTENT));
176 * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
178 public void setValue(IValue value) throws DebugException {
184 * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
186 public boolean supportsValueModification() {
187 return fValue.supportsValueModification();
193 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
195 public boolean verifyValue(String expression) throws DebugException {
196 return fValue.verifyValue(expression);
202 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
204 public boolean verifyValue(IValue value) throws DebugException {
209 * Returns the stack frame owning this variable.
211 * @return the stack frame owning this variable
213 protected XDebugStackFrame getStackFrame() {
217 // public int getType() {
221 public String getValueString() throws DebugException {
222 return fValue.getValueString();
225 public boolean hasChildren() {
226 return (fNumChildren > 0);
229 public boolean isArray() {
230 return (fValue.isArray());
233 public String getEncoding() {
237 public void setEncoding(String encoding) {
238 fEncoding = encoding;
241 public String toString() {
242 return fValue.toString();
245 public String getFullName() {