KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > util > ConfigException


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

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

42 public class ConfigException extends KeywordValueException {
43     /**
44      * The <code>reason</code> field may contain this value to indicate
45      * that the cause of the current exception is unknown.
46      *
47      * @see ConfigException#reason
48      */

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

58     public static final int NOT_FOUND = 1;
59
60     /**
61      * The <code>reason</code> field may contain this value to indicate
62      * that a syntax error in the configuration input file or stream
63      * caused this exception.
64      *
65      * @see ConfigException#reason
66      */

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

76     public static final int COUNT = 3;
77
78     /**
79      * The <code>reason</code> field may contain this value to indicate
80      * that a configuration element could not be converted from its
81      * internal string form to the requested type.
82      *
83      * @see ConfigException#reason
84      */

85     public static final int FORMAT = 4;
86
87     /**
88      * Internal constant to indicate the highest valid <code>reason</code>
89      * code.
90      *
91      * @see ConfigException#reason
92      */

93     private static final int MAX_REASON = 4;
94     
95     /**
96      * Indicates the cause (if known) of the current exception.
97      *
98      * @see ConfigException#UNKNOWN
99      * @see ConfigException#SYNTAX
100      * @see ConfigException#COUNT
101      * @see ConfigException#FORMAT
102      */

103     public int reason;
104
105     /**
106      * Creates a new ConfigException object with no informational string
107      * and a <code>reason</code> field of <code>UNKNOWN</code>.
108      *
109      * @see ConfigException#reason
110      */

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

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

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

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

167     public
168     ConfigException(int r, String JavaDoc s)
169     {
170     super(s);
171     if ((r < 0) || (r > MAX_REASON)) reason = UNKNOWN;
172     else reason = r;
173     }
174 }
175
Popular Tags