package bluej.debugger.jdi;

import bluej.debugger.DebuggerObject;
import bluej.utility.JavaUtils;

import com.sun.jdi.CharValue;
import com.sun.jdi.ClassType;
import com.sun.jdi.Field;
import com.sun.jdi.LocalVariable;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.ReferenceType;
import com.sun.jdi.StringReference;
import com.sun.jdi.Value;

import java.lang.reflect.InvocationTargetException;


| Utility methods for Jdi. Used to abstract away differences between java | 1.4 and 1.5 | | @author Davin McCall | public abstract class JdiUtils { private static JdiUtils jutils = null; private static final String nullLabel = "null";
| Factory method. Returns a JdiUtils object. | @return an object supporting the approriate feature set | public static JdiUtils getJdiUtils() { if (jutils == null) { jutils = new JdiUtils15(); } return jutils; } abstract public boolean hasGenericSig(ObjectReference obj); abstract public String genericSignature(Field f); abstract public String genericSignature(ReferenceType rt); abstract public String genericSignature(LocalVariable lv); abstract public boolean isEnum(ClassType ct);
| Return the value of a field as as string. | | <p>Values are represented differently depending on their type: | <ul> | <li>A String value is represented as a valid Java string expression. | <li>A null value is represented as "null". | * <li>An Enum value is represented as the name of the Enum constant. * <li>Any other object reference is represented as "<object reference>". * <li>A primitive value is represented as the value itself. * </ul> * * @see bluej.debugger.DebuggerObject#getInstanceFields(boolean, java.util.Map) */ public String getValueString(Value val) | |
{ | |
if (val == null) { | | return nullLabel; | | } | | public defVis else if (val instanceof StringReference) { | | return "\"" + JavaUtils.escapeString(((StringReference) val).value()) + "\""; } else if (val.type() instanceof ClassType && isEnum((ClassType) val.type())) { ClassType type = (ClassType) val.type(); Field nameField = type.fieldByName("name"); String name = ((StringReference) ((ObjectReference) val).getValue(nameField)).value(); return name; } public defVis else if (val instanceof ObjectReference) { | | return DebuggerObject.OBJECT_REFERENCE; | | } | | public defVis else if (val instanceof CharValue) { | | return "\'" + JavaUtils.escapeString(val.toString()) + "\'"; } return val.toString(); } }
top, use, map, abstract class JdiUtils

.   getJdiUtils
.   hasGenericSig
.   genericSignature
.   genericSignature
.   genericSignature
.   isEnum




49 neLoCode + 20 LoComm