KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > support > sqlstore > query > jqlc > ErrorMsg


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * ErrorMsg.java
26  *
27  * Created on April 3, 2000
28  */

29
30 package com.sun.jdo.spi.persistence.support.sqlstore.query.jqlc;
31
32 import java.util.ResourceBundle JavaDoc;
33
34 import com.sun.jdo.api.persistence.support.JDOQueryException;
35 import com.sun.jdo.api.persistence.support.JDOFatalInternalException;
36 import com.sun.jdo.api.persistence.support.JDOUnsupportedOptionException;
37 import com.sun.jdo.spi.persistence.utility.I18NHelper;
38 import com.sun.jdo.spi.persistence.utility.logging.Logger;
39
40 /**
41  *
42  * @author Michael Bouschen
43  * @version 0.1
44  */

45 public class ErrorMsg
46 {
47     /**
48      *
49      */

50     protected String JavaDoc context = null;
51     
52     /**
53      * I18N support
54      */

55     protected final static ResourceBundle JavaDoc messages =
56       I18NHelper.loadBundle(ErrorMsg.class);
57
58     /** The logger */
59     private static Logger logger = LogHelperQueryCompilerJDO.getLogger();
60     
61     /**
62      *
63      */

64     public String JavaDoc getContext()
65     {
66         return context;
67     }
68     
69     /**
70      *
71      */

72     public void setContext(String JavaDoc name)
73     {
74         context = name;
75     }
76
77     /**
78      * Indicates an error situation.
79      * @param line line number
80      * @param col column number
81      * @param msg error message
82      */

83     public void error(int line, int col, String JavaDoc msg)
84         throws JDOQueryException
85     {
86         JDOQueryException ex;
87         if (line > 1)
88         {
89             // include line and column info
90
Object JavaDoc args[] = {context, new Integer JavaDoc(line), new Integer JavaDoc(col), msg};
91             ex = new JDOQueryException(I18NHelper.getMessage(
92                 messages, "jqlc.errormsg.generic.msglinecolumn", args)); //NOI18N
93
}
94         else if (col > 0)
95         {
96             // include column info
97
Object JavaDoc args[] = {context, new Integer JavaDoc(col), msg};
98             ex = new JDOQueryException(I18NHelper.getMessage(
99                 messages, "jqlc.errormsg.generic.msgcolumn", args)); //NOI18N
100
}
101         else
102         {
103             Object JavaDoc args[] = {context, msg};
104             ex = new JDOQueryException(I18NHelper.getMessage(
105                 messages, "jqlc.errormsg.generic.msg", args)); //NOI18N
106
}
107         logger.throwing("jqlc.ErrorMsg", "error", ex);
108         throw ex;
109     }
110     
111     /**
112      * Indicates that a feature is not supported by the current release.
113      * @param line line number
114      * @param col column number
115      * @param msg message
116      */

117     public void unsupported(int line, int col, String JavaDoc msg)
118         throws JDOUnsupportedOptionException
119     {
120         JDOUnsupportedOptionException ex;
121         if (line > 1)
122         {
123             // include line and column info
124
Object JavaDoc args[] = {context, new Integer JavaDoc(line), new Integer JavaDoc(col), msg};
125             ex = new JDOUnsupportedOptionException(I18NHelper.getMessage(
126                 messages, "jqlc.errormsg.generic.msglinecolumn", args)); //NOI18N
127
}
128         else if (col > 0)
129         {
130             // include column info
131
Object JavaDoc args[] = {context, new Integer JavaDoc(col), msg};
132             ex = new JDOUnsupportedOptionException(I18NHelper.getMessage(
133                 messages, "jqlc.errormsg.generic.msgcolumn", args)); //NOI18N
134

135         }
136         else
137         {
138             Object JavaDoc args[] = {context, msg};
139             ex = new JDOUnsupportedOptionException(I18NHelper.getMessage(
140                 messages, "jqlc.errormsg.generic.msg", args)); //NOI18N
141
}
142         logger.throwing("jqlc.ErrorMsg", "unsupported", ex);
143         throw ex;
144     }
145     
146     /**
147      * Indicates a fatal situation (implementation error).
148      * @param msg error message
149      */

150     public void fatal(String JavaDoc msg)
151         throws JDOFatalInternalException
152     {
153         JDOFatalInternalException ex = new JDOFatalInternalException(msg);
154         logger.throwing("jqlc.ErrorMsg", "fatal", ex);
155         throw ex;
156     }
157
158     /**
159      * Indicates a fatal situation (implementation error).
160      * @param msg error message
161      */

162     public void fatal(String JavaDoc msg, Exception JavaDoc nested)
163         throws JDOFatalInternalException
164     {
165         JDOFatalInternalException ex = new JDOFatalInternalException(msg, nested);
166         logger.throwing("jqlc.ErrorMsg", "fatal", ex);
167         throw ex;
168     }
169 }
170
171
172
Popular Tags