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.Base64;
10 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
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;
16 import org.w3c.dom.NodeList;
21 * TODO To change the template for this generated type comment go to Window -
22 * Preferences - Java - Code Style - Code Templates
24 public abstract class XDebugAbstractValue extends XDebugElement implements
27 public static final int VALUETYPE_UNKNOWN = -1;
29 public static final int VALUETYPE_UNINITIALIZED = 0;
31 public static final int VALUETYPE_STRING = 1;
33 public static final int VALUETYPE_INT = 4;
35 public static final int VALUETYPE_FLOAT = 5;
37 public static final int VALUETYPE_BOOLEAN = 6;
39 public static final int VALUETYPE_ARRAY = 8;
41 public static final int VALUETYPE_HASH = 9;
43 public static final int VALUETYPE_OBJECT = 10;
45 protected XDebugVariable fVariable;
47 private IVariable[] fVariables;
49 protected String fValueString;
53 protected String fTypeName;
55 public XDebugAbstractValue(XDebugVariable variable, Node varNode,
57 super((XDebugTarget) variable.getDebugTarget());
59 if (varNode == null) {
61 System.out.println(variable.getName() + "=null");
62 } catch (DebugException e) {
63 // TODO Auto-generated catch block
69 NodeList property = varNode.getChildNodes();
70 if (variable.hasChildren()) {
71 renderValueString("" + property.getLength());
72 fVariables = new IVariable[property.getLength()];
73 for (int i = 0; i < property.getLength(); i++) {
74 Node propertyNode = property.item(i);
75 fVariables[i] = new XDebugVariable(variable.getStackFrame(),
80 fVariables = new IVariable[0];
81 // if (variable.getType()== XDebugVariable.VARTYPE_UNINITIALIZED)
82 // fValueString="uninitialized";
86 str = varNode.getFirstChild().getNodeValue();
87 } catch (NullPointerException e) {
90 if (variable.getEncoding().equals("base64")) {
91 if (str.length() != 0)
92 str = new String(Base64.decode(str));
96 renderValueString(str);
99 String className = PHPDebugUtils
100 .getAttributeValue(varNode, "classname");
102 renderValueString(className);
109 * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
111 public String getReferenceTypeName() throws DebugException {
118 * @see org.eclipse.debug.core.model.IValue#getValueString()
120 public String getValueString() throws DebugException {
127 * @see org.eclipse.debug.core.model.IValue#isAllocated()
129 public boolean isAllocated() throws DebugException {
136 * @see org.eclipse.debug.core.model.IValue#getVariables()
138 public IVariable[] getVariables() throws DebugException {
145 * @see org.eclipse.debug.core.model.IValue#hasVariables()
147 public boolean hasVariables() throws DebugException {
148 return (fVariables.length > 0);
151 public boolean isArray() {
152 return ((fType & VALUETYPE_ARRAY) > 0);
155 public abstract void setType(String typeName);
157 public abstract void renderValueString(String data);
159 public abstract boolean verifyValue(String expression);
161 public boolean setValue(String expression) {
162 if (!verifyValue(expression))
164 if (fTarget.setVarValue(fVariable.getFullName(), expression)) {
165 renderValueString(expression);
171 public boolean supportsValueModification() {