Gridarta Editor
ErrorViewCollectorErrorHandler.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.model.errorview;
21 
22 import org.jetbrains.annotations.NotNull;
23 import org.xml.sax.ErrorHandler;
24 import org.xml.sax.SAXException;
25 import org.xml.sax.SAXParseException;
26 
32 public class ErrorViewCollectorErrorHandler implements ErrorHandler {
33 
37  @NotNull
39 
44  @NotNull
46 
54  public ErrorViewCollectorErrorHandler(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final ErrorViewCategory errorViewCategory) {
55  this.errorViewCollector = errorViewCollector;
56  this.errorViewCategory = errorViewCategory;
57  }
58 
59  @Override
60  public void warning(final SAXParseException exception) throws SAXException {
61  errorViewCollector.addWarning(errorViewCategory, exception.getMessage());
62  }
63 
64  @Override
65  public void error(final SAXParseException exception) throws SAXException {
66  errorViewCollector.addError(errorViewCategory, exception.getMessage());
67  }
68 
69  @Override
70  public void fatalError(final SAXParseException exception) throws SAXException {
71  errorViewCollector.addError(errorViewCategory, exception.getMessage());
72  }
73 
74 }
Convenience class for adding messages to a ErrorView instance using a fixed category name...
ErrorViewCollectorErrorHandler(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final ErrorViewCategory errorViewCategory)
Creates a new instance.
void addWarning(@NotNull final ErrorViewCategory category)
Adds a warning message.
final ErrorViewCollector errorViewCollector
The ErrorViewCollector instance for adding messages.
Defines possible error categories for ErrorView instances.
An ErrorHandler that adds all reported problems to an ErrorViewCollector instance.
void addError(@NotNull final ErrorViewCategory category)
Adds an error message.
final ErrorViewCategory errorViewCategory
The ErrorViewCategory to use when adding messages to errorViewCollector.