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 XDebugStackFrame fFrame;
25 private XDebugAbstractValue fValue;
26 private String fFacet;
29 * Constructs a variable contained in the given stack frame
30 * with the given name.
32 * @param frame owning stack frame
33 * @param name variable name
35 public XDebugVariable(XDebugStackFrame frame, Node property) throws DebugException {
36 super((XDebugTarget) frame.getDebugTarget());
41 fName = PHPDebugUtils.getAttributeValue(property,"name");
42 if ("".equals(fName)) {
43 fName = PHPDebugUtils.getAttributeValue(property,"address");
46 fFacet = PHPDebugUtils.getAttributeValue(property, "facet");
48 String typeName = PHPDebugUtils.getAttributeValue(property, "type");
50 if (typeName.equals("int") )
51 fValue = new XDebugIntValue(frame, property);
52 else if (typeName.equals("float") )
53 fValue = new XDebugFloatValue(frame, property);
54 else if (typeName.equals("bool") )
55 fValue = new XDebugBooleanValue(frame, property);
56 else if (typeName.equals("string") )
57 fValue = new XDebugStringValue(frame, property);
58 else if (typeName.equals("array") )
59 fValue = new XDebugArrayValue(frame, property);
60 else if (typeName.equals("hash") )
61 fValue = new XDebugArrayValue(frame, property);
62 else if (typeName.equals("object") )
63 fValue = new XDebugArrayValue(frame, property);
64 else if (typeName.equals("resource") )
65 fValue = new XDebugResourceValue(frame, property);
67 fValue = new XDebugValue(frame, property);
71 * @see org.eclipse.debug.core.model.IVariable#getValue()
73 public IValue getValue() throws DebugException {
78 * @see org.eclipse.debug.core.model.IVariable#getName()
80 public String getName() throws DebugException {
81 /*if (fFullName.endsWith("]"))
82 return fFullName.substring(fFullName.lastIndexOf('['));
88 * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
90 public String getReferenceTypeName() throws DebugException {
91 return fValue.getReferenceTypeName();
95 * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
97 public boolean hasValueChanged() throws DebugException {
98 return fValue.hasChanged();
102 * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
104 public void setValue(String expression) throws DebugException {
105 if (fFrame.setVariableValue(this, expression)) {
106 fValue.setValue(expression);
111 * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
113 public void setValue(IValue value) throws DebugException {
117 * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
119 public boolean supportsValueModification() {
120 return fValue.supportsValueModification();
124 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
126 public boolean verifyValue(String expression) throws DebugException {
127 return fValue.verifyValue(expression);
131 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
133 public boolean verifyValue(IValue value) throws DebugException {
138 * Returns the stack frame owning this variable.
140 * @return the stack frame owning this variable
142 /*protected XDebugStackFrame getStackFrame() {
146 public String getValueString() throws DebugException {
147 return fValue.getValueString();
150 public String getVisibility() {