Newer
Older
org.ntlab.traceDebugger / src / org / ntlab / traceDebugger / CallStackModel.java
r-isitani on 18 Nov 2019 1 KB 初コミット
package org.ntlab.traceDebugger;

import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution;
import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace;
import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint;

public class CallStackModel {
	private TracePoint tracePoint;
	
	public CallStackModel(TracePoint tracePoint) {
		this.tracePoint = tracePoint;
	}
	
	public TracePoint getTracePoint() {
		return tracePoint;
	}
	
	public MethodExecution getMethodExecution() {
		return tracePoint.getMethodExecution();
	}

	public int getCallLineNo() {
		return tracePoint.getStatement().getLineNo();
	}
	
	public String getSignature() {
		return tracePoint.getMethodExecution().getSignature();
	}
	
	public String getCallStackSignature() {
		String signature = "";		
		signature = getSignature();
		MethodExecution methodExecution = tracePoint.getMethodExecution();
		String objectType = methodExecution.getThisClassName();
		objectType = objectType.substring(objectType.lastIndexOf(".") + 1);
		boolean isConstructor = methodExecution.isConstructor();
		String declaringType = Trace.getDeclaringType(signature, isConstructor);
		declaringType = declaringType.substring(declaringType.lastIndexOf(".") + 1);
		String methodName = Trace.getMethodName(signature);
		String args = "(" + signature.split("\\(")[1];
		
		StringBuilder sb = new StringBuilder();
		sb.append(objectType);
		if (!declaringType.equals(objectType)) {
			sb.append("(" + declaringType + ")");
		}
		sb.append("." + methodName + args);
		signature = sb.toString();
		return signature;
	}	
}