package es.ejie.frmk.presentacion.sesiondatos.utilidades;

import java.io.PrintWriter;
import java.io.StringWriter;

public class Q70ContextoEJIERuntimeException extends RuntimeException {

	private String componente = null;
	private String clase = null;
	private String metodo = null;
	private Throwable throwable = null;

	/**
	 * @param s
	 */
	public Q70ContextoEJIERuntimeException(String componente, String clase, String metodo, String s, Throwable t) {
		super(s);
		setComponente(componente);
		setClase(clase);
		setMetodo(metodo);
		setThrowable(t);
	}

	/**
	 * @return
	 */
	public String getClase() {
		return clase;
	}

	/**
	 * @return
	 */
	public String getComponente() {
		return componente;
	}

	/**
	 * @return
	 */
	public String getMetodo() {
		return metodo;
	}

	/**
	 * @param string
	 */
	public void setClase(String string) {
		clase = string;
	}

	/**
	 * @param string
	 */
	public void setComponente(String string) {
		componente = string;
	}

	/**
	 * @param string
	 */
	public void setMetodo(String string) {
		metodo = string;
	}

	/**
	 * @return
	 */
	public Throwable getThrowable() {
		return throwable;
	}

	/**
	 * @param throwable
	 */
	public void setThrowable(Throwable throwable) {
		this.throwable = throwable;
	}

	/**
	 * @see java.lang.Throwable#printStackTrace()
	 */
	public void printStackTrace() {
		if (null != throwable)
			throwable.printStackTrace();
		super.printStackTrace();
	}
	/**
	 * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
	 */
	public void printStackTrace(PrintWriter s) {
		s.println("Excepcion:  " + this.getClass().toString());
		s.println("Q70Mensaje:    " + this.getMessage());
		s.println("Componente: " + componente);
		s.println("Clase:      " + clase);
		s.println("Método:     " + metodo);
		s.println("******************************");
		if (null != throwable) {
			StringWriter sw = new StringWriter();
			PrintWriter aux = new PrintWriter(sw);

			throwable.printStackTrace(aux);
			s.println(sw.toString());
		}
	}

}