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
24 public abstract class XDebugAbstractValue extends XDebugElement implements IValue {
25 private IVariable[] fVariables;
26 protected String fValueString;
27 protected String fTypeName;
28 private boolean fhasChanged;
30 public XDebugAbstractValue(XDebugStackFrame frame, Node varNode) {
31 super((XDebugTarget) frame.getDebugTarget());
33 fTypeName = PHPDebugUtils.getAttributeValue(varNode,"type");
36 if (!PHPDebugUtils.getAttributeValue(varNode,"numchildren").equals("")) {
37 NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(varNode, "numchildren"));
40 if (NumChildren > 0) {
41 NodeList property = varNode.getChildNodes();
42 renderValueString(""+property.getLength());
43 fVariables = new IVariable[property.getLength()];
44 for (int i = 0; i<property.getLength(); i++) {
45 Node propertyNode = property.item(i);
46 fVariables[i] = new XDebugVariable(frame, propertyNode);
49 fVariables = new IVariable[0];
52 str=varNode.getFirstChild().getNodeValue();
53 } catch (NullPointerException e) {
57 String Encoding = PHPDebugUtils.getAttributeValue(varNode,"encoding");
59 if (Encoding.equals("base64")) {
61 str=new String(Base64.decode(str));
65 renderValueString(str);
67 String className=PHPDebugUtils.getAttributeValue(varNode,"classname");
68 if(!"".equals(className))
69 renderValueString(className);
72 public boolean hasChanged() {
77 * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
79 public String getReferenceTypeName() throws DebugException {
84 * @see org.eclipse.debug.core.model.IValue#getValueString()
86 public String getValueString() throws DebugException {
91 * @see org.eclipse.debug.core.model.IValue#isAllocated()
93 public boolean isAllocated() throws DebugException {
98 * @see org.eclipse.debug.core.model.IValue#getVariables()
100 public IVariable[] getVariables() throws DebugException {
105 * @see org.eclipse.debug.core.model.IValue#hasVariables()
107 public boolean hasVariables() throws DebugException {
108 return (fVariables.length > 0);
111 public abstract void renderValueString(String data);
113 public abstract boolean verifyValue(String expression);
115 public boolean setValue(String expression) {
116 if (!verifyValue(expression)) {
120 renderValueString(expression);
121 fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
126 public boolean supportsValueModification() {