KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > src > SourceException


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.openide.src;
21
22 /** General exception for the source elements hierarchy. */
23 public class SourceException extends Exception JavaDoc {
24     static final long serialVersionUID =4472081442050042697L;
25     /** Create an exception. */
26     public SourceException() {
27         this(null); // NOI18N
28
}
29     /** Create an exception with a detail message.
30     * @param msg the message
31     */

32     public SourceException(String JavaDoc msg) {
33         super(msg);
34     }
35
36     public static class IO extends SourceException {
37         private java.io.IOException JavaDoc nestedException;
38         
39         public IO(java.io.IOException JavaDoc cause) {
40             this.nestedException = cause;
41         }
42         
43         public IO(String JavaDoc msg) {
44             super(msg);
45         }
46         
47         /**
48          * Returns the original I/O exception that caused the operation to fail.
49          * The function may return null in a generic case.
50          */

51         public java.io.IOException JavaDoc getReason() {
52             return nestedException;
53         }
54
55         public Throwable JavaDoc getCause() {
56             return nestedException;
57         }
58
59     }
60     
61     public static class Protection extends SourceException {
62         private Element protectionTarget;
63         
64         public Protection(Element prot) {
65             this.protectionTarget = prot;
66         }
67         
68         public Element getTarget() {
69             return this.protectionTarget;
70         }
71     }
72     
73     /** This is a wrapper over an unspecified VetoException thrown from a VetoableListener
74      * during some change.
75      */

76     public static class Veto extends SourceException {
77         private java.beans.PropertyVetoException JavaDoc reason;
78         
79         public Veto(java.beans.PropertyVetoException JavaDoc reason) {
80             this.reason = reason;
81         }
82         
83         public java.beans.PropertyVetoException JavaDoc getReason() {
84             return this.reason;
85         }
86
87         public Throwable JavaDoc getCause() {
88             return reason;
89         }
90
91     }
92 }
93
Popular Tags