From: Stefan T. <th...@us...> - 2002-05-21 17:28:28
|
Update of /cvsroot/xpg-xml/edu/iicm/xpg/statemachine In directory usw-pr-cvs1:/tmp/cvs-serv32015 Added Files: TransitionException.java Log Message: new Exception --- NEW FILE: TransitionException.java --- /*********************************************************************** * @(#)$RCSfile: TransitionException.java,v $ * * Copyright (c) 2001 IICM, Graz University of Technology * Schiesstattgasse 4a, A-8010 Graz, Austria. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License (LGPL) * as published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***********************************************************************/ package edu.iicm.xpg.statemachine; //---------------------------------------------------------------------- /** * @author Stefan Thalauer * @version $Revision: 1.1 $ */ public class TransitionException extends Exception { protected Exception exception_; //---------------------------------------------------------------------- /** */ public TransitionException () { super(); exception_ = null; } //---------------------------------------------------------------------- /** */ public TransitionException (String message) { super(message); exception_ = null; } //---------------------------------------------------------------------- /** Create a new TransitionException wrapping an existing exception. * * The existing exception will be embedded in the new * one, and its message will become the default message for * the TransitionException. * * @param exc The exception to be wrapped in a TransitionException. */ public TransitionException (Exception exc) { super(); exception_ = exc; } //---------------------------------------------------------------------- /** Create a new TransitionException from an existing exception. * * The existing exception will be embedded in the new * one, but the new exception will have its own message. * * @param message The detail message. * @param exc The exception to be wrapped in a TransitionException. */ public TransitionException (String message, Exception exc) { super(message); exception_ = exc; } //---------------------------------------------------------------------- /** Return a detail message for this exception. * * If there is an embedded exception, and if the TransitionException * has no detail message of its own, this method will return * the detail message from the embedded exception.</p> * * @return The error or warning message. */ public String getMessage () { String message = super.getMessage(); if (message == null && exception_ != null) { return exception_.getMessage(); } else { return message; } } //---------------------------------------------------------------------- /** Return the embedded exception, if any. * * @return The embedded exception, or null if there is none. */ public Exception getException () { return exception_; } //---------------------------------------------------------------------- /** Override toString to pick up any embedded exception. * * @return A string representation of this exception. */ public String toString () { if (exception_ != null) { return exception_.toString(); } else { return super.toString(); } } } |