678a955abfc8fe99a2e7198f124c44ad4330cf60
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugBooleanValue.java
1 package net.sourceforge.phpeclipse.xdebug.php.model;
2
3 import org.w3c.dom.Node;
4
5 public class XDebugBooleanValue extends XDebugAbstractValue {
6
7         public XDebugBooleanValue(XDebugVariable variable, Node varNode,
8                         String typeName) {
9                 super(variable, varNode, typeName);
10         }
11
12         public boolean supportsValueModification() {
13                 return true;
14         }
15
16         public void setType(String typeName) {
17                 fType = XDebugAbstractValue.VALUETYPE_BOOLEAN;
18                 fTypeName = typeName;
19         }
20
21         public void renderValueString(String data) {
22                 int value = -1;
23                 try {
24                         value = Integer.parseInt(data);
25                 } catch (NumberFormatException e) {
26                         data = data.toLowerCase();
27                         if (data.equals("true") || data.equals("false"))
28                                 fValueString = data;
29                         else
30                                 fValueString = "not defined";
31                 }
32                 if (value == 0)
33                         fValueString = "false";
34                 else if (value == 1)
35                         fValueString = "true";
36                 else
37                         fValueString = "not defined";
38         }
39
40         public boolean verifyValue(String expression) {
41                 int value = -1;
42                 try {
43                         value = Integer.parseInt(expression);
44                 } catch (NumberFormatException e) {
45                         expression = expression.toLowerCase();
46                         if (expression.equals("true") || expression.equals("false"))
47                                 return true;
48                         else
49                                 return false;
50                 }
51                 if ((value >= 0) && (value <= 1))
52                         return true;
53                 return false;
54         }
55
56 }