libjava/ChangeLog:
[official-gcc.git] / libjava / classpath / gnu / javax / crypto / key / KeyAgreementException.java
blob405f011adde6ccf02f6402d9699d569e523dcdbf
1 /* KeyAgreementException.java --
2 Copyright (C) 2003, 2006 Free Software Foundation, Inc.
4 This file is a part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or (at
9 your option) any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19 USA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu.javax.crypto.key;
41 import gnu.java.lang.CPStringBuilder;
43 import java.io.PrintStream;
44 import java.io.PrintWriter;
45 import java.io.Serializable;
46 import java.security.KeyManagementException;
48 /**
49 * A generic exception indicating that an unexpected condition has been detected
50 * during the setup and/or processing of a key agreement protocol exchange.
52 public class KeyAgreementException
53 extends KeyManagementException
54 implements Serializable
56 /** @serial The possibly <code>null</code> <i>root</i> cause exception. */
57 private Throwable cause = null;
59 /**
60 * Constructs a new instance of <code>KeyAgreementException</code>. The
61 * root exception and the detailed message are <code>null</code>.
63 public KeyAgreementException()
65 super();
68 /**
69 * Constructs a new instance of <code>KeyAgreementException</code> with a
70 * detailed message. The <i>root</i> exception is <code>null</code>.
72 * @param detail a possibly <code>null</code> string containing details of
73 * the exception.
74 * @see Throwable#getMessage()
76 public KeyAgreementException(String detail)
78 super(detail);
81 /**
82 * Constructs a new instance of <code>KeyAgreementException</code> with a
83 * detailed message and a <i>root</i> exception.
85 * @param detail a possibly <code>null</code> string containing details of
86 * the exception.
87 * @param cause a possibly <code>null</code> root exception that caused this
88 * exception.
89 * @see Throwable#getMessage()
90 * @see #getCause()
92 public KeyAgreementException(String detail, Throwable cause)
94 super(detail);
95 this.cause = cause;
98 /**
99 * Returns the cause of this throwable or <code>null</code> if the cause is
100 * nonexistent or unknown. The <i>cause</i> is the throwable that caused this
101 * exception to be thrown.
103 * @return the possibly <code>null</code> exception that caused this one.
105 public Throwable getCause()
107 return cause;
111 * Prints this exception's stack trace to <code>System.err</code>. If this
112 * exception has a <i>root</i> exception; the stack trace of the <i>root</i>
113 * exception is also printed to <code>System.err</code>.
115 public void printStackTrace()
117 super.printStackTrace();
118 if (cause != null)
119 cause.printStackTrace();
123 * Prints this exception's stack trace to a print stream. If this exception
124 * has a <i>root</i> exception; the stack trace of the <i>root</i> exception
125 * is also printed to the print stream.
127 * @param ps the non-null print stream to which to print.
129 public void printStackTrace(PrintStream ps)
131 super.printStackTrace(ps);
132 if (cause != null)
133 cause.printStackTrace(ps);
137 * Prints this exception's stack trace to a print writer. If this exception
138 * has a <i>root</i> exception; the stack trace of the <i>root</i> exception
139 * is also printed to the print writer.
141 * @param pw the non-null print writer to use for output.
143 public void printStackTrace(PrintWriter pw)
145 super.printStackTrace(pw);
146 if (cause != null)
147 cause.printStackTrace(pw);
151 * Returns the string representation of this exception. The string
152 * representation contains this exception's class name, its detailed messsage,
153 * and if it has a <i>root</i> exception, the string representation of the
154 * root exception. This string representation is meant for debugging and is
155 * not meant to be interpreted programmatically.
157 * @return the non-null string representation of this exception.
158 * @see Throwable#getMessage()
160 public String toString()
162 CPStringBuilder sb = new CPStringBuilder(this.getClass().getName()).append(": ")
163 .append(super.toString());
164 if (cause != null)
165 sb.append("; caused by: ").append(cause.toString());
166 return sb.toString();