2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 package org.openecomp.sparky.synchronizer;
28 import java.io.PrintWriter;
30 import org.xml.sax.ErrorHandler;
31 import org.xml.sax.SAXException;
32 import org.xml.sax.SAXParseException;
35 * The Class MyErrorHandler.
37 public class MyErrorHandler implements ErrorHandler {
39 /** Error handler output goes here. */
40 private PrintWriter out;
43 * Instantiates a new my error handler.
47 public MyErrorHandler(PrintWriter out) {
52 * Returns a string describing parse exception details.
55 * @return the parses the exception info
57 private String getParseExceptionInfo(SAXParseException spe) {
58 String systemId = spe.getSystemId();
59 if (systemId == null) {
62 String info = "URI=" + systemId + " Line=" + spe.getLineNumber() + ": " + spe.getMessage();
66 // The following methods are standard SAX ErrorHandler methods.
67 // See SAX documentation for more info.
70 * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
73 public void warning(SAXParseException spe) throws SAXException {
74 out.println("Warning: " + getParseExceptionInfo(spe));
78 * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
81 public void error(SAXParseException spe) throws SAXException {
82 String message = "Error: " + getParseExceptionInfo(spe);
83 throw new SAXException(message);
87 * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
90 public void fatalError(SAXParseException spe) throws SAXException {
91 String message = "Fatal Error: " + getParseExceptionInfo(spe);
92 throw new SAXException(message);