当前位置: 首页>>代码示例>>Java>>正文


Java IJavaValue.getSignature方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:32,代码来源:Value.java

示例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;
  }
 
开发者ID:jgalenson,项目名称:codehint,代码行数:59,代码来源:EclipseUtils.java


注:本文中的org.eclipse.jdt.debug.core.IJavaValue.getSignature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。