KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > utils > IgnoreAllErrorHandler


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

17 package com.sun.org.apache.xml.internal.security.utils;
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 /**
26  * This {@link org.xml.sax.ErrorHandler} does absulutely nothing but logging
27  * the events.
28  *
29  * @author Christian Geuer-Pollmann
30  */

31 public class IgnoreAllErrorHandler implements ErrorHandler JavaDoc {
32
33     /** {@link java.util.logging} logging facility */
34     static java.util.logging.Logger JavaDoc log =
35         java.util.logging.Logger.getLogger(
36             IgnoreAllErrorHandler.class.getName());
37
38     /** Field throwExceptions */
39     static final boolean warnOnExceptions = System.getProperty(
40         "com.sun.org.apache.xml.internal.security.test.warn.on.exceptions", "false").equals("true");
41
42     /** Field throwExceptions */
43     static final boolean throwExceptions = System.getProperty(
44         "com.sun.org.apache.xml.internal.security.test.throw.exceptions", "false").equals("true");
45
46     
47     /** @inheritDoc */
48     public void warning(SAXParseException JavaDoc ex) throws SAXException JavaDoc {
49         if (IgnoreAllErrorHandler.warnOnExceptions) {
50             log.log(java.util.logging.Level.WARNING, "", ex);
51         }
52         if (IgnoreAllErrorHandler.throwExceptions) {
53             throw ex;
54         }
55     }
56
57
58     /** @inheritDoc */
59     public void error(SAXParseException JavaDoc ex) throws SAXException JavaDoc {
60         if (IgnoreAllErrorHandler.warnOnExceptions) {
61             log.log(java.util.logging.Level.SEVERE, "", ex);
62         }
63         if (IgnoreAllErrorHandler.throwExceptions) {
64             throw ex;
65         }
66     }
67
68
69
70     /** @inheritDoc */
71     public void fatalError(SAXParseException JavaDoc ex) throws SAXException JavaDoc {
72         if (IgnoreAllErrorHandler.warnOnExceptions) {
73             log.log(java.util.logging.Level.WARNING, "", ex);
74         }
75         if (IgnoreAllErrorHandler.throwExceptions) {
76             throw ex;
77         }
78     }
79 }
80
Popular Tags