a94b86931658064610a2a1bbca273c2d306406d2
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugObjectValue.java
1 package net.sourceforge.phpeclipse.xdebug.php.model;
2
3 import java.util.ArrayList;
4
5 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
6
7 import org.eclipse.debug.core.DebugException;
8 import org.eclipse.debug.core.model.IVariable;
9 import org.w3c.dom.Node;
10 import org.w3c.dom.NodeList;
11
12 public class XDebugObjectValue extends XDebugAbstractValue {
13         private int NumChildren;
14
15         public XDebugObjectValue(XDebugStackFrame variable, Node value) throws DebugException {
16                 super(variable, value);
17
18                 NumChildren = 0;
19                 if (!PHPDebugUtils.getAttributeValue(value, "numchildren").equals("")) {
20                         NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(value, "numchildren"));
21                 }
22
23                 if (NumChildren > 0) {
24                         NodeList property = value.getChildNodes();
25
26                         ArrayList a = new ArrayList();
27                         for (int i = 0; i < property.getLength(); i++) {
28                                 Node propertyNode = property.item(i);
29                                 /*
30                                  * Eliminate CLASSNAME duplicate from object properties.
31                                  * see http://bugs.xdebug.org/view.php?id=518
32                                  * and http://svn.xdebug.org/cgi-bin/viewvc.cgi/xdebug/trunk/xdebug_var.c?root=xdebug&r1=2962&r2=2996
33                                  */
34                                 String name     = PHPDebugUtils.getAttributeValue (propertyNode, "name");
35
36                                 if (!name.equals ("CLASSNAME")) {
37                                         a.add(new XDebugVariable(variable, propertyNode));
38                                 }
39                         }
40
41                         setChildren((IVariable[])a.toArray(new IVariable[a.size()]));
42                 }
43
44                 String className = PHPDebugUtils.getAttributeValue(value,"classname");
45                 if(!"".equals(className)) {
46                         setValueString(className);
47                 }
48         }
49 }