KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibm > webdav > impl > WebDAVErrorHandler


1 /*
2  * (C) Copyright Simulacra Media Ltd, 2004. All rights reserved.
3  *
4  * The program is provided "AS IS" without any warranty express or
5  * implied, including the warranty of non-infringement and the implied
6  * warranties of merchantibility and fitness for a particular purpose.
7  * Simulacra Media Ltd will not be liable for any damages suffered by you as a result
8  * of using the Program. In no event will Simulacra Media Ltd be liable for any
9  * special, indirect or consequential damages or lost profits even if
10  * Simulacra Media Ltd has been advised of the possibility of their occurrence.
11  * Simulacra Media Ltd will not be liable for any third party claims against you.
12  *
13  */

14
15 package com.ibm.webdav.impl;
16
17 import org.xml.sax.SAXParseException JavaDoc;
18
19 public class WebDAVErrorHandler extends org.xml.sax.helpers.DefaultHandler JavaDoc {
20
21     private String JavaDoc resourceName = null;
22     private int errorCount = 0;
23 /** Create an error listener for handling XML parsing errors in entity request
24 * or response bodies, or properties files.
25 *
26 * @param resourceName the URL of the resource involved in the request or response
27 */

28 public WebDAVErrorHandler(String JavaDoc resourceName) {
29     super();
30     this.resourceName = resourceName;
31 }
32 /**
33  * This method is called by the XML Parser when some error occurs.
34  * <p>
35  * This implementation prints the error to standard error and counts the errors
36  * detected. Applications can then access the number of errors in order to raise
37  * an exception after parsing.
38  * </p>
39  * @see org.xml.sax.helpers.DefaultHandler
40  */

41 public void error(SAXParseException JavaDoc e) throws SAXParseException JavaDoc {
42     errorCount++;
43
44     System.err.println(resourceName + ":" + e.getLineNumber() + ":" + e.getColumnNumber() + ": " + e.getMessage());
45 }
46
47 public void warning(SAXParseException JavaDoc e) throws SAXParseException JavaDoc {
48     errorCount++;
49
50     System.err.println(resourceName + ":" + e.getLineNumber() + ":" + e.getColumnNumber() + ": " + e.getMessage());
51 }
52
53 public void fatalError(SAXParseException JavaDoc e) throws SAXParseException JavaDoc {
54     errorCount++;
55
56     System.err.println(resourceName + ":" + e.getLineNumber() + ":" + e.getColumnNumber() + ": " + e.getMessage());
57
58         throw e;
59 }
60
61 /** Return the nuber of errors counted by this error listener.
62  */

63 public int getErrorCount() {
64     return errorCount;
65 }
66 }
67
Popular Tags