1) CLASSNAME is specified by the property 'name' == CLASSNAME. When doing it by the...
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugObjectValue.java
index a7fdfca..a94b869 100644 (file)
@@ -1,35 +1,49 @@
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
-import org.w3c.dom.Node;
-
-public class XDebugObjectValue extends XDebugAbstractValue {
+import java.util.ArrayList;
 
-       public XDebugObjectValue(XDebugVariable variable, Node varNode,
-                       String typeName) {
-               super(variable, varNode, typeName);
-       }
-
-       public void setType(String typeName) {
-               fType=XDebugAbstractValue.VALUETYPE_OBJECT;
-               fTypeName=typeName;
+import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
 
-       }
-
-       public void renderValueString(String data) {
-               fValueString = data;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IVariable;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
+public class XDebugObjectValue extends XDebugAbstractValue {
+       private int NumChildren;
+
+       public XDebugObjectValue(XDebugStackFrame variable, Node value) throws DebugException {
+               super(variable, value);
+
+               NumChildren = 0;
+               if (!PHPDebugUtils.getAttributeValue(value, "numchildren").equals("")) {
+                       NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(value, "numchildren"));
+               }
+
+               if (NumChildren > 0) {
+                       NodeList property = value.getChildNodes();
+
+                       ArrayList a = new ArrayList();
+                       for (int i = 0; i < property.getLength(); i++) {
+                               Node propertyNode = property.item(i);
+                               /*
+                                * Eliminate CLASSNAME duplicate from object properties.
+                                * see http://bugs.xdebug.org/view.php?id=518
+                                * and http://svn.xdebug.org/cgi-bin/viewvc.cgi/xdebug/trunk/xdebug_var.c?root=xdebug&r1=2962&r2=2996
+                                */
+                               String name     = PHPDebugUtils.getAttributeValue (propertyNode, "name");
+
+                               if (!name.equals ("CLASSNAME")) {
+                                       a.add(new XDebugVariable(variable, propertyNode));
+                               }
+                       }
+
+                       setChildren((IVariable[])a.toArray(new IVariable[a.size()]));
+               }
+
+               String className = PHPDebugUtils.getAttributeValue(value,"classname");
+               if(!"".equals(className)) {
+                       setValueString(className);
+               }
        }
-       
-/*     public String toString() {
-               return "class " + fValueString;
-       }*/
-       /*public String toString() {
-               return null;
-       }*/
-
-       public boolean verifyValue(String expression) {
-               // TODO Auto-generated method stub
-               return false;
-       }
-
 }