CIVLHeapException.java

package dev.civl.mc.state.IF;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import dev.civl.mc.model.IF.CIVLException.Certainty;
import dev.civl.mc.model.IF.CIVLProperty;
import dev.civl.mc.model.IF.CIVLSource;
import dev.civl.sarl.IF.expr.SymbolicExpression;

/**
 * Extends an execution exception with a state at which error occurred.
 * 
 * @author siegel
 * 
 */
public class CIVLHeapException extends CIVLStateException {

	/**
	 * Required by eclipse
	 */
	private static final long serialVersionUID = -5422700931342739728L;
	private SymbolicExpression heapValue;
	private String dyscopeName;
	private int dyscopeID;
	private HeapErrorKind heapErrorKind;
	private int heapFieldID;
	private int heapObjectID;

	public enum HeapErrorKind {
		NONEMPTY, UNREACHABLE
	}

	public CIVLHeapException(CIVLProperty property, Certainty certainty, State state,
			String dyscopeName, int dyscopeID, SymbolicExpression heapValue,
			HeapErrorKind heapError, CIVLSource source) {
		super(property, certainty, "", state, source);
		this.dyscopeName = dyscopeName;
		this.dyscopeID = dyscopeID;
		this.heapValue = heapValue;
		this.heapErrorKind = heapError;
	}

	public CIVLHeapException(CIVLProperty property, Certainty certainty, State state,
			String dyscopeName, int dyscopeID, SymbolicExpression heapValue,
			int fieldID, int objectID, HeapErrorKind heapError,
			CIVLSource source) {
		super(property, certainty, "", state, source);
		this.dyscopeName = dyscopeName;
		this.dyscopeID = dyscopeID;
		this.heapValue = heapValue;
		this.heapErrorKind = heapError;
		this.heapFieldID = fieldID;
		this.heapObjectID = objectID;
	}

	public CIVLSource source() {
		return this.source;
	}

	public State state() {
		return this.state;
	}

	public CIVLProperty civlProperty() {
		return this.property;
	}

	public Certainty certainty() {
		return this.certainty;
	}

	public String message() {
		return this.message;
	}

	public String toString() {
		String result = super.toString() + "\n";
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		PrintStream ps = new PrintStream(baos);

		ps.print(state.toString());
		result += baos.toString();
		return result;
	}

	public SymbolicExpression heapValue() {
		return heapValue;
	}

	public String dyscopeName() {
		return dyscopeName;
	}

	public int dyscopeID() {
		return dyscopeID;
	}

	public HeapErrorKind heapErrorKind() {
		return heapErrorKind;
	}

	public int heapFieldID() {
		return heapFieldID;
	}

	public int heapObjectID() {
		return heapObjectID;
	}
}