*/
package net.sourceforge.phpeclipse.xdebug.php.model;
-import net.sourceforge.phpeclipse.xdebug.core.Base64;
import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
-import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* @author Axel
* Window - Preferences - Java - Code Style - Code Templates
*/
-public abstract class XDebugAbstractValue extends XDebugElement implements IValue {
+public /*abstract*/ class XDebugAbstractValue extends XDebugElement implements IValue {
private IVariable[] fVariables;
private String fValueString;
private String fTypeName;
private boolean fhasChanged;
+ protected String rowValue;
+
+ public XDebugAbstractValue(XDebugStackFrame frame, Node value) throws DebugException {
+ super(frame == null ? null : (XDebugTarget)frame.getDebugTarget());
- public XDebugAbstractValue(XDebugStackFrame frame, Node varNode) throws DebugException {
- super(frame == null ? null : (XDebugTarget) frame.getDebugTarget());
-
- fTypeName = PHPDebugUtils.getAttributeValue(varNode,"type");
-
- int NumChildren = 0;
- if (!PHPDebugUtils.getAttributeValue(varNode,"numchildren").equals("")) {
- NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(varNode, "numchildren"));
- }
-
- if (NumChildren > 0) {
- NodeList property = varNode.getChildNodes();
- renderValueString(""+property.getLength());
- fVariables = new IVariable[property.getLength()];
- for (int i = 0; i<property.getLength(); i++) {
- Node propertyNode = property.item(i);
- fVariables[i] = new XDebugVariable(frame, propertyNode);
- }
- }else {
- fVariables = new IVariable[0];
- String str="";
- try {
- str=varNode.getFirstChild().getNodeValue();
- } catch (NullPointerException e) {
- str="";
- }
+ fTypeName = PHPDebugUtils.getAttributeValue(value, "type");
+
+ fVariables = new IVariable[0];
- String Encoding = PHPDebugUtils.getAttributeValue(varNode,"encoding");
-
- if (Encoding.equals("base64")) {
- if (str.length()!=0)
- str=new String(Base64.decode(str));
- else
- str="";
- }
- renderValueString(str);
+ rowValue = "";
+ try {
+ rowValue = value.getFirstChild().getNodeValue();
+ } catch (NullPointerException e) {
+ rowValue = "";
}
- String className=PHPDebugUtils.getAttributeValue(varNode,"classname");
- if(!"".equals(className))
- renderValueString(className);
}
public boolean hasChanged() {
return (fVariables.length > 0);
}
- public abstract void renderValueString(String data) throws DebugException;
-
- public abstract boolean verifyValue(String expression);
-
public boolean setValue(String expression) throws DebugException {
- if (!verifyValue(expression)) {
- return false;
- }
-
- renderValueString(expression);
- fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
-
+ return true;
+ };
+
+ protected boolean verifyValue(String expression) {
return true;
}
- public boolean supportsValueModification() {
+ protected boolean supportsValueModification() {
return false;
}
- public void setValueString(String valueString) {
+ protected void setValueString(String valueString) {
fValueString = valueString;
}
+
+ protected void setChildren(IVariable[] newChildren) {
+ fVariables = newChildren;
+ }
}
\ No newline at end of file
package net.sourceforge.phpeclipse.xdebug.php.model;
+import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
+
import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IVariable;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
public class XDebugArrayValue extends XDebugAbstractValue {
+ private int NumChildren;
+
public XDebugArrayValue(XDebugStackFrame variable, Node value) throws DebugException {
super(variable, value);
+
+ NumChildren = 0;
+ if (!PHPDebugUtils.getAttributeValue(value, "numchildren").equals("")) {
+ NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(value, "numchildren"));
+ }
+
+ if (NumChildren > 0) {
+ NodeList property = value.getChildNodes();
+ renderValueString(""+property.getLength());
+ IVariable[] Variables = new IVariable[property.getLength()];
+
+ for (int i = 0; i<property.getLength(); i++) {
+ Node propertyNode = property.item(i);
+ Variables[i] = new XDebugVariable(variable, propertyNode);
+ }
+
+ setChildren(Variables);
+ }
}
- public void renderValueString(String data) throws DebugException {
+ private void renderValueString(String data) throws DebugException {
if (data.equals("")) {
- setValueString("empty")/*fValueString = "empty"*/;
+ setValueString("empty");
} else {
if ("array".equals(getReferenceTypeName())) {
- setValueString("array")/*fValueString = "array"*/;
+ setValueString("array(" + NumChildren + ")");
} else {
- setValueString(data)/*fValueString = data*/;
+ setValueString(data);
}
}
}
-
- public boolean verifyValue(String expression) {
- return false;
- }
}
\ No newline at end of file
package net.sourceforge.phpeclipse.xdebug.php.model;
+import org.eclipse.debug.core.DebugEvent;
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);
+
+ renderValueString(rowValue);
}
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"))
- setValueString(data)/*fValueString=data*/;
- else
- setValueString("not defined")/*fValueString="not defined"*/;
+ public boolean setValue(String expression) throws DebugException {
+ if (isValid(expression)) {
+ renderValueString(expression);
+ fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
+ return true;
}
- if (value==0)
- setValueString("false")/*fValueString="false"*/;
- else if (value==1)
- setValueString("false")/*fValueString="true"*/;
- else
- setValueString("not defined")/*fValueString="not defined"*/;
+ return false;
}
- public boolean verifyValue(String expression) {
- int value=-1;
+ private void renderValueString(String data) {
+ if (data.equals("0") || data.toLowerCase().equals("false")) {
+ setValueString("false");
+ } else if (data.equals("1") || data.toLowerCase().equals("true")) {
+ setValueString("true");
+ }
+ }
+
+ private boolean isValid(String expression) {
+ int value = -1;
try {
- value=Integer.parseInt(expression);
+ value = Integer.parseInt(expression);
} catch (NumberFormatException e) {
- expression=expression.toLowerCase();
+ expression = expression.toLowerCase();
if (expression.equals("true") || expression.equals("false"))
return true;
else
return false;
}
- if ((value>=0)&& (value <=1))
+ if ((value >= 0)&& (value <= 1))
return true;
return false;
}
+
+ public boolean verifyValue(String expression) {
+ return isValid(expression);
+ }
}
\ No newline at end of file
package net.sourceforge.phpeclipse.xdebug.php.model;
+import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.w3c.dom.Node;
public class XDebugFloatValue extends XDebugAbstractValue {
- public XDebugFloatValue(XDebugStackFrame variable, Node value) throws DebugException {
- super(variable, value);
+ public XDebugFloatValue(XDebugStackFrame stackFrame, Node value) throws DebugException {
+ super(stackFrame, value);
+
+ if (isValid(rowValue)) {
+ setValueString(rowValue);
+ }
}
public boolean supportsValueModification() {
return true;
}
- public void renderValueString(String data) {
- setValueString(data)/*fValueString = data*/;
+ public boolean setValue(String expression) throws DebugException {
+ if (isValid(expression)) {
+ setValueString(expression);
+ fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
+ return true;
+ }
+
+ return false;
}
public boolean verifyValue(String expression) {
+ return isValid(expression);
+ }
+
+ private boolean isValid(String expression) {
try {
Float.parseFloat(expression);
} catch (NumberFormatException e) {
package net.sourceforge.phpeclipse.xdebug.php.model;
+import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.w3c.dom.Node;
public class XDebugIntValue extends XDebugAbstractValue {
- public XDebugIntValue(XDebugStackFrame frame, Node value) throws DebugException {
- super(frame, value);
+ public XDebugIntValue(XDebugStackFrame stackFrame, Node value) throws DebugException {
+ super(stackFrame, value);
+
+ if (isValid(rowValue)) {
+ setValueString(rowValue);
+ }
}
public boolean supportsValueModification() {
return true;
}
- public void renderValueString(String dataString) {
- setValueString(dataString)/*fValueString = dataString*/;
+ public boolean setValue(String expression) throws DebugException {
+ if (isValid(expression)) {
+ setValueString(expression);
+ fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
+ return true;
+ }
+
+ return false;
}
-
- public boolean verifyValue(String expression) {
+
+ private boolean isValid(String expression) {
try {
Integer.parseInt(expression);
} catch (NumberFormatException e) {
}
return true;
}
+
+ public boolean verifyValue(String expression) {
+ return isValid(expression);
+ }
}
\ No newline at end of file
package net.sourceforge.phpeclipse.xdebug.php.model;
+import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
+
import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IVariable;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
public class XDebugObjectValue extends XDebugAbstractValue {
+ private int NumChildren;
+
public XDebugObjectValue(XDebugStackFrame variable, Node value) throws DebugException {
super(variable, value);
- }
- public void renderValueString(String data) {
- setValueString(data)/*fValueString = data*/;
- }
+ NumChildren = 0;
+ if (!PHPDebugUtils.getAttributeValue(value, "numchildren").equals("")) {
+ NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(value, "numchildren"));
+ }
- public boolean verifyValue(String expression) {
- return false;
+ if (NumChildren > 0) {
+ NodeList property = value.getChildNodes();
+ IVariable[] Variables = new IVariable[property.getLength()];
+
+ for (int i = 0; i<property.getLength(); i++) {
+ Node propertyNode = property.item(i);
+ Variables[i] = new XDebugVariable(variable, propertyNode);
+ }
+
+ setChildren(Variables);
+ }
+
+ String className = PHPDebugUtils.getAttributeValue(value,"classname");
+ if(!"".equals(className)) {
+ setValueString(className);
+ }
}
}
\ No newline at end of file
}
public void renderValueString(String data) {
- setValueString("\"" + data + "\"")/*fValueString = "\"" + data + "\""*/;
- }
-
- public boolean supportsValueModification() {
- return true;
- }
-
- public boolean verifyValue(String expression) {
- return true;
+ setValueString("\"" + data + "\"");
}
}
\ No newline at end of file
package net.sourceforge.phpeclipse.xdebug.php.model;
+import net.sourceforge.phpeclipse.xdebug.core.Base64;
+
+import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.w3c.dom.Node;
public class XDebugStringValue extends XDebugAbstractValue {
public XDebugStringValue(XDebugStackFrame variable, Node value) throws DebugException {
super(variable, value);
- }
- public void renderValueString(String data) {
- setValueString("\"" + data + "\"")/*fValueString = "\"" + data + "\""*/;
+ rowValue = new String(Base64.decode(rowValue));
+
+ setValueString(rowValue);
}
- public boolean supportsValueModification() {
+ public boolean setValue(String expression) throws DebugException {
+ setValueString(expression);
+ fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
return true;
}
- public boolean verifyValue(String expression) {
+ public boolean supportsValueModification() {
return true;
}
}
\ No newline at end of file
public class XDebugValue extends XDebugAbstractValue {
public XDebugValue(XDebugStackFrame variable, Node value) throws DebugException {
super(variable, value);
- }
-
- public void renderValueString(String data) {
- setValueString("uninitialized")/*fValueString = "uninitialized"*/;
- }
- public boolean verifyValue(String expression) {
- return false;
+ setValueString("uninitialized");
}
}
\ No newline at end of file
fValue = new XDebugStringValue(frame, property);
else if (typeName.equals("array") )
fValue = new XDebugArrayValue(frame, property);
- else if (typeName.equals("hash") )
- fValue = new XDebugArrayValue(frame, property);
else if (typeName.equals("object") )
- fValue = new XDebugArrayValue(frame, property);
+ fValue = new XDebugObjectValue(frame, property);
else if (typeName.equals("resource") )
fValue = new XDebugResourceValue(frame, property);
else
* @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
*/
public boolean verifyValue(String expression) throws DebugException {
- return fValue.verifyValue(expression);
+ /*return true; */return fValue.verifyValue(expression);
}
/* (non-Javadoc)