KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > osgi > service > cm > ConfigurationException


1 /*
2  * $Header: /cvshome/build/org.osgi.service.cm/src/org/osgi/service/cm/ConfigurationException.java,v 1.13 2006/07/11 13:15:52 hargrave Exp $
3  *
4  * Copyright (c) OSGi Alliance (2001, 2006). All Rights Reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.osgi.service.cm;
19
20 /**
21  * An <code>Exception</code> class to inform the Configuration Admin service
22  * of problems with configuration data.
23  *
24  * @version $Revision: 1.13 $
25  */

26 public class ConfigurationException extends Exception JavaDoc {
27     static final long serialVersionUID = -1690090413441769377L;
28
29     private final String JavaDoc property;
30     private final String JavaDoc reason;
31
32     /**
33      * Nested exception.
34      */

35     private final Throwable JavaDoc cause;
36
37     /**
38      * Create a <code>ConfigurationException</code> object.
39      *
40      * @param property name of the property that caused the problem,
41      * <code>null</code> if no specific property was the cause
42      * @param reason reason for failure
43      */

44     public ConfigurationException(String JavaDoc property, String JavaDoc reason) {
45         super(property + " : " + reason);
46         this.property = property;
47         this.reason = reason;
48         this.cause = null;
49     }
50
51     /**
52      * Create a <code>ConfigurationException</code> object.
53      *
54      * @param property name of the property that caused the problem,
55      * <code>null</code> if no specific property was the cause
56      * @param reason reason for failure
57      * @param cause The cause of this exception.
58      * @since 1.2
59      */

60     public ConfigurationException(String JavaDoc property, String JavaDoc reason,
61             Throwable JavaDoc cause) {
62         super(property + " : " + reason);
63         this.property = property;
64         this.reason = reason;
65         this.cause = cause;
66     }
67
68     /**
69      * Return the property name that caused the failure or null.
70      *
71      * @return name of property or null if no specific property caused the
72      * problem
73      */

74     public String JavaDoc getProperty() {
75         return property;
76     }
77
78     /**
79      * Return the reason for this exception.
80      *
81      * @return reason of the failure
82      */

83     public String JavaDoc getReason() {
84         return reason;
85     }
86
87     /**
88      * Returns the cause of this exception or <code>null</code> if no cause
89      * was specified when this exception was created.
90      *
91      * @return The cause of this exception or <code>null</code> if no cause
92      * was specified.
93      * @since 1.2
94      */

95     public Throwable JavaDoc getCause() {
96         return cause;
97     }
98
99     /**
100      * The cause of this exception can only be set when constructed.
101      *
102      * @param cause Cause of the exception.
103      * @return This object.
104      * @throws java.lang.IllegalStateException This method will always throw an
105      * <code>IllegalStateException</code> since the cause of this
106      * exception can only be set when constructed.
107      * @since 1.2
108      */

109     public Throwable JavaDoc initCause(Throwable JavaDoc cause) {
110         throw new IllegalStateException JavaDoc();
111     }
112 }
113
Popular Tags