KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > CommandLineErrorHandler


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  */

19
20 import org.xml.sax.ErrorHandler JavaDoc;
21 import org.xml.sax.SAXException JavaDoc;
22 import org.xml.sax.SAXParseException JavaDoc;
23
24 /**
25  * <p>
26  * <code>CommandLineErrorHandler</code> is a simple SAX
27  * <code>ErrorHandler</code> that prints out errors and fatal errors to
28  * the command line. Warnings are ignored.
29  * </p>
30  */

31 public class CommandLineErrorHandler implements ErrorHandler JavaDoc {
32
33     /**
34      * <p>
35      * Indicates a warning has occurred.
36      * </p>
37      *
38      * @param e the parsing exception that triggered this warning.
39      * @throws <code>SAXException</code> - allows for the exception to be
40      * re-thrown.
41      */

42     public void warning(SAXParseException JavaDoc e) throws SAXException JavaDoc {
43         // No action... warnings are OK
44
}
45     
46     /**
47      * <p>
48      * Indicates an error has occurred.
49      * </p>
50      *
51      * @param e the parsing exception that triggered this error.
52      * @throws <code>SAXException</code> - allows for the exception to be
53      * re-thrown.
54      */

55     public void error(SAXParseException JavaDoc e) throws SAXException JavaDoc {
56         System.out.println("Error occurred: " + e.getMessage());
57         throw e;
58     }
59     
60     /**
61      * <p>
62      * Indicates a fatal error has occurred.
63      * </p>
64      *
65      * @param e the parsing exception that triggered this fatal error.
66      * @throws <code>SAXException</code> - allows for the exception to be
67      * re-thrown.
68      */

69     public void fatalError(SAXParseException JavaDoc e) throws SAXException JavaDoc {
70         System.out.println("Fatal error occurred: " + e.getMessage());
71         throw e;
72     }
73
74 }
75
Popular Tags