/*
 * This file is covered by the terms of the Common Public License v1.0.
 *
 * Copyright (c) SZEDER Gábor
 *
 * Parts of this software were developed within the JEOPARD research
 * project, which received funding from the European Union's Seventh
 * Framework Programme under grant agreement No. 216682.
 */

package de.fzi.cjunit.jpf.exceptioninfo;



public class ExceptionInfoDefaultImpl implements ExceptionInfo {

	String className;
	String message;
	ExceptionInfo cause;
	StackTraceElementInfo[] stackTrace;

	public ExceptionInfoDefaultImpl(Throwable t) {
		className = t.getClass().getName();
		message = t.getMessage();
		if (t.getCause() != null) {
			cause = new ExceptionInfoDefaultImpl(t.getCause());
		}

		StackTraceElement[] origStackTrace = t.getStackTrace();
		stackTrace = new StackTraceElementInfo[origStackTrace.length];
		for (int i = 0; i < origStackTrace.length; i++) {
			stackTrace[i] = new StackTraceElementInfoDefaultImpl(
					origStackTrace[i]);
		}
	}

	public ExceptionInfoDefaultImpl(ExceptionInfo other) {
		className = other.getClassName();
		message = other.getMessage();
		if (other.hasCause()) {
			cause = new ExceptionInfoDefaultImpl(other.getCause());
		}

		StackTraceElementInfo[] origStackTrace = other.getStackTrace();
		stackTrace = new StackTraceElementInfo[origStackTrace.length];
		for (int i = 0; i < origStackTrace.length; i++) {
			stackTrace[i] = new StackTraceElementInfoDefaultImpl(
					origStackTrace[i]);
		}
	}

	@Override
	public String getClassName() {
		return className;
	}

	@Override
	public String getMessage() {
		return message;
	}

	@Override
	public StackTraceElementInfo[] getStackTrace() {
		return stackTrace;
	}

	@Override
	public boolean hasCause() {
		return cause != null;
	}

	@Override
	public ExceptionInfo getCause() {
		return cause;
	}
}

@@ -510,16 +510,262 @@
 Trace;%0A%0A
+%09public ExceptionInfoDefaultImpl(String className, String message,%0A%09%09%09StackTraceElementInfo%5B%5D stackTrace,%0A%09%09%09ExceptionInfo cause) %7B%0A%09%09this.className = className;%0A%09%09this.message = message;%0A%09%09this.stackTrace = stackTrace;%0A%09%09this.cause = cause;%0A%09%7D%0A%0A
 %09public 

add alternative constructor