]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
7f844619a8d8d6ae71cdd510d2ec0c41fb3f4c69
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2  *  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3  *
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.
7  *
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.
12  *
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
16  */
17
18 package com.mysql.clusterj.jdbc.antlr;
19
20 import org.antlr.runtime.RecognitionException;
21
22 import java.util.List;
23
24 /**
25  * Default implementation of an ErrorListener that simply delegates all error reporting back to the
26  * Recognizer it came from. 
27  * Author: kroepke
28  */
29 public class BaseErrorListener implements ErrorListener {
30
31     protected final RecognizerErrorDelegate recognizerErrorDelegate;
32     protected boolean seenErrors = false;
33
34     public BaseErrorListener(final RecognizerErrorDelegate recognizerErrorDelegate) {
35         if (recognizerErrorDelegate == null) {
36             throw new IllegalArgumentException("You must pass a recognizer delegate");
37         }
38         this.recognizerErrorDelegate = recognizerErrorDelegate;
39     }
40
41     public void displayRecognitionError(final String[] tokenNames, final RecognitionException e) {
42         recognizerErrorDelegate.originalDisplayError(tokenNames, e);
43         seenErrors = true;
44     }
45
46     public void reportError(final RecognitionException e) {
47         recognizerErrorDelegate.originalReportError(e);
48     }
49
50     public String getErrorHeader(final RecognitionException e) {
51         return recognizerErrorDelegate.originalGetErrorHeader(e);
52     }
53
54     public String getErrorMessage(final RecognitionException e, final String[] tokenNames) {
55         return recognizerErrorDelegate.originalGetErrorMessage(e, tokenNames);
56     }
57
58     public void emitErrorMessage(final String msg) {
59         recognizerErrorDelegate.originalEmitErrorMessage(msg);
60     }
61
62     public boolean hasErrors() {
63         return seenErrors;
64     }
65
66     public List<RecognitionException> getErrors() {
67         return null;
68     }
69 }