2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 package com.mysql.clusterj.jdbc.antlr;
20 import org.antlr.runtime.RecognitionException;
22 import java.util.List;
25 * Default implementation of an ErrorListener that simply delegates all error reporting back to the
26 * Recognizer it came from.
29 public class BaseErrorListener implements ErrorListener {
31 protected final RecognizerErrorDelegate recognizerErrorDelegate;
32 protected boolean seenErrors = false;
34 public BaseErrorListener(final RecognizerErrorDelegate recognizerErrorDelegate) {
35 if (recognizerErrorDelegate == null) {
36 throw new IllegalArgumentException("You must pass a recognizer delegate");
38 this.recognizerErrorDelegate = recognizerErrorDelegate;
41 public void displayRecognitionError(final String[] tokenNames, final RecognitionException e) {
42 recognizerErrorDelegate.originalDisplayError(tokenNames, e);
46 public void reportError(final RecognitionException e) {
47 recognizerErrorDelegate.originalReportError(e);
50 public String getErrorHeader(final RecognitionException e) {
51 return recognizerErrorDelegate.originalGetErrorHeader(e);
54 public String getErrorMessage(final RecognitionException e, final String[] tokenNames) {
55 return recognizerErrorDelegate.originalGetErrorMessage(e, tokenNames);
58 public void emitErrorMessage(final String msg) {
59 recognizerErrorDelegate.originalEmitErrorMessage(msg);
62 public boolean hasErrors() {
66 public List<RecognitionException> getErrors() {