KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > spi > conf > util > ConfigException


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  */

22
23 package org.enhydra.spi.conf.util;
24
25 /**
26  * Exception class thrown by class <code>Config</code>. If a syntax
27  * error is found in the configuration input stream, or if a component
28  * expects a data format for which a configuration element cannot be
29  * converted, then this exception is thrown to indicate the error.
30  *
31  * @see Config
32  * @version $Revision: 1.1 $
33  * @author John Marco
34  * @since Soda1.0
35  */

36 public class ConfigException extends Exception JavaDoc {
37     /**
38      * The <code>reason</code> field may contain this value to indicate
39      * that the cause of the current exception is unknown.
40      *
41      * @see ConfigException#reason
42      */

43     public static final int UNKNOWN = 0;
44
45     /**
46      * The <code>reason</code> field may contain this value to indicate
47      * that a syntax error in the configuration input file or stream
48      * caused this exception.
49      *
50      * @see ConfigException#reason
51      */

52     public static final int NOT_FOUND = 1;
53
54     /**
55      * The <code>reason</code> field may contain this value to indicate
56      * that a syntax error in the configuration input file or stream
57      * caused this exception.
58      *
59      * @see ConfigException#reason
60      */

61     public static final int SYNTAX = 2;
62
63     /**
64      * The <code>reason</code> field may contain this value to indicate
65      * that a component expects a different number of elements than
66      * are provided in the configuration file for a particular key.
67      *
68      * @see ConfigException#reason
69      */

70     public static final int COUNT = 3;
71
72     /**
73      * The <code>reason</code> field may contain this value to indicate
74      * that a configuration element could not be converted from its
75      * internal string form to the requested type.
76      *
77      * @see ConfigException#reason
78      */

79     public static final int FORMAT = 4;
80
81     /**
82      * Internal constant to indicate the highest valid <code>reason</code>
83      * code.
84      *
85      * @see ConfigException#reason
86      */

87     private static final int MAX_REASON = 4;
88
89     /**
90      * Indicates the cause (if known) of the current exception.
91      *
92      * @see ConfigException#UNKNOWN
93      * @see ConfigException#SYNTAX
94      * @see ConfigException#COUNT
95      * @see ConfigException#FORMAT
96      */

97     public int reason;
98
99     /**
100      * Creates a new ConfigException object with no informational string
101      * and a <code>reason</code> field of <code>UNKNOWN</code>.
102      *
103      * @see ConfigException#reason
104      */

105     public
106     ConfigException()
107     {
108     super("Unknown reason");
109     reason = UNKNOWN;
110     }
111
112     /**
113      * Creates a new ConfigException object with the specified informational
114      * string and a <code>reason</code> field of <code>UNKNOWN</code>.
115      *
116      * @param s Informational string to store in the exception object.
117      *
118      * @see ConfigException#reason
119      */

120     public
121     ConfigException(String JavaDoc s)
122     {
123     super(s);
124     reason = UNKNOWN;
125     }
126
127     /**
128      * Constructs a new exception with the specified cause.
129      *
130      * @param cause The cause (which is saved for later retrieval by the
131      * Throwable.getCause() method).
132      * A null value is permitted, and indicates that the cause is
133      * nonexistent or unknown.
134      */

135     public ConfigException (Throwable JavaDoc cause) {
136         super (cause);
137     }
138
139     /**
140      * Constructs a new exception with the specified cause and a detail message.
141      *
142      * @param msg A detailed message describing the expection.
143      * @param cause The cause (which is saved for later retrieval by the
144      * Throwable.getCause() method).
145      * A null value is permitted, and indicates that the cause is
146      * nonexistent or unknown.
147      */

148     public ConfigException (String JavaDoc msg, Throwable JavaDoc cause) {
149         super (msg,cause);
150     }
151
152     /**
153      * Creates a new ConfigException object with the specified informational
154      * string and the specified <code>reason</code> field.
155      *
156      * @param s Informational string to store in the exception object.
157      * @param r Reason code to store in the <code>reason</code> field.
158      *
159      * @see ConfigException#reason
160      */

161     public
162     ConfigException(int r, String JavaDoc s)
163     {
164     super(s);
165     if ((r < 0) || (r > MAX_REASON)) reason = UNKNOWN;
166     else reason = r;
167     }
168 }
169
Popular Tags