View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 2001-2004 The Apache Software Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  /*
21   * $Id: TypeCheckError.java,v 1.2.4.1 2005/09/05 11:42:57 pvedula Exp $
22   */
23  
24  package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
25  
26  import com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode;
27  
28  /**
29   * @author Jacek Ambroziak
30   * @author Santiago Pericas-Geertsen
31   */
32  public class TypeCheckError extends Exception {
33      static final long serialVersionUID = 3246224233917854640L;
34      ErrorMsg _error = null;
35      SyntaxTreeNode _node = null;
36  
37      public TypeCheckError(SyntaxTreeNode node) {
38          super();
39          _node = node;
40      }
41  
42      public TypeCheckError(ErrorMsg error) {
43          super();
44          _error = error;
45      }
46  
47      public TypeCheckError(String code, Object param) {
48          super();
49          _error = new ErrorMsg(code, param);
50      }
51  
52      public TypeCheckError(String code, Object param1, Object param2) {
53          super();
54          _error = new ErrorMsg(code, param1, param2);
55      }
56  
57      public ErrorMsg getErrorMsg() {
58          return _error;
59      }
60  
61      public String getMessage() {
62          return toString();
63      }
64  
65      public String toString() {
66          String result;
67  
68          if (_error == null) {
69              if (_node != null) {
70                  _error = new ErrorMsg(ErrorMsg.TYPE_CHECK_ERR,
71                                        _node.toString());
72              } else {
73                  _error = new ErrorMsg(ErrorMsg.TYPE_CHECK_UNK_LOC_ERR);
74              }
75          }
76  
77          return _error.toString();
78      }
79  }