-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXMLLoaderErrorHandler.java
More file actions
83 lines (71 loc) · 2.44 KB
/
Copy pathXMLLoaderErrorHandler.java
File metadata and controls
83 lines (71 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* This file is part of OpenDS (Open Source Driving Simulator).
* Copyright (C) 2015 Rafael Math
*
* OpenDS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenDS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenDS. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.opends.tools;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
/**
* This class represents an error handler for the validation
* process of the XML file.
*
* @author Rafael Math
*/
public class XMLLoaderErrorHandler implements ErrorHandler
{
private String xmlFileName;
/**
* Creates a new error handler by saving the file name of the
* xml file.
*
* @param xmlFileName
* Name of the related xml file.
*/
public XMLLoaderErrorHandler(String xmlFileName)
{
this.xmlFileName = xmlFileName;
}
/**
* This method will print a message to the console if an error
* occurred while validating the xml file.
*/
public void error(SAXParseException arg0) throws SAXException
{
System.err.println("ERROR while validating xml file: " + arg0.getMessage() +
"(File: \"" + xmlFileName + "\", line " + arg0.getLineNumber() + ")");
throw arg0;
}
/**
* This method will print a message to the console if a fatal
* error occurred while validating the xml file.
*/
public void fatalError(SAXParseException arg0) throws SAXException
{
System.err.println("FATAL ERROR while validating xml file: " + arg0.getMessage() +
"(File: \"" + xmlFileName + "\", line " + arg0.getLineNumber() + ")");
throw arg0;
}
/**
* This method will print a message to the console if a warning
* occurred while validating the xml file.
*/
public void warning(SAXParseException arg0) throws SAXException
{
System.err.println("WARNING while validating xml file: " + arg0.getMessage() +
"(File: \"" + xmlFileName + "\", line " + arg0.getLineNumber() + ")");
}
}