KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > script > InterpreterException


1 /*
2
3    Copyright 2000-2001 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.script;
19
20 /**
21  * An exception that will be thrown when a problem is encountered in the
22  * script by an <code>Interpreter</code> interface implementation.
23  * @author <a HREF="mailto:cjolif@ilog.fr">Christophe Jolif</a>
24  * @version $Id: InterpreterException.java,v 1.6 2005/03/27 08:58:35 cam Exp $
25  */

26 public class InterpreterException extends Exception JavaDoc {
27     private int line = -1; // -1 when unknow
28
private int column = -1; // -1 when unknow
29
private Exception JavaDoc embedded = null; // null when unknown
30

31     /**
32      * Builds an instance of <code>InterpreterException</code>.
33      * @param message the <code>Exception</code> message.
34      * @param lineno the number of the line the error occurs.
35      * @param columnno the number of the column the error occurs.
36      */

37     public InterpreterException(String JavaDoc message, int lineno, int columnno) {
38         super(message);
39         line = lineno;
40         column = columnno;
41     }
42
43     /**
44      * Builds an instance of <code>InterpreterException</code>.
45      * @param exception the embedded exception.
46      * @param message the <code>Exception</code> message.
47      * @param lineno the number of the line the error occurs.
48      * @param columnno the number of the column the error occurs.
49      */

50     public InterpreterException(Exception JavaDoc exception,
51                                 String JavaDoc message, int lineno, int columnno) {
52         this(message, lineno, columnno);
53         embedded = exception;
54     }
55
56     /**
57      * Returns the line number where the error occurs. If this value is not
58      * known, returns -1.
59      */

60     public int getLineNumber() {
61         return line;
62     }
63
64     /**
65      * Returns the column number where the error occurs. If this value is not
66      * known, returns -1.
67      */

68     public int getColumnNumber() {
69         return column;
70     }
71
72     /**
73      * Returns the embedded exception. If no embedded exception is set,
74      * returns null.
75      */

76     public Exception JavaDoc getException() {
77         return embedded;
78     }
79
80     /**
81      * Returns the message of this exception. If an error message has
82      * been specified, returns that one. Otherwise, return the error message
83      * of enclosed exception or null if any.
84      */

85     public String JavaDoc getMessage() {
86         String JavaDoc msg = super.getMessage();
87         if (msg != null) {
88             return msg;
89         } else if (embedded != null) {
90             return embedded.getMessage();
91         } else {
92             return null;
93         }
94     }
95 }
96
Popular Tags