92ba352e723b34fcab1daa209961e86351b353e2
[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 encoding = PHPDebugUtils.getAttributeValue(propertyNode, "encoding");
35                                 if (encoding.equals("base64")) {
36                                         a.add(new XDebugVariable(variable, propertyNode));
37                                 }
38                         }
39                         
40                         setChildren((IVariable[])a.toArray(new IVariable[a.size()]));
41                 }
42                 
43                 String className = PHPDebugUtils.getAttributeValue(value,"classname");
44                 if(!"".equals(className)) {
45                         setValueString(className);
46                 }
47         }
48 }