113f7c2693d21371f1b12c9d1b0ba8562a797aaf
[phpeclipse.git] /
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 XDebugBooleanValue(XDebugVariable variable,String typeName) {
13                 super(variable, typeName);
14         }
15
16
17         public boolean supportsValueModification() {
18                 return true;
19         }
20
21         public void setType(String typeName) {
22                 fType=XDebugAbstractValue.VALUETYPE_BOOLEAN;
23                 fTypeName=typeName;     }
24
25         public void renderValueString(String data) {
26                 int value=-1;
27                 try {
28                         value=Integer.parseInt(data);
29                 } catch (NumberFormatException e) {
30                         data=data.toLowerCase();
31                         if (data.equals("true") || data.equals("false"))
32                                 fValueString=data;
33                         else
34                                 fValueString="not defined";
35                 }
36                 if (value==0) 
37                         fValueString="false";
38                 else if (value==1)
39                         fValueString="true";
40                 else
41                         fValueString="not defined";
42         }
43
44         public boolean verifyValue(String expression) {
45                 int value=-1;
46                 try {
47                         value=Integer.parseInt(expression);
48                 } catch (NumberFormatException e) {
49                         expression=expression.toLowerCase();
50                         if (expression.equals("true") || expression.equals("false"))
51                                 return true;
52                         else
53                                 return false;
54                 }
55                 if ((value>=0)&& (value <=1))
56                         return true;
57                 return false;
58         }
59
60 }