View Javadoc

1   /*
2   This file is part of the xframe software package
3   hosted at http://xframe.sourceforge.net
4   
5   Copyright (c) 2003 Kurt Riede.
6   
7   This library is free software; you can redistribute it and/or
8   modify it under the terms of the GNU Lesser General Public
9   License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11  
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16  
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21  package net.sf.xframe.xsddoc;
22  
23  import javax.xml.transform.TransformerException;
24  
25  import net.sf.xframe.ex.XFrameException;
26  import net.sf.xframe.xsddoc.util.XMLUtil;
27  
28  import org.xml.sax.SAXParseException;
29  
30  /***
31   * Exception class for excpetions occuring in the xsddoc processor.
32   *
33   * @author <a href="mailto:kriede@users.sourceforge.net">Kurt Riede</a>
34   *
35   */
36  public class ProcessorException extends XFrameException {
37  
38      /***
39       * Construct a new <code>ProcessorException</code> instance.
40       *
41       * @param message The detail message for this exception.
42       */
43      public ProcessorException(final String message) {
44          super(message);
45      }
46  
47      /***
48       * Construct a new <code>ProcessorException</code> instance.
49       *
50       * @param throwable the root cause of the exception
51       */
52      public ProcessorException(final Throwable throwable) {
53          super(throwable);
54      }
55  
56      /***
57       * Construct a new <code>ProcessorException</code> instance.
58       *
59       * @param message The detail message for this exception.
60       * @param throwable the root cause of the exception
61       */
62      public ProcessorException(final String message, final Throwable throwable) {
63          super(message, throwable);
64      }
65  
66      /***
67       * @see java.lang.Throwable#getLocalizedMessage()
68       */
69      public final String getLocalizedMessage() {
70          if (getCause() == null) {
71              return super.getLocalizedMessage();
72          } if (this.getCause() instanceof TransformerException) {
73              return XMLUtil.getLocallizedMessageAndLocation((TransformerException) getCause());
74          } else if (this.getCause() instanceof SAXParseException) {
75              return XMLUtil.getLocallizedMessageAndLocation((SAXParseException) getCause());
76          } else {
77              return getCause().getLocalizedMessage();
78          }
79      }
80  
81      /***
82       * @see java.lang.Throwable#getMessage()
83       */
84      public final String getMessage() {
85          if (getCause() == null) {
86              return super.getMessage();
87          } if (this.getCause() instanceof TransformerException) {
88              return XMLUtil.getLocallizedMessageAndLocation((TransformerException) getCause());
89          }
90          return getCause().getMessage();
91      }
92  }