本文整理汇总了Java中org.eclipse.jdt.debug.core.IJavaValue.getSignature方法的典型用法代码示例。如果您正苦于以下问题:Java IJavaValue.getSignature方法的具体用法?Java IJavaValue.getSignature怎么用?Java IJavaValue.getSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.debug.core.IJavaValue
的用法示例。
在下文中一共展示了IJavaValue.getSignature方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equals
import org.eclipse.jdt.debug.core.IJavaValue; //导入方法依赖的package包/类
private static boolean equals(IJavaValue x, IJavaValue y, IJavaThread thread, ValueCache valueCache) {
try {
if (x == y || (x.isNull() && y.isNull()))
return true;
if (x.isNull() || y.isNull())
return false;
if (x instanceof IJavaArray && y instanceof IJavaArray) {
if (!x.getSignature().equals(y.getSignature()))
return false; // Even though arrays are covariant, using the subtype could crash when the supertype does not (e.g., normal Java array covariange bug).
IJavaArray a = (IJavaArray)x;
IJavaArray b = (IJavaArray)y;
if (a.getLength() != b.getLength())
return false;
for (int i = 0; i < a.getLength(); i++) // TODO-opt: Should I finitize this so it doesn't take too long?
if (!equals(a.getValue(i), b.getValue(i), thread, valueCache)) // Recurse on the actual values.
return false;
return true;
}
String signature = x.getSignature();
if (!signature.equals(y.getSignature())) // Short circuit if the two values are not the same type.
return false;
if ("V".equals(signature))
return true;
if (x instanceof IJavaPrimitiveValue || "Ljava/lang/String;".equals(signature))
return x.toString().equals(y.toString());
else
return valueCache.checkObjectEquality((IJavaObject)x, (IJavaObject)y, thread);
} catch (DebugException e) {
throw new RuntimeException(e);
}
}
示例2: javaStringOfValue
import org.eclipse.jdt.debug.core.IJavaValue; //导入方法依赖的package包/类
/**
* Returns a string representing the given value this is
* a legal Java expression, except in the case of arrays,
* where we show a debug-like view of them.
* @param value The value whose string representation is desired.
* @param stack The current stack frame.
* @param callToString Whether we should call toString on
* objects or simply use their default strings in Eclipse.
* @return A string that is the legal Java expression of
* the given value, except for arrays, which show their values.
* @throws DebugException if we cannot get the value.
*/
public static String javaStringOfValue(IJavaValue value, IJavaStackFrame stack, boolean callToString) throws DebugException {
String sig = value.getSignature();
if (value.isNull())
return "null";
else if (value instanceof IJavaArray) {
StringBuilder sb = new StringBuilder();
sb.append("[");
for (IJavaValue arrValue: ((IJavaArray)value).getValues()) {
if (sb.length() > 1)
sb.append(",");
sb.append(javaStringOfValue(arrValue, stack, callToString));
}
sb.append("]");
return sb.toString();
} else if ("C".equals(sig))
return "'" + value.getValueString() + "'";
else if ("Ljava/lang/String;".equals(sig))
return "\"" + value.getValueString() + "\"";
else if (callToString && value instanceof IJavaObject) {
try {
return ((IJavaObject)value).sendMessage("toString", "()Ljava/lang/String;", new IJavaValue[] { }, (IJavaThread)stack.getThread(), null).getValueString();
} catch (DebugException e) {
return value.toString();
}
}
String str = value.toString(); // For Objects, getValueString() returns just the id and not the type.
if ("NaN".equals(str) && "F".equals(sig))
return "Float.NaN";
else if ("Infinity".equals(str) && "F".equals(sig))
return "Float.POSITIVE_INFINITY";
else if ("-Infinity".equals(str) && "F".equals(sig))
return "Float.NEGATIVE_INFINITY";
else if ("NaN".equals(str) && "D".equals(sig))
return "Double.NaN";
else if ("Infinity".equals(str) && "D".equals(sig))
return "Double.POSITIVE_INFINITY";
else if ("-Infinity".equals(str) && "D".equals(sig))
return "Double.NEGATIVE_INFINITY";
else if ("F".equals(sig))
return str + "f";
else if ("D".equals(sig))
return str + "d";
else if ("J".equals(sig))
return str + "L";
return str;
}