Gaurav Agrawal | 4f8ad17 | 2016-02-12 16:17:32 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.yangutils.parser.impl.parserutils; |
| 18 | |
| 19 | /** |
| 20 | * Error information while doing a listener's based walk is maintained in it. |
| 21 | */ |
| 22 | public class ListenerError { |
| 23 | |
Gaurav Agrawal | a04483c | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 24 | // Maintains the state of exception. |
Gaurav Agrawal | 4f8ad17 | 2016-02-12 16:17:32 +0530 | [diff] [blame] | 25 | private boolean errorFlag = false; |
| 26 | |
Gaurav Agrawal | a04483c | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 27 | // Maintains the reason of exception. |
Gaurav Agrawal | 4f8ad17 | 2016-02-12 16:17:32 +0530 | [diff] [blame] | 28 | private String errorMsg; |
| 29 | |
Gaurav Agrawal | a04483c | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 30 | // Maintains the line number of exception. |
| 31 | private int lineNumber; |
| 32 | |
| 33 | // Maintains the character position in lin of exception. |
| 34 | private int charPositionInLine; |
| 35 | |
Gaurav Agrawal | 4f8ad17 | 2016-02-12 16:17:32 +0530 | [diff] [blame] | 36 | /** |
| 37 | * Returns error flag. |
| 38 | * |
| 39 | * @return error flag. |
| 40 | */ |
| 41 | public boolean isErrorFlag() { |
| 42 | return errorFlag; |
| 43 | } |
| 44 | |
| 45 | /** |
Gaurav Agrawal | a04483c | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 46 | * Returns reason for error. |
Gaurav Agrawal | 4f8ad17 | 2016-02-12 16:17:32 +0530 | [diff] [blame] | 47 | * |
Gaurav Agrawal | a04483c | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 48 | * @return error message |
Gaurav Agrawal | 4f8ad17 | 2016-02-12 16:17:32 +0530 | [diff] [blame] | 49 | */ |
| 50 | public String getErrorMsg() { |
| 51 | return errorMsg; |
| 52 | } |
| 53 | |
| 54 | /** |
Gaurav Agrawal | a04483c | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 55 | * Returns error line number. |
| 56 | * |
| 57 | * @return error line number. |
| 58 | */ |
| 59 | public int getLineNumber() { |
| 60 | return lineNumber; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Returns error position in line. |
| 65 | * |
| 66 | * @return error character position in line. |
| 67 | */ |
| 68 | public int getCharPositionInLine() { |
| 69 | return charPositionInLine; |
| 70 | } |
| 71 | |
| 72 | /** |
Gaurav Agrawal | 4f8ad17 | 2016-02-12 16:17:32 +0530 | [diff] [blame] | 73 | * Set error flag. |
| 74 | * |
Gaurav Agrawal | a04483c | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 75 | * @param errorFlag error existence flag. |
Gaurav Agrawal | 4f8ad17 | 2016-02-12 16:17:32 +0530 | [diff] [blame] | 76 | */ |
| 77 | public void setErrorFlag(boolean errorFlag) { |
| 78 | this.errorFlag = errorFlag; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Set error message. |
| 83 | * |
| 84 | * @param errorMsg reason for error. |
| 85 | */ |
| 86 | public void setErrorMsg(String errorMsg) { |
| 87 | this.errorMsg = errorMsg; |
| 88 | } |
Gaurav Agrawal | a04483c | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * Set error line number. |
| 92 | * |
| 93 | * @param lineNumber line number of error. |
| 94 | */ |
| 95 | public void setLineNumber(int lineNumber) { |
| 96 | this.lineNumber = lineNumber; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Set error character position in line. |
| 101 | * |
| 102 | * @param charPositionInLine error character position in line. |
| 103 | */ |
| 104 | public void setCharPositionInLine(int charPositionInLine) { |
| 105 | this.charPositionInLine = charPositionInLine; |
| 106 | } |
Gaurav Agrawal | 4f8ad17 | 2016-02-12 16:17:32 +0530 | [diff] [blame] | 107 | } |