• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IJavaArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jdt.debug.core.IJavaArray的典型用法代码示例。如果您正苦于以下问题:Java IJavaArray类的具体用法?Java IJavaArray怎么用?Java IJavaArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IJavaArray类属于org.eclipse.jdt.debug.core包,在下文中一共展示了IJavaArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: valueToString

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
private String valueToString(IJavaValue value) {
	if(value instanceof IJavaArray) {
		try {
			IJavaArray array = (IJavaArray) value;
			IJavaValue[] values = array.getValues();
			String s = "";
			for(int i = 0; i < values.length; i++) {
				if(!s.isEmpty())
					s += ", ";
				s += valueSpecialChars(values[i]);
			}
			return "{" + s + "}";
		}
		catch (DebugException e) {
			e.printStackTrace();
			return null;
		}
	}
	else
		return valueSpecialChars(value);
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:22,代码来源:StackFrameModel.java


示例2: isMatrix

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
@Override
public boolean isMatrix() {
	if(dimensions < 2)
		return false;

	try {
		for(int i = 0; i < elements.length-1; i++) {
			if(elements[i].isNull() || elements[i+1].isNull())
				return false;
			else
				if(((IJavaArray) elements[i]).getLength() != ((IJavaArray) elements[i+1]).getLength())
					return false;
		}
	} catch (DebugException e) {
		e.printStackTrace(); // TODO termination
	}

	return true;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:20,代码来源:ArrayModel.java


示例3: readFImage

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
FImage readFImage(IJavaObject var) throws DebugException {
	int width = ((IJavaPrimitiveValue)var.getField("width", true).getValue()).getIntValue();
	int height = ((IJavaPrimitiveValue)var.getField("height", true).getValue()).getIntValue();
	
	IJavaValue[] data = ((IJavaArray)var.getField("pixels", false).getValue()).getValues();
	
	FImage img = new FImage(width, height);
	
	for (int y=0; y<height; y++) {
		IJavaValue[] row = ((IJavaArray) data[y]).getValues();
		
		for (int x=0; x<width; x++) {
			img.pixels[y][x] = ((IJavaPrimitiveValue) row[x]).getFloatValue();
		}
	}
	
	return img;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:ImageDetailPane.java


示例4: displayResult

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
@Override
protected void displayResult(final IEvaluationResult result) {
	final Shell shell = JDIDebugUIPlugin.getShell();
	shell.getDisplay().asyncExec(new Runnable() {
		
		@Override
		public void run() {
		    MessageBox mb = new MessageBox(shell, SWT.OK);
		    mb.setText("Visualize Variable History:");		
		    IJavaValue value = result.getValue();
			if (value instanceof IJavaArray) {
					ArraysMainController.addExpression(new ArrayExpression(result.getSnippet(), (IJavaArray)value));
			}
		}
	});
}
 
开发者ID:bilalsal,项目名称:EclipseTracer,代码行数:17,代码来源:VisualizeEditorValueAction.java


示例5: getReachableObjects

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
private void getReachableObjects(IJavaValue value, Set<IJavaObject> objs) throws DebugException {
	if (value instanceof IJavaArray) {
		IJavaArray arr = (IJavaArray)value;
		if (objs.add(arr) && !EclipseUtils.isPrimitive(Signature.getElementType(arr.getSignature())) && !arr.getSignature().equals("[Ljava/lang/String;"))
			for (IJavaValue elem: arr.getValues())
				getReachableObjects(elem, objs);
	} else if (value instanceof IJavaObject) {
		IJavaObject obj = (IJavaObject)value;
		if (objs.add(obj)) {
			// We use the internal API here because the Eclipse one must get each field's value one-by-one and so is much slower.
			ObjectReference obj2 = ((JDIObjectValue)obj).getUnderlyingObject();
			if (obj2 != null)  // null values fail this test
				for (Map.Entry<Field, Value> field: obj2.getValues(obj2.referenceType().allFields()).entrySet())
					if (isUsefulStaticDFSField(field.getKey().declaringType().name(), field.getKey()))
						getReachableObjects(JDIValue.createValue((JDIDebugTarget)stack.getDebugTarget(), field.getValue()), objs);
		}
	}
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:19,代码来源:SideEffectHandler.java


示例6: getHashCode

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
protected int getHashCode(IJavaValue value) throws DebugException {
	if (value == null || value.isNull())
		return -37;
	else if (value instanceof IJavaPrimitiveValue)
		return ((IJavaPrimitiveValue)value).getIntValue() * 5 + 137;  // We add a number to avoid clustering around 0. 
	else if (value instanceof IJavaArray) {  // Heuristically only look at the array's length and its first ten elements.
		IJavaArray array = (IJavaArray)value;
		int length = array.getLength();
		int hashCode = length * 5 + array.getSignature().hashCode() * 7;
		for (int i = 0; i < 10 && i < length; i++)
			hashCode = 31 * hashCode + getHashCode(array.getValue(i));
		return hashCode;
	} else if (value instanceof IJavaClassObject)
		return ((IJavaClassObject)value).getInstanceType().getName().hashCode() * 11;
	else if ("V".equals(value.getSignature()))
		return -137;
	else {
		IJavaObject obj = (IJavaObject)value;
		if ("Ljava/lang/String;".equals(obj.getSignature()))  // Fast-path Strings
			return obj.toString().hashCode();
		return ((IJavaPrimitiveValue)obj.sendMessage("hashCode", "()I", new IJavaValue[] { }, thread, null)).getIntValue();
	}
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:24,代码来源:Value.java


示例7: getToString

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
/**
 * Gets a readable toString by looking inside arrays.
 * @param value The value whose toString we want.
 * @return A toString that looks inside arrays.
 */
private static String getToString(IJavaValue value) {
	try {
		if (value instanceof IJavaArray) {
			IJavaArray arr = (IJavaArray)value;
    		StringBuilder sb = new StringBuilder();
    		sb.append("[");
    		for (int i = 0; i < 5 && i < arr.getLength(); i++) {
    			if (i > 0)
    				sb.append(",");
    			sb.append(getToString(arr.getValue(i)));
    		}
    		if (arr.getLength() > 5)
    			sb.append(",").append(arr.getLength() - 5).append(" more...");
    		sb.append("]");
    		return sb.toString();
    	} else
    		return value.toString();
	} catch (DebugException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:27,代码来源:Value.java


示例8: extendArray

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
/**
 * Extends the given array by indexing into it or
 * getting its length.
 * @param arr The array to extend.
 * @return A new expression that extends the given array.
 * @throws DebugException
 */
private Expression extendArray(Expression arr) throws DebugException {
	Result arrResult = expressionEvaluator.getResult(arr, Collections.<Effect>emptySet());
	int arrLen = ((IJavaArray)arrResult.getValue().getValue()).getLength();
	Set<Effect> arrEffects = arrResult.getEffects();
	ExpressionWeightedList indexChoices = new ExpressionWeightedList(expressionEvaluator, weights);
	for (Expression expr: primitives)
		if (EclipseUtils.isInt(expr.getStaticType())) {
			int index = Integer.parseInt(expressionEvaluator.getValue(expr, arrEffects).getValueString());
			if (index >= 0 && index < arrLen)
				indexChoices.addWeighted(expr);
		}
	if (indexChoices.isEmpty() || random.nextDouble() * ExprStats.ARR_OP_PROB < ExprStats.ARR_LEN_PROB)
		return expressionMaker.makeFieldAccess(arr, "length", intType, null, thread);
	else
		return expressionMaker.makeArrayAccess(arr, indexChoices.getWeighted(), thread);
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:24,代码来源:StochasticExpressionGenerator.java


示例9: getUnitFromTopStackFrame

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
private static String getUnitFromTopStackFrame(IJavaThread thread) throws CoreException {
	if (!thread.hasStackFrames()) {
		return null;
	}

	IStackFrame top = thread.getTopStackFrame();
	if (top.getVariables().length > 0) {
		for (IVariable var : top.getVariables()) {
			try {
				IValue value = var.getValue();
				if (value instanceof IJavaValue) {
					IJavaObject javaValue = (IJavaObject) value;
					IJavaDebugTarget debugTarget = thread.getDebugTarget().getAdapter(IJavaDebugTarget.class);
					IJavaValue arg = debugTarget.newValue("Fully Qualified Name");
					// the signature (2nd argument) can be retrieved with javap. Unit extends soot.tagkit.Host for the tag support
					// -> javap -cp soot-trunk.jar -s soot.tagkit.Host
					// the signature is in the output under "descriptor"
					IJavaType type = javaValue.getJavaType();
					if (isTagHost(type)) { // check, if this is a unit, which contains Tags
						IJavaValue fqnTag = javaValue.sendMessage("getTag", "(Ljava/lang/String;)Lsoot/tagkit/Tag;", new IJavaValue[] { arg }, thread,
								false);
						IJavaValue tagValue = ((IJavaObject) fqnTag).sendMessage("getValue", "()[B", new IJavaValue[0], thread, false);
						IJavaArray byteArray = (IJavaArray) tagValue;
						byte[] b = new byte[byteArray.getLength()];
						for (int i = 0; i < b.length; i++) {
							IJavaPrimitiveValue byteValue = (IJavaPrimitiveValue) byteArray.getValue(i);
							b[i] = byteValue.getByteValue();
						}
						String currentUnitFqn = new String(b);
						return currentUnitFqn;
					}
				}
			} catch (Exception e) {
				logger.error("Couldn't retrieve variable " + var.getName() + " from top stack frame", e);
			}
		}
	}
	return null;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:40,代码来源:StackExaminer.java


示例10: ArrayReferenceModel

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
public ArrayReferenceModel(IJavaArray array, RuntimeModel runtime, IReferenceModel sourceReference) throws DebugException {
	super(array, runtime);
	if(sourceReference != null) {
		VariableInfo info = sourceReference.getVariableRole();
		if(info != null) {
			for(IReferenceModel ref : getModelElements()) {
				VariableInfo copy = info.convertToArrayAccessDim(ref);
				ref.setVariableRole(copy);
			}
		}
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:13,代码来源:ArrayReferenceModel.java


示例11: ArrayModel

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
ArrayModel(IJavaArray array, RuntimeModel runtime) throws DebugException {
	super(array, runtime);
	int len = Math.min(array.getLength(), PandionJView.getMaxArrayLength());
	elementsModel = new ArrayList<T>(len);
	elements = array.getValues();
	dimensions = getDimensions(array);
	componentType = getComponentType(array);
	initArray(array, len);
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:10,代码来源:ArrayModel.java


示例12: initArray

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
private void initArray(IJavaArray array, int length) throws DebugException {
	for(int i = 0; i < length - 1; i++)
		elementsModel.add(createElement((IJavaVariable) array.getVariable(i), i));

	if(length > 0)
		elementsModel.add(createElement((IJavaVariable) array.getVariable(array.getLength()-1), array.getLength()-1));
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:8,代码来源:ArrayModel.java


示例13: getValues

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
private Object getValues(IJavaArray javaArray) {
	try {
		String compType = getComponentType(javaArray);
		int dimensions = getDimensions(javaArray);
		PrimitiveType primitive = PrimitiveType.match(compType);
		IJavaValue[] values = javaArray.getValues();
		Object array = null;
		if(primitive != null) {
			Class<?> type = primitive.getArrayClass(dimensions);
			array = Array.newInstance(type, values.length);
		}
		else
			array = Array.newInstance(Object.class, values.length);

		if(getDimensions(javaArray) == 1) {
			if(primitive == null) {
				for(int j = 0; j < values.length; j++)
					if(!values[j].isNull())
						Array.set(array, j, values[j].getValueString());
			}
			else {
				primitive.fillPrimitiveValues(array, values);
			}
		}	
		else {
			for(int i = 0; i < values.length; i++) {
				IJavaValue val = values[i];
				if(!val.isNull())
					Array.set(array, i, getValues((IJavaArray) val));
			}
		}
		return array;
	}
	catch (DebugException e) {
		e.printStackTrace();
		getRuntimeModel().setTerminated();
		return new Object[0];
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:40,代码来源:ArrayModel.java


示例14: getMatrixDimension

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
public Dimension getMatrixDimension() {
	if(!isMatrix())
		throw new IllegalStateException("not a matrix");

	try {
		return new Dimension(getLength() == 0 ? 0 : ((IJavaArray) elements[0]).getLength(), getLength());
	} catch (DebugException e) {
		e.printStackTrace();
		getRuntimeModel().setTerminated();
	}
	return new Dimension(0, 0);
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:13,代码来源:ArrayModel.java


示例15: ArrayExpression

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
public ArrayExpression(String name, IJavaArray value) {
	this.name = name;
	this.value = value;
	controllers = new HashMap<FieldImpl, AbstractArrayController>();
	try {
		compType = ((IJavaArrayType)value.getJavaType()).getComponentType();
		compJDIType = ((JDIType)compType).getUnderlyingType();
	} catch (DebugException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}
 
开发者ID:bilalsal,项目名称:EclipseTracer,代码行数:14,代码来源:ArrayExpression.java


示例16: cacheMethodResults

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
/**
   * Caches the results of method calls in the given list.
   * Any call to evaluateStatements before another call to
   * this method will use the cached value instead of
   * re-evaluating it.
   * @param stmts The list of statements, which may contain
   * non-call statements.  This is probably the list of
   * component statements used to generate the statements
   * we currently want to evaluate.
   * @throws DebugException
   */
  public void cacheMethodResults(List<? extends Statement> stmts) throws DebugException {
  	// Find the non-inlined method calls.
  	ArrayList<Expression> calls = new ArrayList<Expression>();
  	addCalls(stmts, calls);
methodResultsMap = new HashMap<String, Integer>();
  	if (!calls.isEmpty()) {  // Cache the method call results so the runtime can use them.
  		IJavaArray newValue = ((IJavaArrayType)methodResultsField.getJavaType()).newInstance(calls.size());
  		for (int i = 0; i < calls.size(); i++) {
  			newValue.setValue(i, expressionEvaluator.getValue(calls.get(i), Collections.<Effect>emptySet()));
  			methodResultsMap.put(calls.get(i).toString(), i);
  		}
  		methodResultsField.setValue(newValue);
  	}
  }
 
开发者ID:jgalenson,项目名称:codehint,代码行数:26,代码来源:EvaluationManager.java


示例17: charArrOfValue

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
private static char[] charArrOfValue(Value wrapper) throws DebugException {
	IJavaValue value = wrapper.getValue();
	if (value.isNull())
		return null;
	IJavaArray array = (IJavaArray)value;
	char[] result = new char[array.getLength()];
	IJavaValue[] arrayValues = array.getValues();
	for (int i = 0; i < result.length; i++)
		result[i] = charOfValue(arrayValues[i]);
	return result;
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:12,代码来源:StaticEvaluator.java


示例18: byteArrOfValue

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
private static byte[] byteArrOfValue(Value wrapper) throws DebugException {
	IJavaValue value = wrapper.getValue();
	if (value.isNull())
		return null;
	IJavaArray array = (IJavaArray)value;
	byte[] result = new byte[array.getLength()];
	IJavaValue[] arrayValues = array.getValues();
	for (int i = 0; i < result.length; i++)
		result[i] = byteOfValue(arrayValues[i]);
	return result;
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:12,代码来源:StaticEvaluator.java


示例19: longArrOfValue

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
private static long[] longArrOfValue(Value wrapper) throws DebugException {
	IJavaValue value = wrapper.getValue();
	if (value.isNull())
		return null;
	IJavaArray array = (IJavaArray)value;
	long[] result = new long[array.getLength()];
	IJavaValue[] arrayValues = array.getValues();
	for (int i = 0; i < result.length; i++)
		result[i] = longOfValue(arrayValues[i]);
	return result;
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:12,代码来源:StaticEvaluator.java


示例20: intArrOfValue

import org.eclipse.jdt.debug.core.IJavaArray; //导入依赖的package包/类
private static int[] intArrOfValue(Value wrapper) throws DebugException {
	IJavaValue value = wrapper.getValue();
	if (value.isNull())
		return null;
	IJavaArray array = (IJavaArray)value;
	int[] result = new int[array.getLength()];
	IJavaValue[] arrayValues = array.getValues();
	for (int i = 0; i < result.length; i++)
		result[i] = intOfValue(arrayValues[i]);
	return result;
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:12,代码来源:StaticEvaluator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MQConstants类代码示例发布时间:2022-05-23
下一篇:
Java RefCountedMemory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap