home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / rmi / RemoteException.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  3.2 KB  |  131 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)RemoteException.java    1.12 98/07/12
  3.  *
  4.  * Copyright 1996-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.rmi;
  16.  
  17. /**
  18.  * A <code>RemoteException</code> is the common superclass for a number of
  19.  * communication-related exceptions that may occur during the execution of a
  20.  * remote method call.  Each method of a remote interface, an interface that
  21.  * extends <code>java.rmi.Remote</code>, must list
  22.  * <code>RemoteException</code> in its throws clause.
  23.  * 
  24.  * @version 1.12, 07/12/98
  25.  * @author  Ann Wollrath
  26.  * @since   JDK1.1
  27.  */
  28. public class RemoteException extends java.io.IOException {
  29.  
  30.     /* indicate compatibility with JDK 1.1.x version of class */
  31.     private static final long serialVersionUID = -5148567311918794206L;
  32.  
  33.     /**
  34.      * Nested Exception to hold wrapped remote exception.
  35.      *
  36.      * @serial
  37.      * @since   JDK1.1
  38.      */
  39.     public Throwable detail;
  40.  
  41.     /**
  42.      * Constructs a <code>RemoteException</code> with no specified
  43.      * detail message.
  44.      * @since   JDK1.1
  45.      */
  46.     public RemoteException() {}
  47.  
  48.     /**
  49.      * Constructs a <code>RemoteException</code> with the specified
  50.      * detail message.
  51.      *
  52.      * @param s the detail message
  53.      * @since   JDK1.1
  54.      */
  55.     public RemoteException(String s) {
  56.     super(s);
  57.     }
  58.  
  59.     /**
  60.      * Constructs a <code>RemoteException</code> with the specified
  61.      * detail message and nested exception.
  62.      *
  63.      * @param s the detail message
  64.      * @param ex the nested exception
  65.      * @since   JDK1.1
  66.      */
  67.     public RemoteException(String s, Throwable ex) {
  68.     super(s);
  69.     detail = ex;
  70.     }
  71.  
  72.     /**
  73.      * Returns the detail message, including the message from the nested
  74.      * exception if there is one.
  75.      * @since   JDK1.1
  76.      */
  77.     public String getMessage() {
  78.     if (detail == null)
  79.         return super.getMessage();
  80.     else
  81.         return super.getMessage() +
  82.         "; nested exception is: \n\t" +
  83.         detail.toString();
  84.     }
  85.  
  86.     /**
  87.      * Prints the composite message and the embedded stack trace to
  88.      * the specified stream <code>ps</code>.
  89.      * @param ps the print stream
  90.      * @since JDK1.2
  91.      */
  92.     public void printStackTrace(java.io.PrintStream ps)
  93.     {
  94.     if (detail == null) {
  95.         super.printStackTrace(ps);
  96.     } else {
  97.         synchronized(ps) {
  98.         ps.println(this);
  99.         detail.printStackTrace(ps);
  100.         }
  101.     }
  102.     }
  103.  
  104.     /**
  105.      * Prints the composite message to <code>System.err</code>.
  106.      * @since JDK1.2
  107.      */
  108.     public void printStackTrace()
  109.     {
  110.     printStackTrace(System.err);
  111.     }
  112.  
  113.     /**
  114.      * Prints the composite message and the embedded stack trace to
  115.      * the specified print writer <code>pw</code>
  116.      * @param pw the print writer
  117.      * @since JDK1.2
  118.      */
  119.     public void printStackTrace(java.io.PrintWriter pw)
  120.     {
  121.     if (detail == null) {
  122.         super.printStackTrace(pw);
  123.     } else {
  124.         synchronized(pw) {
  125.         pw.println(this);
  126.         detail.printStackTrace(pw);
  127.         }
  128.     }
  129.     }
  130. }
  131.