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.DebugException;
12 import org.eclipse.debug.core.model.IValue;
13 import org.eclipse.debug.core.model.IVariable;
14 import org.w3c.dom.Node;
19 * TODO To change the template for this generated type comment go to
20 * Window - Preferences - Java - Code Style - Code Templates
22 public class XDebugVariable extends XDebugElement implements IVariable {
24 private String fNameFull;
25 private XDebugStackFrame fFrame;
26 private XDebugAbstractValue fValue;
27 private String fFacet;
28 private XDebugVariable fParent; // The parent variable (a back link)
32 * Constructs a variable contained in the given stack frame
33 * with the given name.
35 * @param frame owning stack frame
36 * @param name variable name
38 public XDebugVariable(XDebugStackFrame frame, Node property, XDebugVariable parent) throws DebugException {
39 super((XDebugTarget) frame.getDebugTarget());
41 this.fParent = parent;
48 fName = "$" + PHPDebugUtils.getAttributeValue(property,"name"); // Prepend the variable 'short' name with the php variable prefix '$'
51 fName = PHPDebugUtils.getAttributeValue(property,"name"); // If this is the root variable don't prepend prefix '$'
54 fNameFull = PHPDebugUtils.getAttributeValue(property,"fullname"); // The fullname has the '$' prepended, but it is the fully qualified name
55 // e.g. $myvar->child->a_variable. The fullname would be suitable to take for
56 // the setting a watch expression
58 if ("".equals(fName)) {
59 fName = PHPDebugUtils.getAttributeValue(property,"address");
62 fFacet = PHPDebugUtils.getAttributeValue(property, "facet");
64 String typeName = PHPDebugUtils.getAttributeValue(property, "type");
66 if (typeName.equals("int") )
67 fValue = new XDebugIntValue(frame, property);
68 else if (typeName.equals("float") )
69 fValue = new XDebugFloatValue(frame, property);
70 else if (typeName.equals("bool") )
71 fValue = new XDebugBooleanValue(frame, property);
72 else if (typeName.equals("string") )
73 fValue = new XDebugStringValue(frame, property);
74 else if (typeName.equals("array") )
75 fValue = new XDebugArrayValue(frame, property, this);
76 else if (typeName.equals("object") )
77 fValue = new XDebugObjectValue(frame, property, this);
78 else if (typeName.equals("resource") )
79 fValue = new XDebugResourceValue(frame, property);
81 fValue = new XDebugValue(frame, property);
85 * @see org.eclipse.debug.core.model.IVariable#getValue()
87 public IValue getValue() {
92 * @see org.eclipse.debug.core.model.IVariable#getName()
94 public String getName() {
99 * @return The fully qualified name of the variable
101 public String getNameFull () {
106 * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
108 public String getReferenceTypeName() throws DebugException {
109 return fValue.getReferenceTypeName();
113 * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
115 public boolean hasValueChanged() throws DebugException {
116 return fValue.hasChanged();
120 * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
122 public void setValue(String expression) throws DebugException {
123 if (fFrame.setVariableValue(this, expression)) {
124 fValue.setValue(expression);
129 * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
131 public void setValue(IValue value) throws DebugException {
136 * @param changed This method is called after a suspend when the list of
137 * variables is updated, to mark that this variable has a changed
138 * value. The variable view will show this variable in
141 public void setValueChanged(boolean changed) {
142 fValue.setChanged(changed);
146 * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
148 public boolean supportsValueModification() {
149 return fValue.supportsValueModification();
153 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
155 public boolean verifyValue(String expression) throws DebugException {
156 /*return true; */return fValue.verifyValue(expression);
160 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
162 public boolean verifyValue(IValue value) throws DebugException {
166 public String getValueString() throws DebugException {
167 return fValue.getValueString();
170 public String getVisibility() {
177 public XDebugVariable getParent() {
184 public void setParent(XDebugVariable parent) {
185 this.fParent = parent;