|
1 /* |
|
2 * Licensed to the Apache Software Foundation (ASF) under one |
|
3 * or more contributor license agreements. See the NOTICE file |
|
4 * distributed with this work for additional information |
|
5 * regarding copyright ownership. The ASF licenses this file |
|
6 * to you under the Apache License, Version 2.0 (the "License"); |
|
7 * you may not use this file except in compliance with the License. |
|
8 * You may obtain a copy of the License at |
|
9 * |
|
10 * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 * |
|
12 * Unless required by applicable law or agreed to in writing, software |
|
13 * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 * See the License for the specific language governing permissions and |
|
16 * limitations under the License. |
|
17 */ |
|
18 /* |
|
19 * $Id: $ |
|
20 */ |
|
21 |
|
22 package com.sun.org.apache.xml.internal.serializer.dom3; |
|
23 |
|
24 import org.w3c.dom.DOMError; |
|
25 import org.w3c.dom.DOMErrorHandler; |
|
26 |
|
27 /** |
|
28 * This is the default implementation of the ErrorHandler interface and is |
|
29 * used if one is not provided. The default implementation simply reports |
|
30 * DOMErrors to System.err. |
|
31 * |
|
32 * @xsl.usage internal |
|
33 */ |
|
34 final class DOMErrorHandlerImpl implements DOMErrorHandler { |
|
35 |
|
36 /** |
|
37 * Default Constructor |
|
38 */ |
|
39 DOMErrorHandlerImpl() { |
|
40 } |
|
41 |
|
42 /** |
|
43 * Implementation of DOMErrorHandler.handleError that |
|
44 * adds copy of error to list for later retrieval. |
|
45 * |
|
46 */ |
|
47 public boolean handleError(DOMError error) { |
|
48 boolean fail = true; |
|
49 String severity = null; |
|
50 if (error.getSeverity() == DOMError.SEVERITY_WARNING) { |
|
51 fail = false; |
|
52 severity = "[Warning]"; |
|
53 } else if (error.getSeverity() == DOMError.SEVERITY_ERROR) { |
|
54 severity = "[Error]"; |
|
55 } else if (error.getSeverity() == DOMError.SEVERITY_FATAL_ERROR) { |
|
56 severity = "[Fatal Error]"; |
|
57 } |
|
58 |
|
59 System.err.println(severity + ": " + error.getMessage() + "\t"); |
|
60 System.err.println("Type : " + error.getType() + "\t" + "Related Data: " |
|
61 + error.getRelatedData() + "\t" + "Related Exception: " |
|
62 + error.getRelatedException() ); |
|
63 |
|
64 return fail; |
|
65 } |
|
66 } |