Committed by
Gerrit Code Review
[ONOS-3877]Parser Exception
Change-Id: I5970210492f75dfccd8ffbf1ffe8464f729337da
Showing
2 changed files
with
156 additions
and
0 deletions
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/exceptions/ParserException.java
0 → 100644
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.exceptions; | ||
18 | + | ||
19 | +/** | ||
20 | + * Base class for exceptions in parser operations. | ||
21 | + */ | ||
22 | +public class ParserException extends Exception { | ||
23 | + | ||
24 | + private static final long serialVersionUID = 20160211L; | ||
25 | + private int lineNumber; | ||
26 | + private int charPositionInLine; | ||
27 | + private String fileName; | ||
28 | + private String msg; | ||
29 | + | ||
30 | + /** | ||
31 | + * Create a new parser exception. | ||
32 | + */ | ||
33 | + public ParserException() { | ||
34 | + super(); | ||
35 | + } | ||
36 | + | ||
37 | + /** | ||
38 | + * Creates a new parser exception with given message. | ||
39 | + * | ||
40 | + * @param message the detail of exception in string | ||
41 | + */ | ||
42 | + public ParserException(String message) { | ||
43 | + super(message); | ||
44 | + } | ||
45 | + | ||
46 | + /** | ||
47 | + * Creates a new parser exception from given message and cause. | ||
48 | + * | ||
49 | + * @param message the detail of exception in string | ||
50 | + * @param cause underlying cause of the error | ||
51 | + */ | ||
52 | + public ParserException(final String message, final Throwable cause) { | ||
53 | + super(message, cause); | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * Creates a new parser exception from cause. | ||
58 | + * | ||
59 | + * @param cause underlying cause of the error | ||
60 | + */ | ||
61 | + public ParserException(final Throwable cause) { | ||
62 | + super(cause); | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * Returns line number of the exception. | ||
67 | + * | ||
68 | + * @return line number of the exception | ||
69 | + */ | ||
70 | + public int getLineNumber() { | ||
71 | + return this.lineNumber; | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Returns YANG file name of the exception. | ||
76 | + * | ||
77 | + * @return YANG file name of the exception | ||
78 | + */ | ||
79 | + public String getFileName() { | ||
80 | + return this.fileName; | ||
81 | + } | ||
82 | + | ||
83 | + /** | ||
84 | + * Returns position of the exception. | ||
85 | + * | ||
86 | + * @return position of the exception | ||
87 | + */ | ||
88 | + public int getCharPositionInLine() { | ||
89 | + return this.charPositionInLine; | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * Returns msg detail of exception in string. | ||
94 | + * | ||
95 | + * @return msg detail of exception in string | ||
96 | + */ | ||
97 | + public String getMsg() { | ||
98 | + return this.msg; | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * Sets line number of YANG file. | ||
103 | + * | ||
104 | + * @param line line number of YANG file | ||
105 | + */ | ||
106 | + public void setLine(int line) { | ||
107 | + this.lineNumber = line; | ||
108 | + } | ||
109 | + | ||
110 | + /** | ||
111 | + * Sets position of exception. | ||
112 | + * | ||
113 | + * @param charPosition position of exception | ||
114 | + */ | ||
115 | + public void setCharPosition(int charPosition) { | ||
116 | + this.charPositionInLine = charPosition; | ||
117 | + } | ||
118 | + | ||
119 | + /** | ||
120 | + * Sets the detail of exception in string. | ||
121 | + * | ||
122 | + * @param msg the detail of exception in string | ||
123 | + */ | ||
124 | + public void setMsg(String msg) { | ||
125 | + this.msg = msg; | ||
126 | + } | ||
127 | + | ||
128 | + /** | ||
129 | + * Sets file name in parser exception. | ||
130 | + * | ||
131 | + * @param fileName YANG file name | ||
132 | + */ | ||
133 | + public void setFileName(String fileName) { | ||
134 | + this.fileName = fileName; | ||
135 | + } | ||
136 | +} |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/exceptions/package-info.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
5 | + * use this file except in compliance with the License. You may obtain a copy of | ||
6 | + * 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, WITHOUT | ||
12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
13 | + * License for the specific language governing permissions and limitations under | ||
14 | + * the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/** | ||
18 | + * Custom parser exceptions. | ||
19 | + */ | ||
20 | +package org.onosproject.yangutils.parser.exceptions; |
-
Please register or login to post a comment