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
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 NodeList property = varNode.getChildNodes();
41 if (NumChildren > 0) {
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) {
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() {
77 public void sethasChanged(boolean hasChanged) {
78 fhasChanged = hasChanged;
81 public void setChildVariables(IVariable[] newChildVariables) {
82 fVariables = newChildVariables;
86 * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
88 public String getReferenceTypeName() throws DebugException {
93 * @see org.eclipse.debug.core.model.IValue#getValueString()
95 public String getValueString() throws DebugException {
100 * @see org.eclipse.debug.core.model.IValue#isAllocated()
102 public boolean isAllocated() throws DebugException {
107 * @see org.eclipse.debug.core.model.IValue#getVariables()
109 public IVariable[] getVariables() throws DebugException {
114 * @see org.eclipse.debug.core.model.IValue#hasVariables()
116 public boolean hasVariables() throws DebugException {
117 return (fVariables.length > 0);
120 public abstract void renderValueString(String data);
122 public abstract boolean verifyValue(String expression);
124 public boolean setValue(String expression) {
125 if (!verifyValue(expression))
127 if( getDebugTarget() == null ) {
128 renderValueString(expression);
130 /* if(((XDebugTarget) getDebugTarget()).setVarValue(fVariable.getFullName(),expression)) {
131 renderValueString(expression);
138 public boolean supportsValueModification() {