KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > xquery > normalize > NormalizeException


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.xquery.normalize;
24
25 import org.xquark.xquery.parser.XQueryException;
26
27 /**
28  * This class describes a normalized exception for various use in classe ExpressionNormalizeVisitor.<BR>
29  * <BR>
30  */

31 public class NormalizeException extends XQueryException {//extends java.lang.RuntimeException {
32

33     //*************************** Constants declaration:
34

35     /** Error code for exception that have no associated error code. */
36     public static final int NO_CODE = 0;
37     /** TODO */
38     public static final int TODO1 = 1;
39     /** TODO */
40     public static final int TODO2 = 2;
41
42     //*************************** Properties declaration:
43

44     /** The error code of this exception. */
45     private int errorCode;
46
47     /** The underlying exception (or error) of this exception. */
48     private java.lang.Throwable JavaDoc exception;
49
50     //*************************** Constructor declaration:
51

52     /**
53      * Constructor with error code.
54      * @param code the code featuring the kind of error (see constants).
55      */

56     public NormalizeException(int code) {
57         this(code, "",null);
58     }
59
60     /**
61      * Constructor with message.
62      * @param msg a message to describe the exception.
63      */

64     public NormalizeException(java.lang.String JavaDoc msg) {
65         this(NormalizeException.NO_CODE, msg, null);
66     }
67
68     /**
69      * Constructor with error code and message.
70      * @param code the code featuring the kind of error (see constants).
71      * @param msg a message to describe the exception.
72      */

73     public NormalizeException(int code, java.lang.String JavaDoc msg) {
74         this(code, msg, null);
75     }
76
77     /**
78      * Constructor with message and underlying exception.
79      * @param msg a message to describe the exception.
80      * @param exception the underlying exception (or error).
81      */

82     public NormalizeException(java.lang.String JavaDoc msg, java.lang.Throwable JavaDoc exception) {
83         this(NormalizeException.NO_CODE, msg, exception);
84     }
85
86     /**
87      * Constructor with error code, message and underlying exception.
88      * @param code the code featuring the kind of error (see constants).
89      * @param msg a message to describe the exception.
90      * @param exception the underlying exception (or error).
91      */

92     public NormalizeException(int code, java.lang.String JavaDoc msg, java.lang.Throwable JavaDoc exception) {
93         super(msg);
94         this.errorCode = code;
95         this.exception = exception;
96     }
97
98     /**
99      * Constructor with error code, message and underlying exception.
100      * @param code the code featuring the kind of error (see constants).
101      * @param msg a message to describe the exception.
102      * @param exception the underlying exception (or error).
103      */

104     public NormalizeException(int code, java.lang.Throwable JavaDoc exception) {
105         super(exception.getMessage());
106         this.errorCode = code;
107         this.exception = exception;
108     }
109
110     //*************************** Other methods declaration:
111

112     /**
113      * To get the code of this exception/error.
114      * @return the error code.
115      */

116     public int getCode() {
117         return this.errorCode;
118     }
119
120     /**
121      * To get the exception of this exception/error.
122      * @return the underlying exception.
123      */

124     public java.lang.Throwable JavaDoc getException() {
125         return this.exception;
126     }
127 }
128
Popular Tags