Fix variable view value modification and refactored XDebugAbstractValue and derived...
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugIntValue.java
1 package net.sourceforge.phpeclipse.xdebug.php.model;
2
3 import org.eclipse.debug.core.DebugEvent;
4 import org.eclipse.debug.core.DebugException;
5 import org.w3c.dom.Node;
6
7 public class XDebugIntValue extends XDebugAbstractValue {
8         public XDebugIntValue(XDebugStackFrame stackFrame, Node value) throws DebugException {
9                 super(stackFrame, value);
10
11                 if (isValid(rowValue)) {
12                         setValueString(rowValue);
13                 }
14         }
15         
16         public boolean supportsValueModification() {
17                 return true;
18         }
19                 
20         public boolean setValue(String expression) throws DebugException {
21                 if (isValid(expression)) {
22                         setValueString(expression);
23                         fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
24                         return true;
25                 }
26                 
27                 return false;
28         }
29
30         private boolean isValid(String expression) {
31                 try {
32                         Integer.parseInt(expression);
33                 } catch (NumberFormatException e) {
34                         return false;
35                 }
36                 return true;
37         }
38
39         public boolean verifyValue(String expression) {
40                 return isValid(expression);
41         }
42 }