blob: c5c3c8b908ed40d38d86967f31e152b651e9f1c0 [file] [log] [blame]
Gaurav Agrawal4f8ad172016-02-12 16:17:32 +05301/*
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
17package org.onosproject.yangutils.parser.impl.parserutils;
18
19/**
20 * Error information while doing a listener's based walk is maintained in it.
21 */
22public class ListenerError {
23
Gaurav Agrawala04483c2016-02-13 14:23:40 +053024 // Maintains the state of exception.
Gaurav Agrawal4f8ad172016-02-12 16:17:32 +053025 private boolean errorFlag = false;
26
Gaurav Agrawala04483c2016-02-13 14:23:40 +053027 // Maintains the reason of exception.
Gaurav Agrawal4f8ad172016-02-12 16:17:32 +053028 private String errorMsg;
29
Gaurav Agrawala04483c2016-02-13 14:23:40 +053030 // 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 Agrawal4f8ad172016-02-12 16:17:32 +053036 /**
37 * Returns error flag.
38 *
39 * @return error flag.
40 */
41 public boolean isErrorFlag() {
42 return errorFlag;
43 }
44
45 /**
Gaurav Agrawala04483c2016-02-13 14:23:40 +053046 * Returns reason for error.
Gaurav Agrawal4f8ad172016-02-12 16:17:32 +053047 *
Gaurav Agrawala04483c2016-02-13 14:23:40 +053048 * @return error message
Gaurav Agrawal4f8ad172016-02-12 16:17:32 +053049 */
50 public String getErrorMsg() {
51 return errorMsg;
52 }
53
54 /**
Gaurav Agrawala04483c2016-02-13 14:23:40 +053055 * 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 Agrawal4f8ad172016-02-12 16:17:32 +053073 * Set error flag.
74 *
Gaurav Agrawala04483c2016-02-13 14:23:40 +053075 * @param errorFlag error existence flag.
Gaurav Agrawal4f8ad172016-02-12 16:17:32 +053076 */
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 Agrawala04483c2016-02-13 14:23:40 +053089
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 Agrawal4f8ad172016-02-12 16:17:32 +0530107}