Fix variable view value modification and refactored XDebugAbstractValue and derived...
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugAbstractValue.java
index 26e1263..eb91e5b 100644 (file)
@@ -1,19 +1,16 @@
-/*
- * Created on 23.11.2004
+ /* Created on 23.11.2004
  *
  * TODO To change the template for this generated file go to
  * Window - Preferences - Java - Code Style - Code Templates
  */
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
-import net.sourceforge.phpeclipse.xdebug.core.Base64;
 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
 
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.model.IValue;
 import org.eclipse.debug.core.model.IVariable;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 /**
  * @author Axel
@@ -21,67 +18,33 @@ import org.w3c.dom.NodeList;
  * TODO To change the template for this generated type comment go to
  * Window - Preferences - Java - Code Style - Code Templates
  */
-public abstract class XDebugAbstractValue  extends XDebugElement implements IValue {
+
+public /*abstract*/ class XDebugAbstractValue  extends XDebugElement implements IValue {
        private IVariable[] fVariables;
-       protected String fValueString;
-       protected String fTypeName;
+       private String fValueString;
+       private String fTypeName;
        private boolean fhasChanged;
+       protected String rowValue;
+       
+       public XDebugAbstractValue(XDebugStackFrame frame, Node value) throws DebugException  {
+               super(frame == null ? null : (XDebugTarget)frame.getDebugTarget());
 
-       public XDebugAbstractValue(XDebugStackFrame frame, Node varNode) {
-               super((XDebugTarget) frame.getDebugTarget());
-
-               fTypeName = PHPDebugUtils.getAttributeValue(varNode,"type");
-
-               int NumChildren = 0;
-               if (!PHPDebugUtils.getAttributeValue(varNode,"numchildren").equals("")) {
-                       NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(varNode, "numchildren"));
-               }               
+               fTypeName = PHPDebugUtils.getAttributeValue(value, "type");
+               
+               fVariables = new IVariable[0];
 
-               NodeList property = varNode.getChildNodes();
-               if (NumChildren > 0) {
-                       renderValueString(""+property.getLength());
-                       fVariables = new IVariable[property.getLength()];
-                       for (int i = 0; i<property.getLength(); i++) {
-                               Node propertyNode = property.item(i);
-                               fVariables[i] = new XDebugVariable(frame, propertyNode);
-                       }
-               }else {
-                       fVariables = new IVariable[0];
-                       String str="";
-                       try {
-                               str=varNode.getFirstChild().getNodeValue();
-                       } catch (NullPointerException e) {
-                               str="";
-                       }
-                       
-                       
-                       String Encoding = PHPDebugUtils.getAttributeValue(varNode,"encoding");
-                       
-                       if (Encoding.equals("base64")) {
-                               if (str.length()!=0)
-                                       str=new String(Base64.decode(str));
-                               else
-                                       str="";
-                       }
-                       renderValueString(str);
+               rowValue = "";
+               try {
+                       rowValue = value.getFirstChild().getNodeValue();
+               } catch (NullPointerException e) {
+                       rowValue = "";
                }
-               String className=PHPDebugUtils.getAttributeValue(varNode,"classname");
-               if(!"".equals(className))
-                       renderValueString(className);
        }
        
        public boolean hasChanged() {
                return fhasChanged;
        }
        
-       public void sethasChanged(boolean hasChanged) {
-               fhasChanged = hasChanged;
-       }
-       
-       public void setChildVariables(IVariable[] newChildVariables) {
-               fVariables = newChildVariables;
-       }
-       
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
         */
@@ -117,25 +80,23 @@ public abstract class XDebugAbstractValue  extends XDebugElement implements IVal
                return (fVariables.length > 0);
        }
        
-       public abstract void renderValueString(String data);
-
-       public abstract boolean verifyValue(String expression);
+       public boolean setValue(String expression) throws DebugException {
+               return true;
+       };
        
-       public boolean setValue(String expression) {
-               if (!verifyValue(expression))
-                       return false;
-        if( getDebugTarget() == null ) {
-            renderValueString(expression);
-           } else {
-                  /* if(((XDebugTarget) getDebugTarget()).setVarValue(fVariable.getFullName(),expression)) {
-                           renderValueString(expression);
-                           return true;
-                   }*/
-           }
-               return false;
+       protected boolean verifyValue(String expression) {
+               return true;
        }
        
-       public boolean supportsValueModification() {
+       protected boolean supportsValueModification() {
                return false;
        }
+       
+       protected void setValueString(String valueString) {
+               fValueString = valueString;
+       }
+
+       protected void setChildren(IVariable[] newChildren) {
+               fVariables = newChildren;
+       }
 }
\ No newline at end of file