1) Added parameter 'parent' to XDebugVariable, so we can determine whether a variable...
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugArrayValue.java
1 package net.sourceforge.phpeclipse.xdebug.php.model;
2
3 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
4
5 import org.eclipse.debug.core.DebugException;
6 import org.eclipse.debug.core.model.IVariable;
7 import org.w3c.dom.Node;
8 import org.w3c.dom.NodeList;
9
10 public class XDebugArrayValue extends XDebugAbstractValue {
11         private int NumChildren;
12
13         public XDebugArrayValue(XDebugStackFrame variable, Node value, XDebugVariable parent) throws DebugException {
14                 super(variable, value);
15
16                 NumChildren = 0;
17                 if (!PHPDebugUtils.getAttributeValue(value, "numchildren").equals("")) {
18                         NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(value, "numchildren"));
19                 }               
20
21                 if (NumChildren > 0) {
22                         NodeList property = value.getChildNodes();
23                         renderValueString(""+property.getLength());
24                         IVariable[] Variables = new IVariable[property.getLength()];
25                         
26                         for (int i = 0; i<property.getLength(); i++) {
27                                 Node propertyNode = property.item(i);
28                                 Variables[i] = new XDebugVariable(variable, propertyNode, parent);
29                         }
30                         
31                         setChildren(Variables);
32                 }
33         }
34
35         private void renderValueString(String data) throws DebugException  {
36                 if (data.equals("")) {
37                         setValueString("empty");
38                 } else {
39                         if ("array".equals(getReferenceTypeName())) {
40                                 setValueString("array(" + NumChildren + ")");
41                         } else {
42                                 setValueString(data);
43                         }
44                 }
45         }
46 }