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