1 /* Created on 23.11.2004
3 * TODO To change the template for this generated file go to
4 * Window - Preferences - Java - Code Style - Code Templates
6 package net.sourceforge.phpeclipse.xdebug.php.model;
8 import net.sourceforge.phpeclipse.xdebug.core.Base64;
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;
16 import org.w3c.dom.NodeList;
21 * TODO To change the template for this generated type comment go to
22 * Window - Preferences - Java - Code Style - Code Templates
25 public abstract class XDebugAbstractValue extends XDebugElement implements IValue {
26 private IVariable[] fVariables;
27 protected String fValueString;
28 protected String fTypeName;
29 private boolean fhasChanged;
31 public XDebugAbstractValue(XDebugStackFrame frame, Node varNode) {
32 super((XDebugTarget) frame.getDebugTarget());
34 fTypeName = PHPDebugUtils.getAttributeValue(varNode,"type");
37 if (!PHPDebugUtils.getAttributeValue(varNode,"numchildren").equals("")) {
38 NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(varNode, "numchildren"));
41 if (NumChildren > 0) {
42 NodeList property = varNode.getChildNodes();
43 renderValueString(""+property.getLength());
44 fVariables = new IVariable[property.getLength()];
45 for (int i = 0; i<property.getLength(); i++) {
46 Node propertyNode = property.item(i);
47 fVariables[i] = new XDebugVariable(frame, propertyNode);
50 fVariables = new IVariable[0];
53 str=varNode.getFirstChild().getNodeValue();
54 } catch (NullPointerException e) {
58 String Encoding = PHPDebugUtils.getAttributeValue(varNode,"encoding");
60 if (Encoding.equals("base64")) {
62 str=new String(Base64.decode(str));
66 renderValueString(str);
68 String className=PHPDebugUtils.getAttributeValue(varNode,"classname");
69 if(!"".equals(className))
70 renderValueString(className);
73 public boolean hasChanged() {
78 * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
80 public String getReferenceTypeName() throws DebugException {
85 * @see org.eclipse.debug.core.model.IValue#getValueString()
87 public String getValueString() throws DebugException {
92 * @see org.eclipse.debug.core.model.IValue#isAllocated()
94 public boolean isAllocated() throws DebugException {
99 * @see org.eclipse.debug.core.model.IValue#getVariables()
101 public IVariable[] getVariables() throws DebugException {
106 * @see org.eclipse.debug.core.model.IValue#hasVariables()
108 public boolean hasVariables() throws DebugException {
109 return (fVariables.length > 0);
112 public abstract void renderValueString(String data);
114 public abstract boolean verifyValue(String expression);
116 public boolean setValue(String expression) {
117 if (!verifyValue(expression)) {
121 renderValueString(expression);
122 fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
127 public boolean supportsValueModification() {