home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 July / Chip_1998-07_cd.bin / zkuste / JBuilder / BDK / Win / bdk_sep97.exe / _SETUP.1 / EncapsulatedEventException.java < prev    next >
Encoding:
Java Source  |  1997-09-10  |  2.1 KB  |  84 lines

  1. /*
  2.  *
  3.  * @(#) EncapsulatedEventException.java 1.3@(#)
  4.  *
  5.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  6.  * 
  7.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  8.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  9.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  10.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  11.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  12.  * THIS SOFTWARE OR ITS DERIVATIVES.
  13.  * 
  14.  */
  15.  
  16. /**
  17.  * <p>
  18.  * sunw.demo.encapsulatedEvents.EncapsulatedEventException
  19.  * </p>
  20.  *
  21.  * @version 1.0
  22.  * @author  Laurence P. G. Cable
  23.  */
  24.  
  25. package sunw.demo.encapsulatedEvents;
  26.  
  27. /**
  28.  * Implementors of EncapsulatedListener use this Exception class to throw
  29.  * Encapsulated Event specific exceptions back to the Event Source.
  30.  *
  31.  * For instance if a Listener is processing an EncapsulatedEvent that is
  32.  * encapsulating a FooEvent, delivered to the FooListener interface method:
  33.  * <code> void fooHappened(FooEvent fe) throws BadFooException; </code>
  34.  * then in order for the EncapsulatedEventListener to throw the
  35.  * BadFooException it should invoke:
  36.  * <code>  throw new EncapsulatedEventException(new BadFooException()); </code>
  37.  */
  38.  
  39. public class EncapsulatedEventException extends RuntimeException {
  40.     
  41.     protected Exception exception;
  42.  
  43.     /**
  44.      * public constructor
  45.      */
  46.  
  47.     public EncapsulatedEventException(Exception e) {
  48.         this(e, null);
  49.     }
  50.  
  51.     /**
  52.      * public constructor
  53.      */
  54.  
  55.     public EncapsulatedEventException(Exception e, String s) {
  56.     super(s);
  57.  
  58.         if (e == null)
  59.             throw new IllegalArgumentException("null exception param");
  60.  
  61.         exception = e;
  62.     }
  63.  
  64.     /**
  65.      * @returns the Exception Object itself
  66.      */
  67.  
  68.     public Exception getException() { return exception; }
  69.  
  70.     /**
  71.      * @returns the Class of the Exception Object itself.
  72.      */
  73.  
  74.     public Class getExceptionClass() { return exception.getClass(); }
  75.  
  76.     /** 
  77.      * @returns the name of the Class of the Exception Object itself.
  78.      */
  79.  
  80.     public String getExceptionClassName() {
  81.     return exception.getClass().getName(); 
  82.     }
  83. }
  84.