package net.sourceforge.phpeclipse.xdebug.php.model;

import org.eclipse.debug.core.DebugException;
import org.w3c.dom.Node;

public class XDebugBooleanValue extends XDebugAbstractValue {
	public XDebugBooleanValue(XDebugStackFrame variable, Node value) throws DebugException {
		super(variable, value);
	}
	
	public boolean supportsValueModification() {
		return true;
	}

	public void renderValueString(String data) {
		int value=-1;
		try {
			value=Integer.parseInt(data);
		} catch (NumberFormatException e) {
			data=data.toLowerCase();
			if (data.equals("true") || data.equals("false"))
				fValueString=data;
			else
				fValueString="not defined";
		}
		if (value==0) 
			fValueString="false";
		else if (value==1)
			fValueString="true";
		else
			fValueString="not defined";
	}

	public boolean verifyValue(String expression) {
		int value=-1;
		try {
			value=Integer.parseInt(expression);
		} catch (NumberFormatException e) {
			expression=expression.toLowerCase();
			if (expression.equals("true") || expression.equals("false"))
				return true;
			else
				return false;
		}
		if ((value>=0)&& (value <=1))
			return true;
		return false;
	}
}