Committed by
Gerrit Code Review
YANG construct collision detection framework added
Change-Id: I1458f9e3192641f3f90c444798c31a64536ffa5d
Showing
89 changed files
with
1610 additions
and
1049 deletions
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.datamodel; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
20 | +import org.onosproject.yangutils.utils.YangConstructType; | ||
21 | + | ||
22 | +/** | ||
23 | + * Abstraction of YANG collision function. Abstracted to unify the collision | ||
24 | + * detection functionality. | ||
25 | + */ | ||
26 | +public interface CollisionDetector { | ||
27 | + /** | ||
28 | + * Checks for the colliding child. | ||
29 | + * | ||
30 | + * @param identifierName name of identifier for which collision to be | ||
31 | + * checked | ||
32 | + * @param dataType type of the YANG construct for which collision to be | ||
33 | + * checked | ||
34 | + * @throws DataModelException if there is any collision in YANG rules in | ||
35 | + * parsed data, corresponding exception should be thrown | ||
36 | + */ | ||
37 | + void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException; | ||
38 | + | ||
39 | + /** | ||
40 | + * Check for the self collision. | ||
41 | + * | ||
42 | + * @param identifierName name of identifier for which collision to be | ||
43 | + * checked | ||
44 | + * @param dataType type of the YANG construct for which collision to be | ||
45 | + * checked | ||
46 | + * @throws DataModelException if there is any collision in YANG rules in | ||
47 | + * parsed data, corresponding exception should be thrown | ||
48 | + */ | ||
49 | + void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException; | ||
50 | +} |
... | @@ -20,7 +20,7 @@ import java.util.List; | ... | @@ -20,7 +20,7 @@ import java.util.List; |
20 | 20 | ||
21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
22 | import org.onosproject.yangutils.parser.Parsable; | 22 | import org.onosproject.yangutils.parser.Parsable; |
23 | -import org.onosproject.yangutils.parser.ParsableDataType; | 23 | +import org.onosproject.yangutils.utils.YangConstructType; |
24 | import org.onosproject.yangutils.translator.CachedFileHandle; | 24 | import org.onosproject.yangutils.translator.CachedFileHandle; |
25 | 25 | ||
26 | /*- | 26 | /*- |
... | @@ -85,7 +85,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -85,7 +85,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
85 | private String targetNode; | 85 | private String targetNode; |
86 | 86 | ||
87 | /** | 87 | /** |
88 | - * description of augment. | 88 | + * Description of augment. |
89 | */ | 89 | */ |
90 | private String description; | 90 | private String description; |
91 | 91 | ||
... | @@ -100,7 +100,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -100,7 +100,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
100 | private List<YangLeafList> listOfLeafList; | 100 | private List<YangLeafList> listOfLeafList; |
101 | 101 | ||
102 | /** | 102 | /** |
103 | - * reference. | 103 | + * Reference of the YANG augment. |
104 | */ | 104 | */ |
105 | private String reference; | 105 | private String reference; |
106 | 106 | ||
... | @@ -110,7 +110,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -110,7 +110,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
110 | private YangStatusType status; | 110 | private YangStatusType status; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | - * package of the generated java code. | 113 | + * Package of the generated java code. |
114 | */ | 114 | */ |
115 | private String pkg; | 115 | private String pkg; |
116 | 116 | ||
... | @@ -124,7 +124,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -124,7 +124,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
124 | /** | 124 | /** |
125 | * Get the augmented node. | 125 | * Get the augmented node. |
126 | * | 126 | * |
127 | - * @return the augmented node. | 127 | + * @return the augmented node |
128 | */ | 128 | */ |
129 | public String getTargetNode() { | 129 | public String getTargetNode() { |
130 | return targetNode; | 130 | return targetNode; |
... | @@ -133,7 +133,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -133,7 +133,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
133 | /** | 133 | /** |
134 | * Set the augmented node. | 134 | * Set the augmented node. |
135 | * | 135 | * |
136 | - * @param targetNode the augmented node. | 136 | + * @param targetNode the augmented node |
137 | */ | 137 | */ |
138 | public void setTargetNode(String targetNode) { | 138 | public void setTargetNode(String targetNode) { |
139 | this.targetNode = targetNode; | 139 | this.targetNode = targetNode; |
... | @@ -142,7 +142,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -142,7 +142,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
142 | /** | 142 | /** |
143 | * Get the description. | 143 | * Get the description. |
144 | * | 144 | * |
145 | - * @return the description. | 145 | + * @return the description |
146 | */ | 146 | */ |
147 | @Override | 147 | @Override |
148 | public String getDescription() { | 148 | public String getDescription() { |
... | @@ -152,7 +152,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -152,7 +152,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
152 | /** | 152 | /** |
153 | * Set the description. | 153 | * Set the description. |
154 | * | 154 | * |
155 | - * @param description set the description. | 155 | + * @param description set the description |
156 | */ | 156 | */ |
157 | @Override | 157 | @Override |
158 | public void setDescription(String description) { | 158 | public void setDescription(String description) { |
... | @@ -162,7 +162,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -162,7 +162,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
162 | /** | 162 | /** |
163 | * Get the list of leaves. | 163 | * Get the list of leaves. |
164 | * | 164 | * |
165 | - * @return the list of leaves. | 165 | + * @return the list of leaves |
166 | */ | 166 | */ |
167 | @Override | 167 | @Override |
168 | public List<YangLeaf> getListOfLeaf() { | 168 | public List<YangLeaf> getListOfLeaf() { |
... | @@ -172,7 +172,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -172,7 +172,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
172 | /** | 172 | /** |
173 | * Set the list of leaves. | 173 | * Set the list of leaves. |
174 | * | 174 | * |
175 | - * @param leafsList the list of leaf to set. | 175 | + * @param leafsList the list of leaf to set |
176 | */ | 176 | */ |
177 | private void setListOfLeaf(List<YangLeaf> leafsList) { | 177 | private void setListOfLeaf(List<YangLeaf> leafsList) { |
178 | listOfLeaf = leafsList; | 178 | listOfLeaf = leafsList; |
... | @@ -181,7 +181,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -181,7 +181,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
181 | /** | 181 | /** |
182 | * Add a leaf. | 182 | * Add a leaf. |
183 | * | 183 | * |
184 | - * @param leaf the leaf to be added. | 184 | + * @param leaf the leaf to be added |
185 | */ | 185 | */ |
186 | @Override | 186 | @Override |
187 | public void addLeaf(YangLeaf leaf) { | 187 | public void addLeaf(YangLeaf leaf) { |
... | @@ -195,7 +195,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -195,7 +195,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
195 | /** | 195 | /** |
196 | * Get the list of leaf-list. | 196 | * Get the list of leaf-list. |
197 | * | 197 | * |
198 | - * @return the list of leaf-list. | 198 | + * @return the list of leaf-list |
199 | */ | 199 | */ |
200 | @Override | 200 | @Override |
201 | public List<YangLeafList> getListOfLeafList() { | 201 | public List<YangLeafList> getListOfLeafList() { |
... | @@ -205,7 +205,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -205,7 +205,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
205 | /** | 205 | /** |
206 | * Set the list of leaf-list. | 206 | * Set the list of leaf-list. |
207 | * | 207 | * |
208 | - * @param listOfLeafList the list of leaf-list to set. | 208 | + * @param listOfLeafList the list of leaf-list to set |
209 | */ | 209 | */ |
210 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | 210 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
211 | this.listOfLeafList = listOfLeafList; | 211 | this.listOfLeafList = listOfLeafList; |
... | @@ -214,7 +214,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -214,7 +214,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
214 | /** | 214 | /** |
215 | * Add a leaf-list. | 215 | * Add a leaf-list. |
216 | * | 216 | * |
217 | - * @param leafList the leaf-list to be added. | 217 | + * @param leafList the leaf-list to be added |
218 | */ | 218 | */ |
219 | @Override | 219 | @Override |
220 | public void addLeafList(YangLeafList leafList) { | 220 | public void addLeafList(YangLeafList leafList) { |
... | @@ -228,7 +228,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -228,7 +228,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
228 | /** | 228 | /** |
229 | * Get the textual reference. | 229 | * Get the textual reference. |
230 | * | 230 | * |
231 | - * @return the reference. | 231 | + * @return the reference |
232 | */ | 232 | */ |
233 | @Override | 233 | @Override |
234 | public String getReference() { | 234 | public String getReference() { |
... | @@ -238,7 +238,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -238,7 +238,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
238 | /** | 238 | /** |
239 | * Set the textual reference. | 239 | * Set the textual reference. |
240 | * | 240 | * |
241 | - * @param reference the reference to set. | 241 | + * @param reference the reference to set |
242 | */ | 242 | */ |
243 | @Override | 243 | @Override |
244 | public void setReference(String reference) { | 244 | public void setReference(String reference) { |
... | @@ -248,7 +248,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -248,7 +248,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
248 | /** | 248 | /** |
249 | * Get the status. | 249 | * Get the status. |
250 | * | 250 | * |
251 | - * @return the status. | 251 | + * @return the status |
252 | */ | 252 | */ |
253 | @Override | 253 | @Override |
254 | public YangStatusType getStatus() { | 254 | public YangStatusType getStatus() { |
... | @@ -258,7 +258,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -258,7 +258,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
258 | /** | 258 | /** |
259 | * Set the status. | 259 | * Set the status. |
260 | * | 260 | * |
261 | - * @param status the status to set. | 261 | + * @param status the status to set |
262 | */ | 262 | */ |
263 | @Override | 263 | @Override |
264 | public void setStatus(YangStatusType status) { | 264 | public void setStatus(YangStatusType status) { |
... | @@ -268,17 +268,17 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -268,17 +268,17 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
268 | /** | 268 | /** |
269 | * Returns the type of the data as belongs-to. | 269 | * Returns the type of the data as belongs-to. |
270 | * | 270 | * |
271 | - * @return returns AUGMENT_DATA. | 271 | + * @return returns AUGMENT_DATA |
272 | */ | 272 | */ |
273 | @Override | 273 | @Override |
274 | - public ParsableDataType getParsableDataType() { | 274 | + public YangConstructType getYangConstructType() { |
275 | - return ParsableDataType.AUGMENT_DATA; | 275 | + return YangConstructType.AUGMENT_DATA; |
276 | } | 276 | } |
277 | 277 | ||
278 | /** | 278 | /** |
279 | * Validate the data on entering the corresponding parse tree node. | 279 | * Validate the data on entering the corresponding parse tree node. |
280 | * | 280 | * |
281 | - * @throws DataModelException a violation of data model rules. | 281 | + * @throws DataModelException a violation of data model rules |
282 | */ | 282 | */ |
283 | @Override | 283 | @Override |
284 | public void validateDataOnEntry() throws DataModelException { | 284 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -288,7 +288,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -288,7 +288,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
288 | /** | 288 | /** |
289 | * Validate the data on exiting the corresponding parse tree node. | 289 | * Validate the data on exiting the corresponding parse tree node. |
290 | * | 290 | * |
291 | - * @throws DataModelException a violation of data model rules. | 291 | + * @throws DataModelException a violation of data model rules |
292 | */ | 292 | */ |
293 | @Override | 293 | @Override |
294 | public void validateDataOnExit() throws DataModelException { | 294 | public void validateDataOnExit() throws DataModelException { |
... | @@ -298,7 +298,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -298,7 +298,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
298 | /** | 298 | /** |
299 | * Get the target nodes name where the augmentation is being done. | 299 | * Get the target nodes name where the augmentation is being done. |
300 | * | 300 | * |
301 | - * @return target nodes name where the augmentation is being done. | 301 | + * @return target nodes name where the augmentation is being done |
302 | */ | 302 | */ |
303 | @Override | 303 | @Override |
304 | public String getName() { | 304 | public String getName() { |
... | @@ -308,7 +308,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -308,7 +308,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
308 | /** | 308 | /** |
309 | * Set the target nodes name where the augmentation is being done. | 309 | * Set the target nodes name where the augmentation is being done. |
310 | * | 310 | * |
311 | - * @param name target nodes name where the augmentation is being done. | 311 | + * @param name target nodes name where the augmentation is being done |
312 | */ | 312 | */ |
313 | @Override | 313 | @Override |
314 | public void setName(String name) { | 314 | public void setName(String name) { | ... | ... |
... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | import org.onosproject.yangutils.parser.Parsable; | 19 | import org.onosproject.yangutils.parser.Parsable; |
20 | -import org.onosproject.yangutils.parser.ParsableDataType; | 20 | +import org.onosproject.yangutils.utils.YangConstructType; |
21 | 21 | ||
22 | /*- | 22 | /*- |
23 | * Reference 6020. | 23 | * Reference 6020. |
... | @@ -94,7 +94,7 @@ public class YangBelongsTo implements Parsable { | ... | @@ -94,7 +94,7 @@ public class YangBelongsTo implements Parsable { |
94 | /** | 94 | /** |
95 | * Get the prefix. | 95 | * Get the prefix. |
96 | * | 96 | * |
97 | - * @return the prefix. | 97 | + * @return the prefix |
98 | */ | 98 | */ |
99 | public String getPrefix() { | 99 | public String getPrefix() { |
100 | return prefix; | 100 | return prefix; |
... | @@ -115,14 +115,14 @@ public class YangBelongsTo implements Parsable { | ... | @@ -115,14 +115,14 @@ public class YangBelongsTo implements Parsable { |
115 | * @return ParsedDataType returns BELONGS_TO_DATA | 115 | * @return ParsedDataType returns BELONGS_TO_DATA |
116 | */ | 116 | */ |
117 | @Override | 117 | @Override |
118 | - public ParsableDataType getParsableDataType() { | 118 | + public YangConstructType getYangConstructType() { |
119 | - return ParsableDataType.BELONGS_TO_DATA; | 119 | + return YangConstructType.BELONGS_TO_DATA; |
120 | } | 120 | } |
121 | 121 | ||
122 | /** | 122 | /** |
123 | * Validate the data on entering the corresponding parse tree node. | 123 | * Validate the data on entering the corresponding parse tree node. |
124 | * | 124 | * |
125 | - * @throws DataModelException a violation of data model rules. | 125 | + * @throws DataModelException a violation of data model rules |
126 | */ | 126 | */ |
127 | @Override | 127 | @Override |
128 | public void validateDataOnEntry() throws DataModelException { | 128 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -132,7 +132,7 @@ public class YangBelongsTo implements Parsable { | ... | @@ -132,7 +132,7 @@ public class YangBelongsTo implements Parsable { |
132 | /** | 132 | /** |
133 | * Validate the data on exiting the corresponding parse tree node. | 133 | * Validate the data on exiting the corresponding parse tree node. |
134 | * | 134 | * |
135 | - * @throws DataModelException a violation of data model rules. | 135 | + * @throws DataModelException a violation of data model rules |
136 | */ | 136 | */ |
137 | @Override | 137 | @Override |
138 | public void validateDataOnExit() throws DataModelException { | 138 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
20 | import org.onosproject.yangutils.parser.Parsable; | 20 | import org.onosproject.yangutils.parser.Parsable; |
21 | -import org.onosproject.yangutils.parser.ParsableDataType; | 21 | +import org.onosproject.yangutils.utils.YangConstructType; |
22 | 22 | ||
23 | import java.util.Objects; | 23 | import java.util.Objects; |
24 | 24 | ||
... | @@ -83,7 +83,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -83,7 +83,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
83 | /** | 83 | /** |
84 | * Returns bit name. | 84 | * Returns bit name. |
85 | * | 85 | * |
86 | - * @return the bit name. | 86 | + * @return the bit name |
87 | */ | 87 | */ |
88 | public String getBitName() { | 88 | public String getBitName() { |
89 | return bitName; | 89 | return bitName; |
... | @@ -92,7 +92,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -92,7 +92,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
92 | /** | 92 | /** |
93 | * Set the bit name. | 93 | * Set the bit name. |
94 | * | 94 | * |
95 | - * @param bitName the bit name to set. | 95 | + * @param bitName the bit name to set |
96 | */ | 96 | */ |
97 | public void setBitName(String bitName) { | 97 | public void setBitName(String bitName) { |
98 | this.bitName = bitName; | 98 | this.bitName = bitName; |
... | @@ -101,7 +101,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -101,7 +101,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
101 | /** | 101 | /** |
102 | * Returns description. | 102 | * Returns description. |
103 | * | 103 | * |
104 | - * @return the description. | 104 | + * @return the description |
105 | */ | 105 | */ |
106 | @Override | 106 | @Override |
107 | public String getDescription() { | 107 | public String getDescription() { |
... | @@ -111,7 +111,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -111,7 +111,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
111 | /** | 111 | /** |
112 | * Set the description. | 112 | * Set the description. |
113 | * | 113 | * |
114 | - * @param description set the description. | 114 | + * @param description set the description |
115 | */ | 115 | */ |
116 | @Override | 116 | @Override |
117 | public void setDescription(String description) { | 117 | public void setDescription(String description) { |
... | @@ -121,7 +121,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -121,7 +121,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
121 | /** | 121 | /** |
122 | * Returns textual reference. | 122 | * Returns textual reference. |
123 | * | 123 | * |
124 | - * @return the reference. | 124 | + * @return the reference |
125 | */ | 125 | */ |
126 | @Override | 126 | @Override |
127 | public String getReference() { | 127 | public String getReference() { |
... | @@ -131,7 +131,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -131,7 +131,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
131 | /** | 131 | /** |
132 | * Set the textual reference. | 132 | * Set the textual reference. |
133 | * | 133 | * |
134 | - * @param reference the reference to set. | 134 | + * @param reference the reference to set |
135 | */ | 135 | */ |
136 | @Override | 136 | @Override |
137 | public void setReference(String reference) { | 137 | public void setReference(String reference) { |
... | @@ -141,7 +141,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -141,7 +141,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
141 | /** | 141 | /** |
142 | * Returns status. | 142 | * Returns status. |
143 | * | 143 | * |
144 | - * @return the status. | 144 | + * @return the status |
145 | */ | 145 | */ |
146 | @Override | 146 | @Override |
147 | public YangStatusType getStatus() { | 147 | public YangStatusType getStatus() { |
... | @@ -151,7 +151,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -151,7 +151,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
151 | /** | 151 | /** |
152 | * Set the status. | 152 | * Set the status. |
153 | * | 153 | * |
154 | - * @param status the status to set. | 154 | + * @param status the status to set |
155 | */ | 155 | */ |
156 | @Override | 156 | @Override |
157 | public void setStatus(YangStatusType status) { | 157 | public void setStatus(YangStatusType status) { |
... | @@ -170,7 +170,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -170,7 +170,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
170 | /** | 170 | /** |
171 | * Set the bit position. | 171 | * Set the bit position. |
172 | * | 172 | * |
173 | - * @param position the position to set. | 173 | + * @param position the position to set |
174 | */ | 174 | */ |
175 | public void setPosition(int position) { | 175 | public void setPosition(int position) { |
176 | this.position = position; | 176 | this.position = position; |
... | @@ -182,8 +182,8 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -182,8 +182,8 @@ public class YangBit implements YangCommonInfo, Parsable { |
182 | * @return ParsedDataType returns BIT_DATA | 182 | * @return ParsedDataType returns BIT_DATA |
183 | */ | 183 | */ |
184 | @Override | 184 | @Override |
185 | - public ParsableDataType getParsableDataType() { | 185 | + public YangConstructType getYangConstructType() { |
186 | - return ParsableDataType.BIT_DATA; | 186 | + return YangConstructType.BIT_DATA; |
187 | } | 187 | } |
188 | 188 | ||
189 | @Override | 189 | @Override |
... | @@ -206,7 +206,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -206,7 +206,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
206 | /** | 206 | /** |
207 | * Validate the data on entering the corresponding parse tree node. | 207 | * Validate the data on entering the corresponding parse tree node. |
208 | * | 208 | * |
209 | - * @throws DataModelException a violation of data model rules. | 209 | + * @throws DataModelException a violation of data model rules |
210 | */ | 210 | */ |
211 | @Override | 211 | @Override |
212 | public void validateDataOnEntry() throws DataModelException { | 212 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -216,7 +216,7 @@ public class YangBit implements YangCommonInfo, Parsable { | ... | @@ -216,7 +216,7 @@ public class YangBit implements YangCommonInfo, Parsable { |
216 | /** | 216 | /** |
217 | * Validate the data on exiting the corresponding parse tree node. | 217 | * Validate the data on exiting the corresponding parse tree node. |
218 | * | 218 | * |
219 | - * @throws DataModelException a violation of data model rules. | 219 | + * @throws DataModelException a violation of data model rules |
220 | */ | 220 | */ |
221 | @Override | 221 | @Override |
222 | public void validateDataOnExit() throws DataModelException { | 222 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -21,7 +21,7 @@ import java.util.Set; | ... | @@ -21,7 +21,7 @@ import java.util.Set; |
21 | 21 | ||
22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
23 | import org.onosproject.yangutils.parser.Parsable; | 23 | import org.onosproject.yangutils.parser.Parsable; |
24 | -import org.onosproject.yangutils.parser.ParsableDataType; | 24 | +import org.onosproject.yangutils.utils.YangConstructType; |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * Reference RFC 6020. | 27 | * Reference RFC 6020. |
... | @@ -70,12 +70,13 @@ public class YangBits implements Parsable { | ... | @@ -70,12 +70,13 @@ public class YangBits implements Parsable { |
70 | /** | 70 | /** |
71 | * Add bit info. | 71 | * Add bit info. |
72 | * | 72 | * |
73 | - * @param bitInfo the bit information to be added. | 73 | + * @param bitInfo the bit information to be added |
74 | - * @throws DataModelException due to violation in data model rules. | 74 | + * @throws DataModelException due to violation in data model rules |
75 | */ | 75 | */ |
76 | public void addBitInfo(YangBit bitInfo) throws DataModelException { | 76 | public void addBitInfo(YangBit bitInfo) throws DataModelException { |
77 | if (!getBitSet().add(bitInfo)) { | 77 | if (!getBitSet().add(bitInfo)) { |
78 | - throw new DataModelException("YANG Bit already exists"); | 78 | + throw new DataModelException("YANG file error: Duplicate identifier detected, same as bit \"" |
79 | + + bitInfo.getBitName() + "\""); | ||
79 | } | 80 | } |
80 | } | 81 | } |
81 | 82 | ||
... | @@ -85,14 +86,14 @@ public class YangBits implements Parsable { | ... | @@ -85,14 +86,14 @@ public class YangBits implements Parsable { |
85 | * @return ParsedDataType returns BITS_DATA | 86 | * @return ParsedDataType returns BITS_DATA |
86 | */ | 87 | */ |
87 | @Override | 88 | @Override |
88 | - public ParsableDataType getParsableDataType() { | 89 | + public YangConstructType getYangConstructType() { |
89 | - return ParsableDataType.BITS_DATA; | 90 | + return YangConstructType.BITS_DATA; |
90 | } | 91 | } |
91 | 92 | ||
92 | /** | 93 | /** |
93 | * Returns the bits name. | 94 | * Returns the bits name. |
94 | * | 95 | * |
95 | - * @return name of the bits. | 96 | + * @return name of the bits |
96 | */ | 97 | */ |
97 | public String getBitsName() { | 98 | public String getBitsName() { |
98 | return bitsName; | 99 | return bitsName; |
... | @@ -101,7 +102,7 @@ public class YangBits implements Parsable { | ... | @@ -101,7 +102,7 @@ public class YangBits implements Parsable { |
101 | /** | 102 | /** |
102 | * Set bits name. | 103 | * Set bits name. |
103 | * | 104 | * |
104 | - * @param bitsName bit name to be set. | 105 | + * @param bitsName bit name to be set |
105 | */ | 106 | */ |
106 | public void setBitsName(String bitsName) { | 107 | public void setBitsName(String bitsName) { |
107 | this.bitsName = bitsName; | 108 | this.bitsName = bitsName; |
... | @@ -110,7 +111,7 @@ public class YangBits implements Parsable { | ... | @@ -110,7 +111,7 @@ public class YangBits implements Parsable { |
110 | /** | 111 | /** |
111 | * Validate the data on entering the corresponding parse tree node. | 112 | * Validate the data on entering the corresponding parse tree node. |
112 | * | 113 | * |
113 | - * @throws DataModelException a violation of data model rules. | 114 | + * @throws DataModelException a violation of data model rules |
114 | */ | 115 | */ |
115 | @Override | 116 | @Override |
116 | public void validateDataOnEntry() throws DataModelException { | 117 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -120,7 +121,7 @@ public class YangBits implements Parsable { | ... | @@ -120,7 +121,7 @@ public class YangBits implements Parsable { |
120 | /** | 121 | /** |
121 | * Validate the data on exiting the corresponding parse tree node. | 122 | * Validate the data on exiting the corresponding parse tree node. |
122 | * | 123 | * |
123 | - * @throws DataModelException a violation of data model rules. | 124 | + * @throws DataModelException a violation of data model rules |
124 | */ | 125 | */ |
125 | @Override | 126 | @Override |
126 | public void validateDataOnExit() throws DataModelException { | 127 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -15,13 +15,15 @@ | ... | @@ -15,13 +15,15 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.datamodel; | 16 | package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | -import java.util.LinkedList; | ||
19 | -import java.util.List; | ||
20 | - | ||
21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | ||
22 | import org.onosproject.yangutils.parser.Parsable; | 20 | import org.onosproject.yangutils.parser.Parsable; |
23 | -import org.onosproject.yangutils.parser.ParsableDataType; | ||
24 | import org.onosproject.yangutils.translator.CachedFileHandle; | 21 | import org.onosproject.yangutils.translator.CachedFileHandle; |
22 | +import org.onosproject.yangutils.utils.YangConstructType; | ||
23 | +import static org.onosproject.yangutils.utils.YangConstructType.CASE_DATA; | ||
24 | + | ||
25 | +import java.util.LinkedList; | ||
26 | +import java.util.List; | ||
25 | 27 | ||
26 | /*- | 28 | /*- |
27 | * Reference RFC 6020. | 29 | * Reference RFC 6020. |
... | @@ -90,7 +92,7 @@ import org.onosproject.yangutils.translator.CachedFileHandle; | ... | @@ -90,7 +92,7 @@ import org.onosproject.yangutils.translator.CachedFileHandle; |
90 | * Data model node to maintain information defined in YANG case. | 92 | * Data model node to maintain information defined in YANG case. |
91 | */ | 93 | */ |
92 | public class YangCase extends YangNode | 94 | public class YangCase extends YangNode |
93 | - implements YangLeavesHolder, YangCommonInfo, Parsable { | 95 | + implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector { |
94 | 96 | ||
95 | /** | 97 | /** |
96 | * Case name. | 98 | * Case name. |
... | @@ -100,7 +102,7 @@ public class YangCase extends YangNode | ... | @@ -100,7 +102,7 @@ public class YangCase extends YangNode |
100 | // TODO: default field identification for the case | 102 | // TODO: default field identification for the case |
101 | 103 | ||
102 | /** | 104 | /** |
103 | - * Description of container. | 105 | + * Description of case. |
104 | */ | 106 | */ |
105 | private String description; | 107 | private String description; |
106 | 108 | ||
... | @@ -125,7 +127,7 @@ public class YangCase extends YangNode | ... | @@ -125,7 +127,7 @@ public class YangCase extends YangNode |
125 | private YangStatusType status; | 127 | private YangStatusType status; |
126 | 128 | ||
127 | /** | 129 | /** |
128 | - * package of the generated java code. | 130 | + * Package of the generated java code. |
129 | */ | 131 | */ |
130 | private String pkg; | 132 | private String pkg; |
131 | 133 | ||
... | @@ -139,7 +141,7 @@ public class YangCase extends YangNode | ... | @@ -139,7 +141,7 @@ public class YangCase extends YangNode |
139 | /** | 141 | /** |
140 | * Get the case name. | 142 | * Get the case name. |
141 | * | 143 | * |
142 | - * @return case name. | 144 | + * @return case name |
143 | */ | 145 | */ |
144 | @Override | 146 | @Override |
145 | public String getName() { | 147 | public String getName() { |
... | @@ -149,7 +151,7 @@ public class YangCase extends YangNode | ... | @@ -149,7 +151,7 @@ public class YangCase extends YangNode |
149 | /** | 151 | /** |
150 | * Set the case name. | 152 | * Set the case name. |
151 | * | 153 | * |
152 | - * @param name case name. | 154 | + * @param name case name |
153 | */ | 155 | */ |
154 | @Override | 156 | @Override |
155 | public void setName(String name) { | 157 | public void setName(String name) { |
... | @@ -159,7 +161,7 @@ public class YangCase extends YangNode | ... | @@ -159,7 +161,7 @@ public class YangCase extends YangNode |
159 | /** | 161 | /** |
160 | * Get the description. | 162 | * Get the description. |
161 | * | 163 | * |
162 | - * @return the description. | 164 | + * @return the description |
163 | */ | 165 | */ |
164 | @Override | 166 | @Override |
165 | public String getDescription() { | 167 | public String getDescription() { |
... | @@ -169,7 +171,7 @@ public class YangCase extends YangNode | ... | @@ -169,7 +171,7 @@ public class YangCase extends YangNode |
169 | /** | 171 | /** |
170 | * Set the description. | 172 | * Set the description. |
171 | * | 173 | * |
172 | - * @param description set the description. | 174 | + * @param description set the description |
173 | */ | 175 | */ |
174 | @Override | 176 | @Override |
175 | public void setDescription(String description) { | 177 | public void setDescription(String description) { |
... | @@ -179,7 +181,7 @@ public class YangCase extends YangNode | ... | @@ -179,7 +181,7 @@ public class YangCase extends YangNode |
179 | /** | 181 | /** |
180 | * Get the list of leaves. | 182 | * Get the list of leaves. |
181 | * | 183 | * |
182 | - * @return the list of leaves. | 184 | + * @return the list of leaves |
183 | */ | 185 | */ |
184 | @Override | 186 | @Override |
185 | public List<YangLeaf> getListOfLeaf() { | 187 | public List<YangLeaf> getListOfLeaf() { |
... | @@ -189,7 +191,7 @@ public class YangCase extends YangNode | ... | @@ -189,7 +191,7 @@ public class YangCase extends YangNode |
189 | /** | 191 | /** |
190 | * Set the list of leaves. | 192 | * Set the list of leaves. |
191 | * | 193 | * |
192 | - * @param leafsList the list of leaf to set. | 194 | + * @param leafsList the list of leaf to set |
193 | */ | 195 | */ |
194 | private void setListOfLeaf(List<YangLeaf> leafsList) { | 196 | private void setListOfLeaf(List<YangLeaf> leafsList) { |
195 | listOfLeaf = leafsList; | 197 | listOfLeaf = leafsList; |
... | @@ -198,7 +200,7 @@ public class YangCase extends YangNode | ... | @@ -198,7 +200,7 @@ public class YangCase extends YangNode |
198 | /** | 200 | /** |
199 | * Add a leaf. | 201 | * Add a leaf. |
200 | * | 202 | * |
201 | - * @param leaf the leaf to be added. | 203 | + * @param leaf the leaf to be added |
202 | */ | 204 | */ |
203 | @Override | 205 | @Override |
204 | public void addLeaf(YangLeaf leaf) { | 206 | public void addLeaf(YangLeaf leaf) { |
... | @@ -212,7 +214,7 @@ public class YangCase extends YangNode | ... | @@ -212,7 +214,7 @@ public class YangCase extends YangNode |
212 | /** | 214 | /** |
213 | * Get the list of leaf-list. | 215 | * Get the list of leaf-list. |
214 | * | 216 | * |
215 | - * @return the list of leaf-list. | 217 | + * @return the list of leaf-list |
216 | */ | 218 | */ |
217 | @Override | 219 | @Override |
218 | public List<YangLeafList> getListOfLeafList() { | 220 | public List<YangLeafList> getListOfLeafList() { |
... | @@ -222,7 +224,7 @@ public class YangCase extends YangNode | ... | @@ -222,7 +224,7 @@ public class YangCase extends YangNode |
222 | /** | 224 | /** |
223 | * Set the list of leaf-list. | 225 | * Set the list of leaf-list. |
224 | * | 226 | * |
225 | - * @param listOfLeafList the list of leaf-list to set. | 227 | + * @param listOfLeafList the list of leaf-list to set |
226 | */ | 228 | */ |
227 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | 229 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
228 | this.listOfLeafList = listOfLeafList; | 230 | this.listOfLeafList = listOfLeafList; |
... | @@ -231,7 +233,7 @@ public class YangCase extends YangNode | ... | @@ -231,7 +233,7 @@ public class YangCase extends YangNode |
231 | /** | 233 | /** |
232 | * Add a leaf-list. | 234 | * Add a leaf-list. |
233 | * | 235 | * |
234 | - * @param leafList the leaf-list to be added. | 236 | + * @param leafList the leaf-list to be added |
235 | */ | 237 | */ |
236 | @Override | 238 | @Override |
237 | public void addLeafList(YangLeafList leafList) { | 239 | public void addLeafList(YangLeafList leafList) { |
... | @@ -245,7 +247,7 @@ public class YangCase extends YangNode | ... | @@ -245,7 +247,7 @@ public class YangCase extends YangNode |
245 | /** | 247 | /** |
246 | * Get the textual reference. | 248 | * Get the textual reference. |
247 | * | 249 | * |
248 | - * @return the reference. | 250 | + * @return the reference |
249 | */ | 251 | */ |
250 | @Override | 252 | @Override |
251 | public String getReference() { | 253 | public String getReference() { |
... | @@ -255,7 +257,7 @@ public class YangCase extends YangNode | ... | @@ -255,7 +257,7 @@ public class YangCase extends YangNode |
255 | /** | 257 | /** |
256 | * Set the textual reference. | 258 | * Set the textual reference. |
257 | * | 259 | * |
258 | - * @param reference the reference to set. | 260 | + * @param reference the reference to set |
259 | */ | 261 | */ |
260 | @Override | 262 | @Override |
261 | public void setReference(String reference) { | 263 | public void setReference(String reference) { |
... | @@ -265,7 +267,7 @@ public class YangCase extends YangNode | ... | @@ -265,7 +267,7 @@ public class YangCase extends YangNode |
265 | /** | 267 | /** |
266 | * Get the status. | 268 | * Get the status. |
267 | * | 269 | * |
268 | - * @return the status. | 270 | + * @return the status |
269 | */ | 271 | */ |
270 | @Override | 272 | @Override |
271 | public YangStatusType getStatus() { | 273 | public YangStatusType getStatus() { |
... | @@ -275,7 +277,7 @@ public class YangCase extends YangNode | ... | @@ -275,7 +277,7 @@ public class YangCase extends YangNode |
275 | /** | 277 | /** |
276 | * Set the status. | 278 | * Set the status. |
277 | * | 279 | * |
278 | - * @param status the status to set. | 280 | + * @param status the status to set |
279 | */ | 281 | */ |
280 | @Override | 282 | @Override |
281 | public void setStatus(YangStatusType status) { | 283 | public void setStatus(YangStatusType status) { |
... | @@ -288,14 +290,14 @@ public class YangCase extends YangNode | ... | @@ -288,14 +290,14 @@ public class YangCase extends YangNode |
288 | * @return returns CASE_DATA | 290 | * @return returns CASE_DATA |
289 | */ | 291 | */ |
290 | @Override | 292 | @Override |
291 | - public ParsableDataType getParsableDataType() { | 293 | + public YangConstructType getYangConstructType() { |
292 | - return ParsableDataType.CASE_DATA; | 294 | + return YangConstructType.CASE_DATA; |
293 | } | 295 | } |
294 | 296 | ||
295 | /** | 297 | /** |
296 | * Validate the data on entering the corresponding parse tree node. | 298 | * Validate the data on entering the corresponding parse tree node. |
297 | * | 299 | * |
298 | - * @throws DataModelException a violation of data model rules. | 300 | + * @throws DataModelException a violation of data model rules |
299 | */ | 301 | */ |
300 | @Override | 302 | @Override |
301 | public void validateDataOnEntry() throws DataModelException { | 303 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -305,7 +307,7 @@ public class YangCase extends YangNode | ... | @@ -305,7 +307,7 @@ public class YangCase extends YangNode |
305 | /** | 307 | /** |
306 | * Validate the data on exiting the corresponding parse tree node. | 308 | * Validate the data on exiting the corresponding parse tree node. |
307 | * | 309 | * |
308 | - * @throws DataModelException a violation of data model rules. | 310 | + * @throws DataModelException a violation of data model rules |
309 | */ | 311 | */ |
310 | @Override | 312 | @Override |
311 | public void validateDataOnExit() throws DataModelException { | 313 | public void validateDataOnExit() throws DataModelException { |
... | @@ -361,6 +363,30 @@ public class YangCase extends YangNode | ... | @@ -361,6 +363,30 @@ public class YangCase extends YangNode |
361 | @Override | 363 | @Override |
362 | public void setFileHandle(CachedFileHandle fileHandle) { | 364 | public void setFileHandle(CachedFileHandle fileHandle) { |
363 | // TODO Auto-generated method stub | 365 | // TODO Auto-generated method stub |
366 | + } | ||
367 | + | ||
368 | + @Override | ||
369 | + public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { | ||
370 | + if ((this.getParent() == null) || (!(this.getParent() instanceof YangChoice))) { | ||
371 | + throw new DataModelException("Internal Data Model Tree Error: Invalid/Missing holder in case " + | ||
372 | + this.getName()); | ||
373 | + } | ||
374 | + // Traverse up in tree to ask parent choice start collision detection. | ||
375 | + ((CollisionDetector) this.getParent()).detectCollidingChild(identifierName, dataType); | ||
376 | + } | ||
377 | + | ||
378 | + @Override | ||
379 | + public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { | ||
380 | + | ||
381 | + if (dataType == CASE_DATA) { | ||
382 | + if (this.getName().equals(identifierName)) { | ||
383 | + throw new DataModelException("YANG File Error: Identifier collision detected in case \"" + | ||
384 | + this.getName() + "\""); | ||
385 | + } | ||
386 | + return; | ||
387 | + } | ||
364 | 388 | ||
389 | + // Asks helper to detect colliding child. | ||
390 | + detectCollidingChildUtil(identifierName, dataType, this); | ||
365 | } | 391 | } |
366 | } | 392 | } | ... | ... |
... | @@ -15,13 +15,11 @@ | ... | @@ -15,13 +15,11 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.datamodel; | 16 | package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | -import java.util.LinkedList; | ||
19 | -import java.util.List; | ||
20 | - | ||
21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
22 | import org.onosproject.yangutils.parser.Parsable; | 19 | import org.onosproject.yangutils.parser.Parsable; |
23 | -import org.onosproject.yangutils.parser.ParsableDataType; | ||
24 | import org.onosproject.yangutils.translator.CachedFileHandle; | 20 | import org.onosproject.yangutils.translator.CachedFileHandle; |
21 | +import org.onosproject.yangutils.utils.YangConstructType; | ||
22 | +import static org.onosproject.yangutils.utils.YangConstructType.CHOICE_DATA; | ||
25 | 23 | ||
26 | /*- | 24 | /*- |
27 | * Reference RFC 6020. | 25 | * Reference RFC 6020. |
... | @@ -61,7 +59,7 @@ import org.onosproject.yangutils.translator.CachedFileHandle; | ... | @@ -61,7 +59,7 @@ import org.onosproject.yangutils.translator.CachedFileHandle; |
61 | /** | 59 | /** |
62 | * Data model node to maintain information defined in YANG choice. | 60 | * Data model node to maintain information defined in YANG choice. |
63 | */ | 61 | */ |
64 | -public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | 62 | +public class YangChoice extends YangNode implements YangCommonInfo, Parsable, CollisionDetector { |
65 | 63 | ||
66 | /** | 64 | /** |
67 | * Name of choice. | 65 | * Name of choice. |
... | @@ -69,11 +67,6 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -69,11 +67,6 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
69 | private String name; | 67 | private String name; |
70 | 68 | ||
71 | /** | 69 | /** |
72 | - * List of cases for the current choice. | ||
73 | - */ | ||
74 | - private List<YangCase> caseList; | ||
75 | - | ||
76 | - /** | ||
77 | * If the choice represents config data. | 70 | * If the choice represents config data. |
78 | */ | 71 | */ |
79 | private boolean isConfig; | 72 | private boolean isConfig; |
... | @@ -105,7 +98,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -105,7 +98,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
105 | private String defaultCase; | 98 | private String defaultCase; |
106 | 99 | ||
107 | /** | 100 | /** |
108 | - * Description. | 101 | + * Description of choice. |
109 | */ | 102 | */ |
110 | private String description; | 103 | private String description; |
111 | 104 | ||
... | @@ -131,7 +124,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -131,7 +124,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
131 | private String mandatory; | 124 | private String mandatory; |
132 | 125 | ||
133 | /** | 126 | /** |
134 | - * reference of the choice. | 127 | + * Reference of the choice. |
135 | */ | 128 | */ |
136 | private String reference; | 129 | private String reference; |
137 | 130 | ||
... | @@ -141,13 +134,15 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -141,13 +134,15 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
141 | private YangStatusType status; | 134 | private YangStatusType status; |
142 | 135 | ||
143 | /** | 136 | /** |
144 | - * Create a Choice node. | 137 | + * Create a choice node. |
145 | */ | 138 | */ |
146 | public YangChoice() { | 139 | public YangChoice() { |
147 | super(YangNodeType.CHOICE_NODE); | 140 | super(YangNodeType.CHOICE_NODE); |
148 | } | 141 | } |
149 | 142 | ||
150 | - /* (non-Javadoc) | 143 | + /* |
144 | + * (non-Javadoc) | ||
145 | + * | ||
151 | * @see org.onosproject.yangutils.datamodel.YangNode#getName() | 146 | * @see org.onosproject.yangutils.datamodel.YangNode#getName() |
152 | */ | 147 | */ |
153 | @Override | 148 | @Override |
... | @@ -155,8 +150,11 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -155,8 +150,11 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
155 | return name; | 150 | return name; |
156 | } | 151 | } |
157 | 152 | ||
158 | - /* (non-Javadoc) | 153 | + /* |
159 | - * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String) | 154 | + * (non-Javadoc) |
155 | + * | ||
156 | + * @see | ||
157 | + * org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String) | ||
160 | */ | 158 | */ |
161 | @Override | 159 | @Override |
162 | public void setName(String name) { | 160 | public void setName(String name) { |
... | @@ -164,40 +162,9 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -164,40 +162,9 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
164 | } | 162 | } |
165 | 163 | ||
166 | /** | 164 | /** |
167 | - * Get the list of cases. | ||
168 | - * | ||
169 | - * @return the case list | ||
170 | - */ | ||
171 | - public List<YangCase> getCaseList() { | ||
172 | - return caseList; | ||
173 | - } | ||
174 | - | ||
175 | - /** | ||
176 | - * Set the list of cases. | ||
177 | - * | ||
178 | - * @param caseList list of cases. | ||
179 | - */ | ||
180 | - private void setCaseList(List<YangCase> caseList) { | ||
181 | - this.caseList = caseList; | ||
182 | - } | ||
183 | - | ||
184 | - /** | ||
185 | - * Add a case. | ||
186 | - * | ||
187 | - * @param newCase new case for the choice | ||
188 | - */ | ||
189 | - public void addCase(YangCase newCase) { | ||
190 | - if (getCaseList() == null) { | ||
191 | - setCaseList(new LinkedList<YangCase>()); | ||
192 | - } | ||
193 | - | ||
194 | - getCaseList().add(newCase); | ||
195 | - } | ||
196 | - | ||
197 | - /** | ||
198 | * Get config flag. | 165 | * Get config flag. |
199 | * | 166 | * |
200 | - * @return the config flag. | 167 | + * @return the config flag |
201 | */ | 168 | */ |
202 | public boolean isConfig() { | 169 | public boolean isConfig() { |
203 | return isConfig; | 170 | return isConfig; |
... | @@ -206,7 +173,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -206,7 +173,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
206 | /** | 173 | /** |
207 | * Set config flag. | 174 | * Set config flag. |
208 | * | 175 | * |
209 | - * @param isCfg the config flag. | 176 | + * @param isCfg the config flag |
210 | */ | 177 | */ |
211 | public void setConfig(boolean isCfg) { | 178 | public void setConfig(boolean isCfg) { |
212 | isConfig = isCfg; | 179 | isConfig = isCfg; |
... | @@ -215,7 +182,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -215,7 +182,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
215 | /** | 182 | /** |
216 | * Get the default case. | 183 | * Get the default case. |
217 | * | 184 | * |
218 | - * @return the default case. | 185 | + * @return the default case |
219 | */ | 186 | */ |
220 | public String getDefaultCase() { | 187 | public String getDefaultCase() { |
221 | return defaultCase; | 188 | return defaultCase; |
... | @@ -233,7 +200,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -233,7 +200,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
233 | /** | 200 | /** |
234 | * Get the mandatory status. | 201 | * Get the mandatory status. |
235 | * | 202 | * |
236 | - * @return the mandatory status. | 203 | + * @return the mandatory status |
237 | */ | 204 | */ |
238 | public String getMandatory() { | 205 | public String getMandatory() { |
239 | return mandatory; | 206 | return mandatory; |
... | @@ -242,7 +209,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -242,7 +209,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
242 | /** | 209 | /** |
243 | * Set the mandatory status. | 210 | * Set the mandatory status. |
244 | * | 211 | * |
245 | - * @param mandatory the mandatory status. | 212 | + * @param mandatory the mandatory status |
246 | */ | 213 | */ |
247 | public void setMandatory(String mandatory) { | 214 | public void setMandatory(String mandatory) { |
248 | this.mandatory = mandatory; | 215 | this.mandatory = mandatory; |
... | @@ -251,7 +218,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -251,7 +218,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
251 | /** | 218 | /** |
252 | * Get the description. | 219 | * Get the description. |
253 | * | 220 | * |
254 | - * @return the description. | 221 | + * @return the description |
255 | */ | 222 | */ |
256 | @Override | 223 | @Override |
257 | public String getDescription() { | 224 | public String getDescription() { |
... | @@ -261,7 +228,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -261,7 +228,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
261 | /** | 228 | /** |
262 | * Set the description. | 229 | * Set the description. |
263 | * | 230 | * |
264 | - * @param description set the description. | 231 | + * @param description set the description |
265 | */ | 232 | */ |
266 | @Override | 233 | @Override |
267 | public void setDescription(String description) { | 234 | public void setDescription(String description) { |
... | @@ -271,7 +238,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -271,7 +238,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
271 | /** | 238 | /** |
272 | * Get the textual reference. | 239 | * Get the textual reference. |
273 | * | 240 | * |
274 | - * @return the reference. | 241 | + * @return the reference |
275 | */ | 242 | */ |
276 | @Override | 243 | @Override |
277 | public String getReference() { | 244 | public String getReference() { |
... | @@ -281,7 +248,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -281,7 +248,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
281 | /** | 248 | /** |
282 | * Set the textual reference. | 249 | * Set the textual reference. |
283 | * | 250 | * |
284 | - * @param reference the reference to set. | 251 | + * @param reference the reference to set |
285 | */ | 252 | */ |
286 | @Override | 253 | @Override |
287 | public void setReference(String reference) { | 254 | public void setReference(String reference) { |
... | @@ -291,7 +258,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -291,7 +258,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
291 | /** | 258 | /** |
292 | * Get the status. | 259 | * Get the status. |
293 | * | 260 | * |
294 | - * @return the status. | 261 | + * @return the status |
295 | */ | 262 | */ |
296 | @Override | 263 | @Override |
297 | public YangStatusType getStatus() { | 264 | public YangStatusType getStatus() { |
... | @@ -301,7 +268,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -301,7 +268,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
301 | /** | 268 | /** |
302 | * Set the status. | 269 | * Set the status. |
303 | * | 270 | * |
304 | - * @param status the status to set. | 271 | + * @param status the status to set |
305 | */ | 272 | */ |
306 | @Override | 273 | @Override |
307 | public void setStatus(YangStatusType status) { | 274 | public void setStatus(YangStatusType status) { |
... | @@ -314,14 +281,14 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -314,14 +281,14 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
314 | * @return returns CHOICE_DATA | 281 | * @return returns CHOICE_DATA |
315 | */ | 282 | */ |
316 | @Override | 283 | @Override |
317 | - public ParsableDataType getParsableDataType() { | 284 | + public YangConstructType getYangConstructType() { |
318 | - return ParsableDataType.CHOICE_DATA; | 285 | + return YangConstructType.CHOICE_DATA; |
319 | } | 286 | } |
320 | 287 | ||
321 | /** | 288 | /** |
322 | * Validate the data on entering the corresponding parse tree node. | 289 | * Validate the data on entering the corresponding parse tree node. |
323 | * | 290 | * |
324 | - * @throws DataModelException a violation of data model rules. | 291 | + * @throws DataModelException a violation of data model rules |
325 | */ | 292 | */ |
326 | @Override | 293 | @Override |
327 | public void validateDataOnEntry() throws DataModelException { | 294 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -331,14 +298,16 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -331,14 +298,16 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
331 | /** | 298 | /** |
332 | * Validate the data on exiting the corresponding parse tree node. | 299 | * Validate the data on exiting the corresponding parse tree node. |
333 | * | 300 | * |
334 | - * @throws DataModelException a violation of data model rules. | 301 | + * @throws DataModelException a violation of data model rules |
335 | */ | 302 | */ |
336 | @Override | 303 | @Override |
337 | public void validateDataOnExit() throws DataModelException { | 304 | public void validateDataOnExit() throws DataModelException { |
338 | // TODO auto-generated method stub, to be implemented by parser | 305 | // TODO auto-generated method stub, to be implemented by parser |
339 | } | 306 | } |
340 | 307 | ||
341 | - /* (non-Javadoc) | 308 | + /* |
309 | + * (non-Javadoc) | ||
310 | + * | ||
342 | * @see org.onosproject.yangutils.datamodel.YangNode#getPackage() | 311 | * @see org.onosproject.yangutils.datamodel.YangNode#getPackage() |
343 | */ | 312 | */ |
344 | @Override | 313 | @Override |
... | @@ -347,8 +316,11 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -347,8 +316,11 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
347 | return null; | 316 | return null; |
348 | } | 317 | } |
349 | 318 | ||
350 | - /* (non-Javadoc) | 319 | + /* |
351 | - * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String) | 320 | + * (non-Javadoc) |
321 | + * | ||
322 | + * @see | ||
323 | + * org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String) | ||
352 | */ | 324 | */ |
353 | @Override | 325 | @Override |
354 | public void setPackage(String pkg) { | 326 | public void setPackage(String pkg) { |
... | @@ -356,8 +328,12 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -356,8 +328,12 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
356 | 328 | ||
357 | } | 329 | } |
358 | 330 | ||
359 | - /* (non-Javadoc) | 331 | + /* |
360 | - * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | 332 | + * (non-Javadoc) |
333 | + * | ||
334 | + * @see | ||
335 | + * org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry( | ||
336 | + * ) | ||
361 | */ | 337 | */ |
362 | @Override | 338 | @Override |
363 | public void generateJavaCodeEntry() { | 339 | public void generateJavaCodeEntry() { |
... | @@ -365,8 +341,11 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -365,8 +341,11 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
365 | 341 | ||
366 | } | 342 | } |
367 | 343 | ||
368 | - /* (non-Javadoc) | 344 | + /* |
369 | - * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | 345 | + * (non-Javadoc) |
346 | + * | ||
347 | + * @see | ||
348 | + * org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | ||
370 | */ | 349 | */ |
371 | @Override | 350 | @Override |
372 | public void generateJavaCodeExit() { | 351 | public void generateJavaCodeExit() { |
... | @@ -385,4 +364,36 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -385,4 +364,36 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
385 | // TODO Auto-generated method stub | 364 | // TODO Auto-generated method stub |
386 | 365 | ||
387 | } | 366 | } |
367 | + | ||
368 | + @Override | ||
369 | + public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { | ||
370 | + | ||
371 | + YangNode node = this.getChild(); | ||
372 | + while ((node != null)) { | ||
373 | + if (node instanceof CollisionDetector) { | ||
374 | + ((CollisionDetector) node).detectSelfCollision(identifierName, dataType); | ||
375 | + } | ||
376 | + node = node.getNextSibling(); | ||
377 | + } | ||
378 | + } | ||
379 | + | ||
380 | + @Override | ||
381 | + public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { | ||
382 | + | ||
383 | + if (dataType == CHOICE_DATA) { | ||
384 | + if (this.getName().equals(identifierName)) { | ||
385 | + throw new DataModelException("YANG file error: Identifier collision detected in choice \"" + | ||
386 | + this.getName() + "\""); | ||
387 | + } | ||
388 | + return; | ||
389 | + } | ||
390 | + | ||
391 | + YangNode node = this.getChild(); | ||
392 | + while ((node != null)) { | ||
393 | + if (node instanceof CollisionDetector) { | ||
394 | + ((CollisionDetector) node).detectSelfCollision(identifierName, dataType); | ||
395 | + } | ||
396 | + node = node.getNextSibling(); | ||
397 | + } | ||
398 | + } | ||
388 | } | 399 | } | ... | ... |
... | @@ -21,8 +21,9 @@ import java.util.LinkedList; | ... | @@ -21,8 +21,9 @@ import java.util.LinkedList; |
21 | import java.util.List; | 21 | import java.util.List; |
22 | 22 | ||
23 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 23 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
24 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | ||
24 | import org.onosproject.yangutils.parser.Parsable; | 25 | import org.onosproject.yangutils.parser.Parsable; |
25 | -import org.onosproject.yangutils.parser.ParsableDataType; | 26 | +import org.onosproject.yangutils.utils.YangConstructType; |
26 | import org.onosproject.yangutils.translator.CachedFileHandle; | 27 | import org.onosproject.yangutils.translator.CachedFileHandle; |
27 | import org.onosproject.yangutils.translator.GeneratedFileType; | 28 | import org.onosproject.yangutils.translator.GeneratedFileType; |
28 | import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax; | 29 | import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax; |
... | @@ -90,7 +91,7 @@ import org.onosproject.yangutils.utils.io.impl.FileSystemUtil; | ... | @@ -90,7 +91,7 @@ import org.onosproject.yangutils.utils.io.impl.FileSystemUtil; |
90 | /** | 91 | /** |
91 | * Data model node to maintain information defined in YANG container. | 92 | * Data model node to maintain information defined in YANG container. |
92 | */ | 93 | */ |
93 | -public class YangContainer extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable { | 94 | +public class YangContainer extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector { |
94 | 95 | ||
95 | /** | 96 | /** |
96 | * Name of the container. | 97 | * Name of the container. |
... | @@ -153,7 +154,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -153,7 +154,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
153 | /** | 154 | /** |
154 | * Get the YANG name of container. | 155 | * Get the YANG name of container. |
155 | * | 156 | * |
156 | - * @return the name of container as defined in YANG file. | 157 | + * @return the name of container as defined in YANG file |
157 | */ | 158 | */ |
158 | @Override | 159 | @Override |
159 | public String getName() { | 160 | public String getName() { |
... | @@ -163,7 +164,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -163,7 +164,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
163 | /** | 164 | /** |
164 | * Set the YANG name of container. | 165 | * Set the YANG name of container. |
165 | * | 166 | * |
166 | - * @param name the name of container as defined in YANG file. | 167 | + * @param name the name of container as defined in YANG file |
167 | */ | 168 | */ |
168 | @Override | 169 | @Override |
169 | public void setName(String name) { | 170 | public void setName(String name) { |
... | @@ -182,7 +183,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -182,7 +183,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
182 | /** | 183 | /** |
183 | * Set the config flag. | 184 | * Set the config flag. |
184 | * | 185 | * |
185 | - * @param isCfg the config flag. | 186 | + * @param isCfg the config flag |
186 | */ | 187 | */ |
187 | public void setConfig(boolean isCfg) { | 188 | public void setConfig(boolean isCfg) { |
188 | isConfig = isCfg; | 189 | isConfig = isCfg; |
... | @@ -191,7 +192,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -191,7 +192,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
191 | /** | 192 | /** |
192 | * Get the description. | 193 | * Get the description. |
193 | * | 194 | * |
194 | - * @return the description. | 195 | + * @return the description |
195 | */ | 196 | */ |
196 | @Override | 197 | @Override |
197 | public String getDescription() { | 198 | public String getDescription() { |
... | @@ -201,7 +202,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -201,7 +202,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
201 | /** | 202 | /** |
202 | * Set the description. | 203 | * Set the description. |
203 | * | 204 | * |
204 | - * @param description set the description. | 205 | + * @param description set the description |
205 | */ | 206 | */ |
206 | @Override | 207 | @Override |
207 | public void setDescription(String description) { | 208 | public void setDescription(String description) { |
... | @@ -211,7 +212,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -211,7 +212,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
211 | /** | 212 | /** |
212 | * Get the list of leaves. | 213 | * Get the list of leaves. |
213 | * | 214 | * |
214 | - * @return the list of leaves. | 215 | + * @return the list of leaves |
215 | */ | 216 | */ |
216 | @Override | 217 | @Override |
217 | public List<YangLeaf> getListOfLeaf() { | 218 | public List<YangLeaf> getListOfLeaf() { |
... | @@ -221,7 +222,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -221,7 +222,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
221 | /** | 222 | /** |
222 | * Set the list of leaves. | 223 | * Set the list of leaves. |
223 | * | 224 | * |
224 | - * @param leafsList the list of leaf to set. | 225 | + * @param leafsList the list of leaf to set |
225 | */ | 226 | */ |
226 | private void setListOfLeaf(List<YangLeaf> leafsList) { | 227 | private void setListOfLeaf(List<YangLeaf> leafsList) { |
227 | listOfLeaf = leafsList; | 228 | listOfLeaf = leafsList; |
... | @@ -230,7 +231,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -230,7 +231,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
230 | /** | 231 | /** |
231 | * Add a leaf. | 232 | * Add a leaf. |
232 | * | 233 | * |
233 | - * @param leaf the leaf to be added. | 234 | + * @param leaf the leaf to be added |
234 | */ | 235 | */ |
235 | @Override | 236 | @Override |
236 | public void addLeaf(YangLeaf leaf) { | 237 | public void addLeaf(YangLeaf leaf) { |
... | @@ -244,7 +245,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -244,7 +245,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
244 | /** | 245 | /** |
245 | * Get the list of leaf-list. | 246 | * Get the list of leaf-list. |
246 | * | 247 | * |
247 | - * @return the list of leaf-list. | 248 | + * @return the list of leaf-list |
248 | */ | 249 | */ |
249 | @Override | 250 | @Override |
250 | public List<YangLeafList> getListOfLeafList() { | 251 | public List<YangLeafList> getListOfLeafList() { |
... | @@ -254,7 +255,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -254,7 +255,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
254 | /** | 255 | /** |
255 | * Set the list of leaf-list. | 256 | * Set the list of leaf-list. |
256 | * | 257 | * |
257 | - * @param listOfLeafList the list of leaf-list to set. | 258 | + * @param listOfLeafList the list of leaf-list to set |
258 | */ | 259 | */ |
259 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | 260 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
260 | this.listOfLeafList = listOfLeafList; | 261 | this.listOfLeafList = listOfLeafList; |
... | @@ -263,7 +264,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -263,7 +264,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
263 | /** | 264 | /** |
264 | * Add a leaf-list. | 265 | * Add a leaf-list. |
265 | * | 266 | * |
266 | - * @param leafList the leaf-list to be added. | 267 | + * @param leafList the leaf-list to be added |
267 | */ | 268 | */ |
268 | @Override | 269 | @Override |
269 | public void addLeafList(YangLeafList leafList) { | 270 | public void addLeafList(YangLeafList leafList) { |
... | @@ -277,7 +278,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -277,7 +278,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
277 | /** | 278 | /** |
278 | * Get the presence string if present. | 279 | * Get the presence string if present. |
279 | * | 280 | * |
280 | - * @return the isPressence. | 281 | + * @return the presence |
281 | */ | 282 | */ |
282 | public String getPresence() { | 283 | public String getPresence() { |
283 | return presence; | 284 | return presence; |
... | @@ -295,7 +296,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -295,7 +296,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
295 | /** | 296 | /** |
296 | * Get the textual reference. | 297 | * Get the textual reference. |
297 | * | 298 | * |
298 | - * @return the reference. | 299 | + * @return the reference |
299 | */ | 300 | */ |
300 | @Override | 301 | @Override |
301 | public String getReference() { | 302 | public String getReference() { |
... | @@ -305,7 +306,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -305,7 +306,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
305 | /** | 306 | /** |
306 | * Set the textual reference. | 307 | * Set the textual reference. |
307 | * | 308 | * |
308 | - * @param reference the reference to set. | 309 | + * @param reference the reference to set |
309 | */ | 310 | */ |
310 | @Override | 311 | @Override |
311 | public void setReference(String reference) { | 312 | public void setReference(String reference) { |
... | @@ -315,7 +316,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -315,7 +316,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
315 | /** | 316 | /** |
316 | * Get the status. | 317 | * Get the status. |
317 | * | 318 | * |
318 | - * @return the status. | 319 | + * @return the status |
319 | */ | 320 | */ |
320 | @Override | 321 | @Override |
321 | public YangStatusType getStatus() { | 322 | public YangStatusType getStatus() { |
... | @@ -325,7 +326,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -325,7 +326,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
325 | /** | 326 | /** |
326 | * Set the status. | 327 | * Set the status. |
327 | * | 328 | * |
328 | - * @param status the status to set. | 329 | + * @param status the status to set |
329 | */ | 330 | */ |
330 | @Override | 331 | @Override |
331 | public void setStatus(YangStatusType status) { | 332 | public void setStatus(YangStatusType status) { |
... | @@ -355,17 +356,17 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -355,17 +356,17 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
355 | /** | 356 | /** |
356 | * Returns the type of the data. | 357 | * Returns the type of the data. |
357 | * | 358 | * |
358 | - * @return returns CONTAINER_DATA. | 359 | + * @return returns CONTAINER_DATA |
359 | */ | 360 | */ |
360 | @Override | 361 | @Override |
361 | - public ParsableDataType getParsableDataType() { | 362 | + public YangConstructType getYangConstructType() { |
362 | - return ParsableDataType.CONTAINER_DATA; | 363 | + return YangConstructType.CONTAINER_DATA; |
363 | } | 364 | } |
364 | 365 | ||
365 | /** | 366 | /** |
366 | * Validate the data on entering the corresponding parse tree node. | 367 | * Validate the data on entering the corresponding parse tree node. |
367 | * | 368 | * |
368 | - * @throws DataModelException a violation of data model rules. | 369 | + * @throws DataModelException a violation of data model rules |
369 | */ | 370 | */ |
370 | @Override | 371 | @Override |
371 | public void validateDataOnEntry() throws DataModelException { | 372 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -375,7 +376,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -375,7 +376,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
375 | /** | 376 | /** |
376 | * Validate the data on exiting the corresponding parse tree node. | 377 | * Validate the data on exiting the corresponding parse tree node. |
377 | * | 378 | * |
378 | - * @throws DataModelException a violation of data model rules. | 379 | + * @throws DataModelException a violation of data model rules |
379 | */ | 380 | */ |
380 | @Override | 381 | @Override |
381 | public void validateDataOnExit() throws DataModelException { | 382 | public void validateDataOnExit() throws DataModelException { |
... | @@ -387,15 +388,18 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -387,15 +388,18 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
387 | } | 388 | } |
388 | 389 | ||
389 | /** | 390 | /** |
390 | - * Sets the config's value to all leaf if leaf's config statement is not specified. | 391 | + * Sets the config's value to all leaf if leaf's config statement is not |
392 | + * specified. | ||
391 | * | 393 | * |
392 | - * @param leaves list of leaf attributes of container. | 394 | + * @param leaves list of leaf attributes of container |
393 | - * @param leafLists list of leaf-list attributes of container. | 395 | + * @param leafLists list of leaf-list attributes of container |
394 | */ | 396 | */ |
395 | private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) { | 397 | private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) { |
396 | 398 | ||
397 | - /* If "config" is not specified, the default is the same as the parent | 399 | + /* |
398 | - schema node's "config" value.*/ | 400 | + * If "config" is not specified, the default is the same as the parent |
401 | + * schema node's "config" value. | ||
402 | + */ | ||
399 | if (leaves != null) { | 403 | if (leaves != null) { |
400 | for (YangLeaf leaf : leaves) { | 404 | for (YangLeaf leaf : leaves) { |
401 | if (leaf.isConfig() == null) { | 405 | if (leaf.isConfig() == null) { |
... | @@ -404,8 +408,10 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -404,8 +408,10 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
404 | } | 408 | } |
405 | } | 409 | } |
406 | 410 | ||
407 | - /* If "config" is not specified, the default is the same as the parent | 411 | + /* |
408 | - schema node's "config" value.*/ | 412 | + * If "config" is not specified, the default is the same as the parent |
413 | + * schema node's "config" value. | ||
414 | + */ | ||
409 | if (leafLists != null) { | 415 | if (leafLists != null) { |
410 | for (YangLeafList leafList : leafLists) { | 416 | for (YangLeafList leafList : leafLists) { |
411 | if (leafList.isConfig() == null) { | 417 | if (leafList.isConfig() == null) { |
... | @@ -418,14 +424,16 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -418,14 +424,16 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
418 | /** | 424 | /** |
419 | * Validates config statement of container. | 425 | * Validates config statement of container. |
420 | * | 426 | * |
421 | - * @param leaves list of leaf attributes of container. | 427 | + * @param leaves list of leaf attributes of container |
422 | - * @param leafLists list of leaf-list attributes of container. | 428 | + * @param leafLists list of leaf-list attributes of container |
423 | - * @throws DataModelException a violation of data model rules. | 429 | + * @throws DataModelException a violation of data model rules |
424 | */ | 430 | */ |
425 | private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException { | 431 | private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException { |
426 | 432 | ||
427 | - /* If a node has "config" set to "false", no node underneath it can have | 433 | + /* |
428 | - "config" set to "true".*/ | 434 | + * If a node has "config" set to "false", no node underneath it can have |
435 | + * "config" set to "true". | ||
436 | + */ | ||
429 | if ((!isConfig) && (leaves != null)) { | 437 | if ((!isConfig) && (leaves != null)) { |
430 | for (YangLeaf leaf : leaves) { | 438 | for (YangLeaf leaf : leaves) { |
431 | if (leaf.isConfig()) { | 439 | if (leaf.isConfig()) { |
... | @@ -468,7 +476,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -468,7 +476,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
468 | /** | 476 | /** |
469 | * Generate the java code corresponding to YANG container. | 477 | * Generate the java code corresponding to YANG container. |
470 | * | 478 | * |
471 | - * @throws IOException when fails to generate the source files. | 479 | + * @throws IOException when fails to generate the source files |
472 | */ | 480 | */ |
473 | @Override | 481 | @Override |
474 | public void generateJavaCodeEntry() throws IOException { | 482 | public void generateJavaCodeEntry() throws IOException { |
... | @@ -532,4 +540,18 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -532,4 +540,18 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
532 | } | 540 | } |
533 | return; | 541 | return; |
534 | } | 542 | } |
543 | + | ||
544 | + @Override | ||
545 | + public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { | ||
546 | + // Asks helper to detect colliding child. | ||
547 | + detectCollidingChildUtil(identifierName, dataType, this); | ||
548 | + } | ||
549 | + | ||
550 | + @Override | ||
551 | + public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { | ||
552 | + if (this.getName().equals(identifierName)) { | ||
553 | + throw new DataModelException("YANG file error: Duplicate input identifier detected, same as container \"" | ||
554 | + + this.getName() + "\""); | ||
555 | + } | ||
556 | + } | ||
535 | } | 557 | } | ... | ... |
... | @@ -15,7 +15,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -15,7 +15,7 @@ package org.onosproject.yangutils.datamodel; |
15 | 15 | ||
16 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 16 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
17 | import org.onosproject.yangutils.parser.Parsable; | 17 | import org.onosproject.yangutils.parser.Parsable; |
18 | -import org.onosproject.yangutils.parser.ParsableDataType; | 18 | +import org.onosproject.yangutils.utils.YangConstructType; |
19 | 19 | ||
20 | /*- | 20 | /*- |
21 | * The typedef Statement | 21 | * The typedef Statement |
... | @@ -60,7 +60,7 @@ public class YangDerivedType implements Parsable { | ... | @@ -60,7 +60,7 @@ public class YangDerivedType implements Parsable { |
60 | /** | 60 | /** |
61 | * Get the effective YANG built-in type of the derived data type. | 61 | * Get the effective YANG built-in type of the derived data type. |
62 | * | 62 | * |
63 | - * @return effective YANG built-in type of the derived data type. | 63 | + * @return effective YANG built-in type of the derived data type |
64 | */ | 64 | */ |
65 | public YangDataTypes getEffectiveYangBuiltInType() { | 65 | public YangDataTypes getEffectiveYangBuiltInType() { |
66 | return effectiveYangBuiltInType; | 66 | return effectiveYangBuiltInType; |
... | @@ -69,7 +69,7 @@ public class YangDerivedType implements Parsable { | ... | @@ -69,7 +69,7 @@ public class YangDerivedType implements Parsable { |
69 | /** | 69 | /** |
70 | * Set the effective YANG built-in type of the derived data type. | 70 | * Set the effective YANG built-in type of the derived data type. |
71 | * | 71 | * |
72 | - * @param builtInType effective YANG built-in type of the derived data type. | 72 | + * @param builtInType effective YANG built-in type of the derived data type |
73 | */ | 73 | */ |
74 | public void setEffectiveYangBuiltInType(YangDataTypes builtInType) { | 74 | public void setEffectiveYangBuiltInType(YangDataTypes builtInType) { |
75 | effectiveYangBuiltInType = builtInType; | 75 | effectiveYangBuiltInType = builtInType; |
... | @@ -78,7 +78,7 @@ public class YangDerivedType implements Parsable { | ... | @@ -78,7 +78,7 @@ public class YangDerivedType implements Parsable { |
78 | /** | 78 | /** |
79 | * Get the base type information. | 79 | * Get the base type information. |
80 | * | 80 | * |
81 | - * @return base type information. | 81 | + * @return base type information |
82 | */ | 82 | */ |
83 | public YangType<?> getBaseType() { | 83 | public YangType<?> getBaseType() { |
84 | return baseType; | 84 | return baseType; |
... | @@ -87,7 +87,7 @@ public class YangDerivedType implements Parsable { | ... | @@ -87,7 +87,7 @@ public class YangDerivedType implements Parsable { |
87 | /** | 87 | /** |
88 | * Get the base type information. | 88 | * Get the base type information. |
89 | * | 89 | * |
90 | - * @param baseType base type information. | 90 | + * @param baseType base type information |
91 | */ | 91 | */ |
92 | public void setBaseType(YangType<?> baseType) { | 92 | public void setBaseType(YangType<?> baseType) { |
93 | this.baseType = baseType; | 93 | this.baseType = baseType; |
... | @@ -97,8 +97,8 @@ public class YangDerivedType implements Parsable { | ... | @@ -97,8 +97,8 @@ public class YangDerivedType implements Parsable { |
97 | * Get the parsable type. | 97 | * Get the parsable type. |
98 | */ | 98 | */ |
99 | @Override | 99 | @Override |
100 | - public ParsableDataType getParsableDataType() { | 100 | + public YangConstructType getYangConstructType() { |
101 | - return ParsableDataType.DERIVED; | 101 | + return YangConstructType.DERIVED; |
102 | } | 102 | } |
103 | 103 | ||
104 | /** | 104 | /** | ... | ... |
... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
20 | import org.onosproject.yangutils.parser.Parsable; | 20 | import org.onosproject.yangutils.parser.Parsable; |
21 | -import org.onosproject.yangutils.parser.ParsableDataType; | 21 | +import org.onosproject.yangutils.utils.YangConstructType; |
22 | 22 | ||
23 | import java.util.Objects; | 23 | import java.util.Objects; |
24 | 24 | ||
... | @@ -73,7 +73,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -73,7 +73,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
73 | private YangStatusType status; | 73 | private YangStatusType status; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | - * value of ENUM. | 76 | + * Value of ENUM. |
77 | */ | 77 | */ |
78 | private int value; | 78 | private int value; |
79 | 79 | ||
... | @@ -87,7 +87,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -87,7 +87,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
87 | /** | 87 | /** |
88 | * Get the named value. | 88 | * Get the named value. |
89 | * | 89 | * |
90 | - * @return the named value. | 90 | + * @return the named value |
91 | */ | 91 | */ |
92 | public String getNamedValue() { | 92 | public String getNamedValue() { |
93 | return namedValue; | 93 | return namedValue; |
... | @@ -96,7 +96,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -96,7 +96,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
96 | /** | 96 | /** |
97 | * Set the named value. | 97 | * Set the named value. |
98 | * | 98 | * |
99 | - * @param namedValue the named value to set. | 99 | + * @param namedValue the named value to set |
100 | */ | 100 | */ |
101 | public void setNamedValue(String namedValue) { | 101 | public void setNamedValue(String namedValue) { |
102 | this.namedValue = namedValue; | 102 | this.namedValue = namedValue; |
... | @@ -105,7 +105,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -105,7 +105,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
105 | /** | 105 | /** |
106 | * Get the description. | 106 | * Get the description. |
107 | * | 107 | * |
108 | - * @return the description. | 108 | + * @return the description |
109 | */ | 109 | */ |
110 | @Override | 110 | @Override |
111 | public String getDescription() { | 111 | public String getDescription() { |
... | @@ -115,7 +115,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -115,7 +115,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
115 | /** | 115 | /** |
116 | * Set the description. | 116 | * Set the description. |
117 | * | 117 | * |
118 | - * @param description set the description. | 118 | + * @param description set the description |
119 | */ | 119 | */ |
120 | @Override | 120 | @Override |
121 | public void setDescription(String description) { | 121 | public void setDescription(String description) { |
... | @@ -125,7 +125,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -125,7 +125,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
125 | /** | 125 | /** |
126 | * Get the textual reference. | 126 | * Get the textual reference. |
127 | * | 127 | * |
128 | - * @return the reference. | 128 | + * @return the reference |
129 | */ | 129 | */ |
130 | @Override | 130 | @Override |
131 | public String getReference() { | 131 | public String getReference() { |
... | @@ -135,7 +135,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -135,7 +135,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
135 | /** | 135 | /** |
136 | * Set the textual reference. | 136 | * Set the textual reference. |
137 | * | 137 | * |
138 | - * @param reference the reference to set. | 138 | + * @param reference the reference to set |
139 | */ | 139 | */ |
140 | @Override | 140 | @Override |
141 | public void setReference(String reference) { | 141 | public void setReference(String reference) { |
... | @@ -145,7 +145,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -145,7 +145,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
145 | /** | 145 | /** |
146 | * Get the status. | 146 | * Get the status. |
147 | * | 147 | * |
148 | - * @return the status. | 148 | + * @return the status |
149 | */ | 149 | */ |
150 | @Override | 150 | @Override |
151 | public YangStatusType getStatus() { | 151 | public YangStatusType getStatus() { |
... | @@ -155,7 +155,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -155,7 +155,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
155 | /** | 155 | /** |
156 | * Set the status. | 156 | * Set the status. |
157 | * | 157 | * |
158 | - * @param status the status to set. | 158 | + * @param status the status to set |
159 | */ | 159 | */ |
160 | @Override | 160 | @Override |
161 | public void setStatus(YangStatusType status) { | 161 | public void setStatus(YangStatusType status) { |
... | @@ -165,7 +165,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -165,7 +165,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
165 | /** | 165 | /** |
166 | * Get the value. | 166 | * Get the value. |
167 | * | 167 | * |
168 | - * @return the value. | 168 | + * @return the value |
169 | */ | 169 | */ |
170 | public int getValue() { | 170 | public int getValue() { |
171 | return value; | 171 | return value; |
... | @@ -174,7 +174,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -174,7 +174,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
174 | /** | 174 | /** |
175 | * Set the value. | 175 | * Set the value. |
176 | * | 176 | * |
177 | - * @param value the value to set. | 177 | + * @param value the value to set |
178 | */ | 178 | */ |
179 | public void setValue(int value) { | 179 | public void setValue(int value) { |
180 | this.value = value; | 180 | this.value = value; |
... | @@ -186,8 +186,8 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -186,8 +186,8 @@ public class YangEnum implements YangCommonInfo, Parsable { |
186 | * @return ParsedDataType returns ENUM_DATA | 186 | * @return ParsedDataType returns ENUM_DATA |
187 | */ | 187 | */ |
188 | @Override | 188 | @Override |
189 | - public ParsableDataType getParsableDataType() { | 189 | + public YangConstructType getYangConstructType() { |
190 | - return ParsableDataType.ENUM_DATA; | 190 | + return YangConstructType.ENUM_DATA; |
191 | } | 191 | } |
192 | 192 | ||
193 | @Override | 193 | @Override |
... | @@ -210,7 +210,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -210,7 +210,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
210 | /** | 210 | /** |
211 | * Validate the data on entering the corresponding parse tree node. | 211 | * Validate the data on entering the corresponding parse tree node. |
212 | * | 212 | * |
213 | - * @throws DataModelException a violation of data model rules. | 213 | + * @throws DataModelException a violation of data model rules |
214 | */ | 214 | */ |
215 | @Override | 215 | @Override |
216 | public void validateDataOnEntry() throws DataModelException { | 216 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -220,7 +220,7 @@ public class YangEnum implements YangCommonInfo, Parsable { | ... | @@ -220,7 +220,7 @@ public class YangEnum implements YangCommonInfo, Parsable { |
220 | /** | 220 | /** |
221 | * Validate the data on exiting the corresponding parse tree node. | 221 | * Validate the data on exiting the corresponding parse tree node. |
222 | * | 222 | * |
223 | - * @throws DataModelException a violation of data model rules. | 223 | + * @throws DataModelException a violation of data model rules |
224 | */ | 224 | */ |
225 | @Override | 225 | @Override |
226 | public void validateDataOnExit() throws DataModelException { | 226 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -21,7 +21,7 @@ import java.util.Set; | ... | @@ -21,7 +21,7 @@ import java.util.Set; |
21 | 21 | ||
22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
23 | import org.onosproject.yangutils.parser.Parsable; | 23 | import org.onosproject.yangutils.parser.Parsable; |
24 | -import org.onosproject.yangutils.parser.ParsableDataType; | 24 | +import org.onosproject.yangutils.utils.YangConstructType; |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * The enumeration built-in type represents values from a set of | 27 | * The enumeration built-in type represents values from a set of |
... | @@ -67,8 +67,8 @@ public class YangEnumeration implements Parsable { | ... | @@ -67,8 +67,8 @@ public class YangEnumeration implements Parsable { |
67 | /** | 67 | /** |
68 | * Add ENUM information. | 68 | * Add ENUM information. |
69 | * | 69 | * |
70 | - * @param enumInfo the ENUM information to be added. | 70 | + * @param enumInfo the ENUM information to be added |
71 | - * @throws DataModelException due to violation in data model rules. | 71 | + * @throws DataModelException due to violation in data model rules |
72 | */ | 72 | */ |
73 | public void addEnumInfo(YangEnum enumInfo) throws DataModelException { | 73 | public void addEnumInfo(YangEnum enumInfo) throws DataModelException { |
74 | if (!getEnumSet().add(enumInfo)) { | 74 | if (!getEnumSet().add(enumInfo)) { |
... | @@ -100,14 +100,14 @@ public class YangEnumeration implements Parsable { | ... | @@ -100,14 +100,14 @@ public class YangEnumeration implements Parsable { |
100 | * @return returns ENUMERATION_DATA | 100 | * @return returns ENUMERATION_DATA |
101 | */ | 101 | */ |
102 | @Override | 102 | @Override |
103 | - public ParsableDataType getParsableDataType() { | 103 | + public YangConstructType getYangConstructType() { |
104 | - return ParsableDataType.ENUMERATION_DATA; | 104 | + return YangConstructType.ENUMERATION_DATA; |
105 | } | 105 | } |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Validate the data on entering the corresponding parse tree node. | 108 | * Validate the data on entering the corresponding parse tree node. |
109 | * | 109 | * |
110 | - * @throws DataModelException a violation of data model rules. | 110 | + * @throws DataModelException a violation of data model rules |
111 | */ | 111 | */ |
112 | @Override | 112 | @Override |
113 | public void validateDataOnEntry() throws DataModelException { | 113 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -117,7 +117,7 @@ public class YangEnumeration implements Parsable { | ... | @@ -117,7 +117,7 @@ public class YangEnumeration implements Parsable { |
117 | /** | 117 | /** |
118 | * Validate the data on exiting the corresponding parse tree node. | 118 | * Validate the data on exiting the corresponding parse tree node. |
119 | * | 119 | * |
120 | - * @throws DataModelException a violation of data model rules. | 120 | + * @throws DataModelException a violation of data model rules |
121 | */ | 121 | */ |
122 | @Override | 122 | @Override |
123 | public void validateDataOnExit() throws DataModelException { | 123 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -20,7 +20,7 @@ import java.util.List; | ... | @@ -20,7 +20,7 @@ import java.util.List; |
20 | 20 | ||
21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
22 | import org.onosproject.yangutils.parser.Parsable; | 22 | import org.onosproject.yangutils.parser.Parsable; |
23 | -import org.onosproject.yangutils.parser.ParsableDataType; | 23 | +import org.onosproject.yangutils.utils.YangConstructType; |
24 | import org.onosproject.yangutils.translator.CachedFileHandle; | 24 | import org.onosproject.yangutils.translator.CachedFileHandle; |
25 | 25 | ||
26 | /*- | 26 | /*- |
... | @@ -110,7 +110,7 @@ public class YangGrouping extends YangNode | ... | @@ -110,7 +110,7 @@ public class YangGrouping extends YangNode |
110 | private YangStatusType status; | 110 | private YangStatusType status; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | - * package of the generated java code. | 113 | + * Package of the generated java code. |
114 | */ | 114 | */ |
115 | private String pkg; | 115 | private String pkg; |
116 | 116 | ||
... | @@ -124,7 +124,7 @@ public class YangGrouping extends YangNode | ... | @@ -124,7 +124,7 @@ public class YangGrouping extends YangNode |
124 | /** | 124 | /** |
125 | * Get YANG grouping name. | 125 | * Get YANG grouping name. |
126 | * | 126 | * |
127 | - * @return YANG grouping name. | 127 | + * @return YANG grouping name |
128 | */ | 128 | */ |
129 | @Override | 129 | @Override |
130 | public String getName() { | 130 | public String getName() { |
... | @@ -134,7 +134,7 @@ public class YangGrouping extends YangNode | ... | @@ -134,7 +134,7 @@ public class YangGrouping extends YangNode |
134 | /** | 134 | /** |
135 | * Set YANG grouping name. | 135 | * Set YANG grouping name. |
136 | * | 136 | * |
137 | - * @param name YANG grouping name. | 137 | + * @param name YANG grouping name |
138 | */ | 138 | */ |
139 | @Override | 139 | @Override |
140 | public void setName(String name) { | 140 | public void setName(String name) { |
... | @@ -144,7 +144,7 @@ public class YangGrouping extends YangNode | ... | @@ -144,7 +144,7 @@ public class YangGrouping extends YangNode |
144 | /** | 144 | /** |
145 | * Get the description. | 145 | * Get the description. |
146 | * | 146 | * |
147 | - * @return the description. | 147 | + * @return the description |
148 | */ | 148 | */ |
149 | @Override | 149 | @Override |
150 | public String getDescription() { | 150 | public String getDescription() { |
... | @@ -154,7 +154,7 @@ public class YangGrouping extends YangNode | ... | @@ -154,7 +154,7 @@ public class YangGrouping extends YangNode |
154 | /** | 154 | /** |
155 | * Set the description. | 155 | * Set the description. |
156 | * | 156 | * |
157 | - * @param description set the description. | 157 | + * @param description set the description |
158 | */ | 158 | */ |
159 | @Override | 159 | @Override |
160 | public void setDescription(String description) { | 160 | public void setDescription(String description) { |
... | @@ -164,7 +164,7 @@ public class YangGrouping extends YangNode | ... | @@ -164,7 +164,7 @@ public class YangGrouping extends YangNode |
164 | /** | 164 | /** |
165 | * Get the list of leaves. | 165 | * Get the list of leaves. |
166 | * | 166 | * |
167 | - * @return the list of leaves. | 167 | + * @return the list of leaves |
168 | */ | 168 | */ |
169 | @Override | 169 | @Override |
170 | public List<YangLeaf> getListOfLeaf() { | 170 | public List<YangLeaf> getListOfLeaf() { |
... | @@ -174,7 +174,7 @@ public class YangGrouping extends YangNode | ... | @@ -174,7 +174,7 @@ public class YangGrouping extends YangNode |
174 | /** | 174 | /** |
175 | * Set the list of leaves. | 175 | * Set the list of leaves. |
176 | * | 176 | * |
177 | - * @param leafsList the list of leaf to set. | 177 | + * @param leafsList the list of leaf to set |
178 | */ | 178 | */ |
179 | private void setListOfLeaf(List<YangLeaf> leafsList) { | 179 | private void setListOfLeaf(List<YangLeaf> leafsList) { |
180 | listOfLeaf = leafsList; | 180 | listOfLeaf = leafsList; |
... | @@ -183,7 +183,7 @@ public class YangGrouping extends YangNode | ... | @@ -183,7 +183,7 @@ public class YangGrouping extends YangNode |
183 | /** | 183 | /** |
184 | * Add a leaf. | 184 | * Add a leaf. |
185 | * | 185 | * |
186 | - * @param leaf the leaf to be added. | 186 | + * @param leaf the leaf to be added |
187 | */ | 187 | */ |
188 | @Override | 188 | @Override |
189 | public void addLeaf(YangLeaf leaf) { | 189 | public void addLeaf(YangLeaf leaf) { |
... | @@ -197,7 +197,7 @@ public class YangGrouping extends YangNode | ... | @@ -197,7 +197,7 @@ public class YangGrouping extends YangNode |
197 | /** | 197 | /** |
198 | * Get the list of leaf-list. | 198 | * Get the list of leaf-list. |
199 | * | 199 | * |
200 | - * @return the list of leaf-list. | 200 | + * @return the list of leaf-list |
201 | */ | 201 | */ |
202 | @Override | 202 | @Override |
203 | public List<YangLeafList> getListOfLeafList() { | 203 | public List<YangLeafList> getListOfLeafList() { |
... | @@ -207,7 +207,7 @@ public class YangGrouping extends YangNode | ... | @@ -207,7 +207,7 @@ public class YangGrouping extends YangNode |
207 | /** | 207 | /** |
208 | * Set the list of leaf-list. | 208 | * Set the list of leaf-list. |
209 | * | 209 | * |
210 | - * @param listOfLeafList the list of leaf-list to set. | 210 | + * @param listOfLeafList the list of leaf-list to set |
211 | */ | 211 | */ |
212 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | 212 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
213 | this.listOfLeafList = listOfLeafList; | 213 | this.listOfLeafList = listOfLeafList; |
... | @@ -216,7 +216,7 @@ public class YangGrouping extends YangNode | ... | @@ -216,7 +216,7 @@ public class YangGrouping extends YangNode |
216 | /** | 216 | /** |
217 | * Add a leaf-list. | 217 | * Add a leaf-list. |
218 | * | 218 | * |
219 | - * @param leafList the leaf-list to be added. | 219 | + * @param leafList the leaf-list to be added |
220 | */ | 220 | */ |
221 | @Override | 221 | @Override |
222 | public void addLeafList(YangLeafList leafList) { | 222 | public void addLeafList(YangLeafList leafList) { |
... | @@ -230,7 +230,7 @@ public class YangGrouping extends YangNode | ... | @@ -230,7 +230,7 @@ public class YangGrouping extends YangNode |
230 | /** | 230 | /** |
231 | * Get the textual reference. | 231 | * Get the textual reference. |
232 | * | 232 | * |
233 | - * @return the reference. | 233 | + * @return the reference |
234 | */ | 234 | */ |
235 | @Override | 235 | @Override |
236 | public String getReference() { | 236 | public String getReference() { |
... | @@ -240,7 +240,7 @@ public class YangGrouping extends YangNode | ... | @@ -240,7 +240,7 @@ public class YangGrouping extends YangNode |
240 | /** | 240 | /** |
241 | * Set the textual reference. | 241 | * Set the textual reference. |
242 | * | 242 | * |
243 | - * @param reference the reference to set. | 243 | + * @param reference the reference to set |
244 | */ | 244 | */ |
245 | @Override | 245 | @Override |
246 | public void setReference(String reference) { | 246 | public void setReference(String reference) { |
... | @@ -250,7 +250,7 @@ public class YangGrouping extends YangNode | ... | @@ -250,7 +250,7 @@ public class YangGrouping extends YangNode |
250 | /** | 250 | /** |
251 | * Get the status. | 251 | * Get the status. |
252 | * | 252 | * |
253 | - * @return the status. | 253 | + * @return the status |
254 | */ | 254 | */ |
255 | @Override | 255 | @Override |
256 | public YangStatusType getStatus() { | 256 | public YangStatusType getStatus() { |
... | @@ -260,7 +260,7 @@ public class YangGrouping extends YangNode | ... | @@ -260,7 +260,7 @@ public class YangGrouping extends YangNode |
260 | /** | 260 | /** |
261 | * Set the status. | 261 | * Set the status. |
262 | * | 262 | * |
263 | - * @param status the status to set. | 263 | + * @param status the status to set |
264 | */ | 264 | */ |
265 | @Override | 265 | @Override |
266 | public void setStatus(YangStatusType status) { | 266 | public void setStatus(YangStatusType status) { |
... | @@ -270,17 +270,17 @@ public class YangGrouping extends YangNode | ... | @@ -270,17 +270,17 @@ public class YangGrouping extends YangNode |
270 | /** | 270 | /** |
271 | * Returns the type of the data. | 271 | * Returns the type of the data. |
272 | * | 272 | * |
273 | - * @return returns GROUPING_DATA. | 273 | + * @return returns GROUPING_DATA |
274 | */ | 274 | */ |
275 | @Override | 275 | @Override |
276 | - public ParsableDataType getParsableDataType() { | 276 | + public YangConstructType getYangConstructType() { |
277 | - return ParsableDataType.GROUPING_DATA; | 277 | + return YangConstructType.GROUPING_DATA; |
278 | } | 278 | } |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * Validate the data on entering the corresponding parse tree node. | 281 | * Validate the data on entering the corresponding parse tree node. |
282 | * | 282 | * |
283 | - * @throws DataModelException a violation of data model rules. | 283 | + * @throws DataModelException a violation of data model rules |
284 | */ | 284 | */ |
285 | @Override | 285 | @Override |
286 | public void validateDataOnEntry() throws DataModelException { | 286 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -290,7 +290,7 @@ public class YangGrouping extends YangNode | ... | @@ -290,7 +290,7 @@ public class YangGrouping extends YangNode |
290 | /** | 290 | /** |
291 | * Validate the data on exiting the corresponding parse tree node. | 291 | * Validate the data on exiting the corresponding parse tree node. |
292 | * | 292 | * |
293 | - * @throws DataModelException a violation of data model rules. | 293 | + * @throws DataModelException a violation of data model rules |
294 | */ | 294 | */ |
295 | @Override | 295 | @Override |
296 | public void validateDataOnExit() throws DataModelException { | 296 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | import org.onosproject.yangutils.parser.Parsable; | 19 | import org.onosproject.yangutils.parser.Parsable; |
20 | -import org.onosproject.yangutils.parser.ParsableDataType; | 20 | +import org.onosproject.yangutils.utils.YangConstructType; |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * Reference:RFC 6020. | 23 | * Reference:RFC 6020. |
... | @@ -94,7 +94,7 @@ public class YangImport implements Parsable { | ... | @@ -94,7 +94,7 @@ public class YangImport implements Parsable { |
94 | /** | 94 | /** |
95 | * Get the imported module name. | 95 | * Get the imported module name. |
96 | * | 96 | * |
97 | - * @return the module name. | 97 | + * @return the module name |
98 | */ | 98 | */ |
99 | public String getModuleName() { | 99 | public String getModuleName() { |
100 | return name; | 100 | return name; |
... | @@ -113,7 +113,7 @@ public class YangImport implements Parsable { | ... | @@ -113,7 +113,7 @@ public class YangImport implements Parsable { |
113 | * Get the prefix used to identify the entities from the imported module. | 113 | * Get the prefix used to identify the entities from the imported module. |
114 | * | 114 | * |
115 | * @return the prefix used to identify the entities from the imported | 115 | * @return the prefix used to identify the entities from the imported |
116 | - * module. | 116 | + * module |
117 | */ | 117 | */ |
118 | public String getPrefixId() { | 118 | public String getPrefixId() { |
119 | return prefixId; | 119 | return prefixId; |
... | @@ -122,7 +122,7 @@ public class YangImport implements Parsable { | ... | @@ -122,7 +122,7 @@ public class YangImport implements Parsable { |
122 | /** | 122 | /** |
123 | * Set prefix identifier. | 123 | * Set prefix identifier. |
124 | * | 124 | * |
125 | - * @param prefixId set the prefix identifier of the imported module. | 125 | + * @param prefixId set the prefix identifier of the imported module |
126 | */ | 126 | */ |
127 | public void setPrefixId(String prefixId) { | 127 | public void setPrefixId(String prefixId) { |
128 | this.prefixId = prefixId; | 128 | this.prefixId = prefixId; |
... | @@ -131,7 +131,7 @@ public class YangImport implements Parsable { | ... | @@ -131,7 +131,7 @@ public class YangImport implements Parsable { |
131 | /** | 131 | /** |
132 | * Get the revision of the imported module. | 132 | * Get the revision of the imported module. |
133 | * | 133 | * |
134 | - * @return the revision of the imported module. | 134 | + * @return the revision of the imported module |
135 | */ | 135 | */ |
136 | public String getRevision() { | 136 | public String getRevision() { |
137 | return revision; | 137 | return revision; |
... | @@ -140,7 +140,7 @@ public class YangImport implements Parsable { | ... | @@ -140,7 +140,7 @@ public class YangImport implements Parsable { |
140 | /** | 140 | /** |
141 | * Set the revision of the imported module. | 141 | * Set the revision of the imported module. |
142 | * | 142 | * |
143 | - * @param rev set the revision of the imported module. | 143 | + * @param rev set the revision of the imported module |
144 | */ | 144 | */ |
145 | public void setRevision(String rev) { | 145 | public void setRevision(String rev) { |
146 | revision = rev; | 146 | revision = rev; |
... | @@ -152,8 +152,8 @@ public class YangImport implements Parsable { | ... | @@ -152,8 +152,8 @@ public class YangImport implements Parsable { |
152 | * @return returns IMPORT_DATA | 152 | * @return returns IMPORT_DATA |
153 | */ | 153 | */ |
154 | @Override | 154 | @Override |
155 | - public ParsableDataType getParsableDataType() { | 155 | + public YangConstructType getYangConstructType() { |
156 | - return ParsableDataType.IMPORT_DATA; | 156 | + return YangConstructType.IMPORT_DATA; |
157 | } | 157 | } |
158 | 158 | ||
159 | /** | 159 | /** | ... | ... |
... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | import org.onosproject.yangutils.parser.Parsable; | 19 | import org.onosproject.yangutils.parser.Parsable; |
20 | -import org.onosproject.yangutils.parser.ParsableDataType; | 20 | +import org.onosproject.yangutils.utils.YangConstructType; |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * Reference:RFC 6020. | 23 | * Reference:RFC 6020. |
... | @@ -98,8 +98,8 @@ public class YangInclude implements Parsable { | ... | @@ -98,8 +98,8 @@ public class YangInclude implements Parsable { |
98 | * @return returns INCLUDE_DATA | 98 | * @return returns INCLUDE_DATA |
99 | */ | 99 | */ |
100 | @Override | 100 | @Override |
101 | - public ParsableDataType getParsableDataType() { | 101 | + public YangConstructType getYangConstructType() { |
102 | - return ParsableDataType.INCLUDE_DATA; | 102 | + return YangConstructType.INCLUDE_DATA; |
103 | } | 103 | } |
104 | 104 | ||
105 | /** | 105 | /** | ... | ... |
... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
20 | import org.onosproject.yangutils.parser.Parsable; | 20 | import org.onosproject.yangutils.parser.Parsable; |
21 | -import org.onosproject.yangutils.parser.ParsableDataType; | 21 | +import org.onosproject.yangutils.utils.YangConstructType; |
22 | 22 | ||
23 | /* | 23 | /* |
24 | * Reference:RFC 6020. | 24 | * Reference:RFC 6020. |
... | @@ -108,7 +108,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -108,7 +108,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
108 | /** | 108 | /** |
109 | * Get the name of leaf. | 109 | * Get the name of leaf. |
110 | * | 110 | * |
111 | - * @return the leaf name. | 111 | + * @return the leaf name |
112 | */ | 112 | */ |
113 | public String getLeafName() { | 113 | public String getLeafName() { |
114 | return name; | 114 | return name; |
... | @@ -117,7 +117,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -117,7 +117,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
117 | /** | 117 | /** |
118 | * Set the name of leaf. | 118 | * Set the name of leaf. |
119 | * | 119 | * |
120 | - * @param leafName the leaf name to set. | 120 | + * @param leafName the leaf name to set |
121 | */ | 121 | */ |
122 | public void setLeafName(String leafName) { | 122 | public void setLeafName(String leafName) { |
123 | name = leafName; | 123 | name = leafName; |
... | @@ -126,7 +126,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -126,7 +126,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
126 | /** | 126 | /** |
127 | * Get the config flag. | 127 | * Get the config flag. |
128 | * | 128 | * |
129 | - * @return if config flag. | 129 | + * @return if config flag |
130 | */ | 130 | */ |
131 | public Boolean isConfig() { | 131 | public Boolean isConfig() { |
132 | return isConfig; | 132 | return isConfig; |
... | @@ -135,7 +135,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -135,7 +135,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
135 | /** | 135 | /** |
136 | * Set the config flag. | 136 | * Set the config flag. |
137 | * | 137 | * |
138 | - * @param isCfg the flag value to set. | 138 | + * @param isCfg the flag value to set |
139 | */ | 139 | */ |
140 | public void setConfig(boolean isCfg) { | 140 | public void setConfig(boolean isCfg) { |
141 | isConfig = isCfg; | 141 | isConfig = isCfg; |
... | @@ -144,7 +144,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -144,7 +144,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
144 | /** | 144 | /** |
145 | * Get the description. | 145 | * Get the description. |
146 | * | 146 | * |
147 | - * @return the description. | 147 | + * @return the description |
148 | */ | 148 | */ |
149 | @Override | 149 | @Override |
150 | public String getDescription() { | 150 | public String getDescription() { |
... | @@ -154,7 +154,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -154,7 +154,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
154 | /** | 154 | /** |
155 | * Set the description. | 155 | * Set the description. |
156 | * | 156 | * |
157 | - * @param description set the description. | 157 | + * @param description set the description |
158 | */ | 158 | */ |
159 | @Override | 159 | @Override |
160 | public void setDescription(String description) { | 160 | public void setDescription(String description) { |
... | @@ -164,7 +164,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -164,7 +164,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
164 | /** | 164 | /** |
165 | * Get if the leaf is mandatory. | 165 | * Get if the leaf is mandatory. |
166 | * | 166 | * |
167 | - * @return if leaf is mandatory. | 167 | + * @return if leaf is mandatory |
168 | */ | 168 | */ |
169 | public boolean isMandatory() { | 169 | public boolean isMandatory() { |
170 | return isMandatory; | 170 | return isMandatory; |
... | @@ -182,7 +182,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -182,7 +182,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
182 | /** | 182 | /** |
183 | * Get the textual reference. | 183 | * Get the textual reference. |
184 | * | 184 | * |
185 | - * @return the reference. | 185 | + * @return the reference |
186 | */ | 186 | */ |
187 | @Override | 187 | @Override |
188 | public String getReference() { | 188 | public String getReference() { |
... | @@ -192,7 +192,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -192,7 +192,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
192 | /** | 192 | /** |
193 | * Set the textual reference. | 193 | * Set the textual reference. |
194 | * | 194 | * |
195 | - * @param reference the reference to set. | 195 | + * @param reference the reference to set |
196 | */ | 196 | */ |
197 | @Override | 197 | @Override |
198 | public void setReference(String reference) { | 198 | public void setReference(String reference) { |
... | @@ -202,7 +202,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -202,7 +202,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
202 | /** | 202 | /** |
203 | * Get the status. | 203 | * Get the status. |
204 | * | 204 | * |
205 | - * @return the status. | 205 | + * @return the status |
206 | */ | 206 | */ |
207 | @Override | 207 | @Override |
208 | public YangStatusType getStatus() { | 208 | public YangStatusType getStatus() { |
... | @@ -212,7 +212,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -212,7 +212,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
212 | /** | 212 | /** |
213 | * Set the status. | 213 | * Set the status. |
214 | * | 214 | * |
215 | - * @param status the status to set. | 215 | + * @param status the status to set |
216 | */ | 216 | */ |
217 | @Override | 217 | @Override |
218 | public void setStatus(YangStatusType status) { | 218 | public void setStatus(YangStatusType status) { |
... | @@ -222,7 +222,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -222,7 +222,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
222 | /** | 222 | /** |
223 | * Get the units. | 223 | * Get the units. |
224 | * | 224 | * |
225 | - * @return the units. | 225 | + * @return the units |
226 | */ | 226 | */ |
227 | public String getUnits() { | 227 | public String getUnits() { |
228 | return units; | 228 | return units; |
... | @@ -231,7 +231,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -231,7 +231,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
231 | /** | 231 | /** |
232 | * Set the units. | 232 | * Set the units. |
233 | * | 233 | * |
234 | - * @param units the units to set. | 234 | + * @param units the units to set |
235 | */ | 235 | */ |
236 | public void setUnits(String units) { | 236 | public void setUnits(String units) { |
237 | this.units = units; | 237 | this.units = units; |
... | @@ -240,7 +240,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -240,7 +240,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
240 | /** | 240 | /** |
241 | * Get the data type. | 241 | * Get the data type. |
242 | * | 242 | * |
243 | - * @return the data type. | 243 | + * @return the data type |
244 | */ | 244 | */ |
245 | public YangType<?> getDataType() { | 245 | public YangType<?> getDataType() { |
246 | return dataType; | 246 | return dataType; |
... | @@ -249,7 +249,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -249,7 +249,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
249 | /** | 249 | /** |
250 | * Set the data type. | 250 | * Set the data type. |
251 | * | 251 | * |
252 | - * @param dataType the data type to set. | 252 | + * @param dataType the data type to set |
253 | */ | 253 | */ |
254 | public void setDataType(YangType<?> dataType) { | 254 | public void setDataType(YangType<?> dataType) { |
255 | this.dataType = dataType; | 255 | this.dataType = dataType; |
... | @@ -258,17 +258,17 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -258,17 +258,17 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
258 | /** | 258 | /** |
259 | * Returns the type of the parsed data. | 259 | * Returns the type of the parsed data. |
260 | * | 260 | * |
261 | - * @return returns LEAF_DATA. | 261 | + * @return returns LEAF_DATA |
262 | */ | 262 | */ |
263 | @Override | 263 | @Override |
264 | - public ParsableDataType getParsableDataType() { | 264 | + public YangConstructType getYangConstructType() { |
265 | - return ParsableDataType.LEAF_DATA; | 265 | + return YangConstructType.LEAF_DATA; |
266 | } | 266 | } |
267 | 267 | ||
268 | /** | 268 | /** |
269 | * Validate the data on entering the corresponding parse tree node. | 269 | * Validate the data on entering the corresponding parse tree node. |
270 | * | 270 | * |
271 | - * @throws DataModelException a violation of data model rules. | 271 | + * @throws DataModelException a violation of data model rules |
272 | */ | 272 | */ |
273 | @Override | 273 | @Override |
274 | public void validateDataOnEntry() throws DataModelException { | 274 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -279,7 +279,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -279,7 +279,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
279 | /** | 279 | /** |
280 | * Validate the data on exiting the corresponding parse tree node. | 280 | * Validate the data on exiting the corresponding parse tree node. |
281 | * | 281 | * |
282 | - * @throws DataModelException a violation of data model rules. | 282 | + * @throws DataModelException a violation of data model rules |
283 | */ | 283 | */ |
284 | @Override | 284 | @Override |
285 | public void validateDataOnExit() throws DataModelException { | 285 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
20 | import org.onosproject.yangutils.parser.Parsable; | 20 | import org.onosproject.yangutils.parser.Parsable; |
21 | -import org.onosproject.yangutils.parser.ParsableDataType; | 21 | +import org.onosproject.yangutils.utils.YangConstructType; |
22 | 22 | ||
23 | /* | 23 | /* |
24 | * Reference:RFC 6020. | 24 | * Reference:RFC 6020. |
... | @@ -130,7 +130,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -130,7 +130,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
130 | /** | 130 | /** |
131 | * Get the leaf-list name. | 131 | * Get the leaf-list name. |
132 | * | 132 | * |
133 | - * @return the leaf-list name. | 133 | + * @return the leaf-list name |
134 | */ | 134 | */ |
135 | public String getLeafName() { | 135 | public String getLeafName() { |
136 | return name; | 136 | return name; |
... | @@ -139,7 +139,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -139,7 +139,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
139 | /** | 139 | /** |
140 | * Set the leaf-list name. | 140 | * Set the leaf-list name. |
141 | * | 141 | * |
142 | - * @param leafListName the leaf-list name to set. | 142 | + * @param leafListName the leaf-list name to set |
143 | */ | 143 | */ |
144 | public void setLeafName(String leafListName) { | 144 | public void setLeafName(String leafListName) { |
145 | name = leafListName; | 145 | name = leafListName; |
... | @@ -148,7 +148,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -148,7 +148,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
148 | /** | 148 | /** |
149 | * Get the config flag. | 149 | * Get the config flag. |
150 | * | 150 | * |
151 | - * @return the config flag. | 151 | + * @return the config flag |
152 | */ | 152 | */ |
153 | public Boolean isConfig() { | 153 | public Boolean isConfig() { |
154 | return isConfig; | 154 | return isConfig; |
... | @@ -157,7 +157,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -157,7 +157,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
157 | /** | 157 | /** |
158 | * Set the config flag. | 158 | * Set the config flag. |
159 | * | 159 | * |
160 | - * @param isCfg the config flag. | 160 | + * @param isCfg the config flag |
161 | */ | 161 | */ |
162 | public void setConfig(boolean isCfg) { | 162 | public void setConfig(boolean isCfg) { |
163 | isConfig = isCfg; | 163 | isConfig = isCfg; |
... | @@ -166,7 +166,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -166,7 +166,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
166 | /** | 166 | /** |
167 | * Get the description. | 167 | * Get the description. |
168 | * | 168 | * |
169 | - * @return the description. | 169 | + * @return the description |
170 | */ | 170 | */ |
171 | @Override | 171 | @Override |
172 | public String getDescription() { | 172 | public String getDescription() { |
... | @@ -176,7 +176,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -176,7 +176,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
176 | /** | 176 | /** |
177 | * Set the description. | 177 | * Set the description. |
178 | * | 178 | * |
179 | - * @param description set the description. | 179 | + * @param description set the description |
180 | */ | 180 | */ |
181 | @Override | 181 | @Override |
182 | public void setDescription(String description) { | 182 | public void setDescription(String description) { |
... | @@ -186,7 +186,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -186,7 +186,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
186 | /** | 186 | /** |
187 | * Get the max elements no. | 187 | * Get the max elements no. |
188 | * | 188 | * |
189 | - * @return the max elements no. | 189 | + * @return the max elements no |
190 | */ | 190 | */ |
191 | public int getMaxElelements() { | 191 | public int getMaxElelements() { |
192 | return maxElelements; | 192 | return maxElelements; |
... | @@ -195,7 +195,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -195,7 +195,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
195 | /** | 195 | /** |
196 | * Set the max elements no. | 196 | * Set the max elements no. |
197 | * | 197 | * |
198 | - * @param maxElelements max elements no. | 198 | + * @param maxElelements max elements no |
199 | */ | 199 | */ |
200 | public void setMaxElelements(int maxElelements) { | 200 | public void setMaxElelements(int maxElelements) { |
201 | this.maxElelements = maxElelements; | 201 | this.maxElelements = maxElelements; |
... | @@ -204,7 +204,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -204,7 +204,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
204 | /** | 204 | /** |
205 | * Get the min elements no. | 205 | * Get the min elements no. |
206 | * | 206 | * |
207 | - * @return the min elements no. | 207 | + * @return the min elements no |
208 | */ | 208 | */ |
209 | public int getMinElements() { | 209 | public int getMinElements() { |
210 | return minElements; | 210 | return minElements; |
... | @@ -213,7 +213,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -213,7 +213,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
213 | /** | 213 | /** |
214 | * Set the min elements no. | 214 | * Set the min elements no. |
215 | * | 215 | * |
216 | - * @param minElements the min elements no. | 216 | + * @param minElements the min elements no |
217 | */ | 217 | */ |
218 | public void setMinElements(int minElements) { | 218 | public void setMinElements(int minElements) { |
219 | this.minElements = minElements; | 219 | this.minElements = minElements; |
... | @@ -222,7 +222,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -222,7 +222,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
222 | /** | 222 | /** |
223 | * Get the textual reference. | 223 | * Get the textual reference. |
224 | * | 224 | * |
225 | - * @return the reference. | 225 | + * @return the reference |
226 | */ | 226 | */ |
227 | @Override | 227 | @Override |
228 | public String getReference() { | 228 | public String getReference() { |
... | @@ -232,7 +232,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -232,7 +232,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
232 | /** | 232 | /** |
233 | * Set the textual reference. | 233 | * Set the textual reference. |
234 | * | 234 | * |
235 | - * @param reference the reference to set. | 235 | + * @param reference the reference to set |
236 | */ | 236 | */ |
237 | @Override | 237 | @Override |
238 | public void setReference(String reference) { | 238 | public void setReference(String reference) { |
... | @@ -242,7 +242,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -242,7 +242,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
242 | /** | 242 | /** |
243 | * Get the status. | 243 | * Get the status. |
244 | * | 244 | * |
245 | - * @return the status. | 245 | + * @return the status |
246 | */ | 246 | */ |
247 | @Override | 247 | @Override |
248 | public YangStatusType getStatus() { | 248 | public YangStatusType getStatus() { |
... | @@ -252,7 +252,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -252,7 +252,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
252 | /** | 252 | /** |
253 | * Set the status. | 253 | * Set the status. |
254 | * | 254 | * |
255 | - * @param status the status to set. | 255 | + * @param status the status to set |
256 | */ | 256 | */ |
257 | @Override | 257 | @Override |
258 | public void setStatus(YangStatusType status) { | 258 | public void setStatus(YangStatusType status) { |
... | @@ -262,7 +262,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -262,7 +262,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
262 | /** | 262 | /** |
263 | * Get the units. | 263 | * Get the units. |
264 | * | 264 | * |
265 | - * @return the units. | 265 | + * @return the units |
266 | */ | 266 | */ |
267 | public String getUnits() { | 267 | public String getUnits() { |
268 | return units; | 268 | return units; |
... | @@ -271,7 +271,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -271,7 +271,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
271 | /** | 271 | /** |
272 | * Set the units. | 272 | * Set the units. |
273 | * | 273 | * |
274 | - * @param units the units to set. | 274 | + * @param units the units to set |
275 | */ | 275 | */ |
276 | public void setUnits(String units) { | 276 | public void setUnits(String units) { |
277 | this.units = units; | 277 | this.units = units; |
... | @@ -280,7 +280,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -280,7 +280,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
280 | /** | 280 | /** |
281 | * Get the data type. | 281 | * Get the data type. |
282 | * | 282 | * |
283 | - * @return the data type. | 283 | + * @return the data type |
284 | */ | 284 | */ |
285 | public YangType<?> getDataType() { | 285 | public YangType<?> getDataType() { |
286 | return dataType; | 286 | return dataType; |
... | @@ -289,7 +289,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -289,7 +289,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
289 | /** | 289 | /** |
290 | * Set the data type. | 290 | * Set the data type. |
291 | * | 291 | * |
292 | - * @param dataType the data type to set. | 292 | + * @param dataType the data type to set |
293 | */ | 293 | */ |
294 | public void setDataType(YangType<?> dataType) { | 294 | public void setDataType(YangType<?> dataType) { |
295 | this.dataType = dataType; | 295 | this.dataType = dataType; |
... | @@ -298,17 +298,17 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -298,17 +298,17 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
298 | /** | 298 | /** |
299 | * Returns the type of the parsed data. | 299 | * Returns the type of the parsed data. |
300 | * | 300 | * |
301 | - * @return returns LEAF_LIST_DATA. | 301 | + * @return returns LEAF_LIST_DATA |
302 | */ | 302 | */ |
303 | @Override | 303 | @Override |
304 | - public ParsableDataType getParsableDataType() { | 304 | + public YangConstructType getYangConstructType() { |
305 | - return ParsableDataType.LEAF_LIST_DATA; | 305 | + return YangConstructType.LEAF_LIST_DATA; |
306 | } | 306 | } |
307 | 307 | ||
308 | /** | 308 | /** |
309 | * Validate the data on entering the corresponding parse tree node. | 309 | * Validate the data on entering the corresponding parse tree node. |
310 | * | 310 | * |
311 | - * @throws DataModelException a violation of data model rules. | 311 | + * @throws DataModelException a violation of data model rules |
312 | */ | 312 | */ |
313 | @Override | 313 | @Override |
314 | public void validateDataOnEntry() throws DataModelException { | 314 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -319,7 +319,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -319,7 +319,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
319 | /** | 319 | /** |
320 | * Validate the data on exiting the corresponding parse tree node. | 320 | * Validate the data on exiting the corresponding parse tree node. |
321 | * | 321 | * |
322 | - * @throws DataModelException a violation of data model rules. | 322 | + * @throws DataModelException a violation of data model rules |
323 | */ | 323 | */ |
324 | @Override | 324 | @Override |
325 | public void validateDataOnExit() throws DataModelException { | 325 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -16,13 +16,14 @@ | ... | @@ -16,13 +16,14 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.datamodel; | 17 | package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | -import java.util.LinkedList; | ||
20 | -import java.util.List; | ||
21 | - | ||
22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
20 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | ||
23 | import org.onosproject.yangutils.parser.Parsable; | 21 | import org.onosproject.yangutils.parser.Parsable; |
24 | -import org.onosproject.yangutils.parser.ParsableDataType; | ||
25 | import org.onosproject.yangutils.translator.CachedFileHandle; | 22 | import org.onosproject.yangutils.translator.CachedFileHandle; |
23 | +import org.onosproject.yangutils.utils.YangConstructType; | ||
24 | + | ||
25 | +import java.util.LinkedList; | ||
26 | +import java.util.List; | ||
26 | 27 | ||
27 | /*- | 28 | /*- |
28 | * The "list" statement is used to define an interior data node in the | 29 | * The "list" statement is used to define an interior data node in the |
... | @@ -67,10 +68,10 @@ import org.onosproject.yangutils.translator.CachedFileHandle; | ... | @@ -67,10 +68,10 @@ import org.onosproject.yangutils.translator.CachedFileHandle; |
67 | * List data represented in YANG. | 68 | * List data represented in YANG. |
68 | */ | 69 | */ |
69 | public class YangList extends YangNode | 70 | public class YangList extends YangNode |
70 | - implements YangLeavesHolder, YangCommonInfo, Parsable { | 71 | + implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector { |
71 | 72 | ||
72 | /** | 73 | /** |
73 | - * name of the YANG list. | 74 | + * Name of the YANG list. |
74 | */ | 75 | */ |
75 | private String name; | 76 | private String name; |
76 | 77 | ||
... | @@ -177,7 +178,7 @@ public class YangList extends YangNode | ... | @@ -177,7 +178,7 @@ public class YangList extends YangNode |
177 | /** | 178 | /** |
178 | * Get the YANG list name. | 179 | * Get the YANG list name. |
179 | * | 180 | * |
180 | - * @return YANG list name. | 181 | + * @return YANG list name |
181 | */ | 182 | */ |
182 | @Override | 183 | @Override |
183 | public String getName() { | 184 | public String getName() { |
... | @@ -187,7 +188,7 @@ public class YangList extends YangNode | ... | @@ -187,7 +188,7 @@ public class YangList extends YangNode |
187 | /** | 188 | /** |
188 | * Set the YANG list name. | 189 | * Set the YANG list name. |
189 | * | 190 | * |
190 | - * @param name YANG list name. | 191 | + * @param name YANG list name |
191 | */ | 192 | */ |
192 | @Override | 193 | @Override |
193 | public void setName(String name) { | 194 | public void setName(String name) { |
... | @@ -206,7 +207,7 @@ public class YangList extends YangNode | ... | @@ -206,7 +207,7 @@ public class YangList extends YangNode |
206 | /** | 207 | /** |
207 | * Set the config flag. | 208 | * Set the config flag. |
208 | * | 209 | * |
209 | - * @param isCfg the config flag. | 210 | + * @param isCfg the config flag |
210 | */ | 211 | */ |
211 | public void setConfig(boolean isCfg) { | 212 | public void setConfig(boolean isCfg) { |
212 | isConfig = isCfg; | 213 | isConfig = isCfg; |
... | @@ -215,7 +216,7 @@ public class YangList extends YangNode | ... | @@ -215,7 +216,7 @@ public class YangList extends YangNode |
215 | /** | 216 | /** |
216 | * Get the description. | 217 | * Get the description. |
217 | * | 218 | * |
218 | - * @return the description. | 219 | + * @return the description |
219 | */ | 220 | */ |
220 | @Override | 221 | @Override |
221 | public String getDescription() { | 222 | public String getDescription() { |
... | @@ -225,7 +226,7 @@ public class YangList extends YangNode | ... | @@ -225,7 +226,7 @@ public class YangList extends YangNode |
225 | /** | 226 | /** |
226 | * Set the description. | 227 | * Set the description. |
227 | * | 228 | * |
228 | - * @param description set the description. | 229 | + * @param description set the description |
229 | */ | 230 | */ |
230 | @Override | 231 | @Override |
231 | public void setDescription(String description) { | 232 | public void setDescription(String description) { |
... | @@ -235,7 +236,7 @@ public class YangList extends YangNode | ... | @@ -235,7 +236,7 @@ public class YangList extends YangNode |
235 | /** | 236 | /** |
236 | * Get the list of key field names. | 237 | * Get the list of key field names. |
237 | * | 238 | * |
238 | - * @return the list of key field names. | 239 | + * @return the list of key field names |
239 | */ | 240 | */ |
240 | public List<String> getKeyList() { | 241 | public List<String> getKeyList() { |
241 | return keyList; | 242 | return keyList; |
... | @@ -244,7 +245,7 @@ public class YangList extends YangNode | ... | @@ -244,7 +245,7 @@ public class YangList extends YangNode |
244 | /** | 245 | /** |
245 | * Set the list of key field names. | 246 | * Set the list of key field names. |
246 | * | 247 | * |
247 | - * @param keyList the list of key field names. | 248 | + * @param keyList the list of key field names |
248 | */ | 249 | */ |
249 | private void setKeyList(List<String> keyList) { | 250 | private void setKeyList(List<String> keyList) { |
250 | this.keyList = keyList; | 251 | this.keyList = keyList; |
... | @@ -254,7 +255,7 @@ public class YangList extends YangNode | ... | @@ -254,7 +255,7 @@ public class YangList extends YangNode |
254 | * Add a key field name. | 255 | * Add a key field name. |
255 | * | 256 | * |
256 | * @param key key field name. | 257 | * @param key key field name. |
257 | - * @throws DataModelException a violation of data model rules. | 258 | + * @throws DataModelException a violation of data model rules |
258 | */ | 259 | */ |
259 | public void addKey(String key) throws DataModelException { | 260 | public void addKey(String key) throws DataModelException { |
260 | if (getKeyList() == null) { | 261 | if (getKeyList() == null) { |
... | @@ -272,7 +273,7 @@ public class YangList extends YangNode | ... | @@ -272,7 +273,7 @@ public class YangList extends YangNode |
272 | /** | 273 | /** |
273 | * Get the list of leaves. | 274 | * Get the list of leaves. |
274 | * | 275 | * |
275 | - * @return the list of leaves. | 276 | + * @return the list of leaves |
276 | */ | 277 | */ |
277 | @Override | 278 | @Override |
278 | public List<YangLeaf> getListOfLeaf() { | 279 | public List<YangLeaf> getListOfLeaf() { |
... | @@ -282,7 +283,7 @@ public class YangList extends YangNode | ... | @@ -282,7 +283,7 @@ public class YangList extends YangNode |
282 | /** | 283 | /** |
283 | * Set the list of leaves. | 284 | * Set the list of leaves. |
284 | * | 285 | * |
285 | - * @param leafsList the list of leaf to set. | 286 | + * @param leafsList the list of leaf to set |
286 | */ | 287 | */ |
287 | private void setListOfLeaf(List<YangLeaf> leafsList) { | 288 | private void setListOfLeaf(List<YangLeaf> leafsList) { |
288 | listOfLeaf = leafsList; | 289 | listOfLeaf = leafsList; |
... | @@ -291,7 +292,7 @@ public class YangList extends YangNode | ... | @@ -291,7 +292,7 @@ public class YangList extends YangNode |
291 | /** | 292 | /** |
292 | * Add a leaf. | 293 | * Add a leaf. |
293 | * | 294 | * |
294 | - * @param leaf the leaf to be added. | 295 | + * @param leaf the leaf to be added |
295 | */ | 296 | */ |
296 | @Override | 297 | @Override |
297 | public void addLeaf(YangLeaf leaf) { | 298 | public void addLeaf(YangLeaf leaf) { |
... | @@ -305,7 +306,7 @@ public class YangList extends YangNode | ... | @@ -305,7 +306,7 @@ public class YangList extends YangNode |
305 | /** | 306 | /** |
306 | * Get the list of leaf-list. | 307 | * Get the list of leaf-list. |
307 | * | 308 | * |
308 | - * @return the list of leaf-list. | 309 | + * @return the list of leaf-list |
309 | */ | 310 | */ |
310 | @Override | 311 | @Override |
311 | public List<YangLeafList> getListOfLeafList() { | 312 | public List<YangLeafList> getListOfLeafList() { |
... | @@ -315,7 +316,7 @@ public class YangList extends YangNode | ... | @@ -315,7 +316,7 @@ public class YangList extends YangNode |
315 | /** | 316 | /** |
316 | * Set the list of leaf-list. | 317 | * Set the list of leaf-list. |
317 | * | 318 | * |
318 | - * @param listOfLeafList the list of leaf-list to set. | 319 | + * @param listOfLeafList the list of leaf-list to set |
319 | */ | 320 | */ |
320 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | 321 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
321 | this.listOfLeafList = listOfLeafList; | 322 | this.listOfLeafList = listOfLeafList; |
... | @@ -324,7 +325,7 @@ public class YangList extends YangNode | ... | @@ -324,7 +325,7 @@ public class YangList extends YangNode |
324 | /** | 325 | /** |
325 | * Add a leaf-list. | 326 | * Add a leaf-list. |
326 | * | 327 | * |
327 | - * @param leafList the leaf-list to be added. | 328 | + * @param leafList the leaf-list to be added |
328 | */ | 329 | */ |
329 | @Override | 330 | @Override |
330 | public void addLeafList(YangLeafList leafList) { | 331 | public void addLeafList(YangLeafList leafList) { |
... | @@ -338,7 +339,7 @@ public class YangList extends YangNode | ... | @@ -338,7 +339,7 @@ public class YangList extends YangNode |
338 | /** | 339 | /** |
339 | * Get the max elements. | 340 | * Get the max elements. |
340 | * | 341 | * |
341 | - * @return the max elements. | 342 | + * @return the max elements |
342 | */ | 343 | */ |
343 | public int getMaxElelements() { | 344 | public int getMaxElelements() { |
344 | return maxElelements; | 345 | return maxElelements; |
... | @@ -347,7 +348,7 @@ public class YangList extends YangNode | ... | @@ -347,7 +348,7 @@ public class YangList extends YangNode |
347 | /** | 348 | /** |
348 | * Set the max elements. | 349 | * Set the max elements. |
349 | * | 350 | * |
350 | - * @param maxElelements the max elements. | 351 | + * @param maxElelements the max elements |
351 | */ | 352 | */ |
352 | public void setMaxElelements(int maxElelements) { | 353 | public void setMaxElelements(int maxElelements) { |
353 | this.maxElelements = maxElelements; | 354 | this.maxElelements = maxElelements; |
... | @@ -356,7 +357,7 @@ public class YangList extends YangNode | ... | @@ -356,7 +357,7 @@ public class YangList extends YangNode |
356 | /** | 357 | /** |
357 | * Get the minimum elements. | 358 | * Get the minimum elements. |
358 | * | 359 | * |
359 | - * @return the minimum elements. | 360 | + * @return the minimum elements |
360 | */ | 361 | */ |
361 | public int getMinElements() { | 362 | public int getMinElements() { |
362 | return minElements; | 363 | return minElements; |
... | @@ -365,7 +366,7 @@ public class YangList extends YangNode | ... | @@ -365,7 +366,7 @@ public class YangList extends YangNode |
365 | /** | 366 | /** |
366 | * Set the minimum elements. | 367 | * Set the minimum elements. |
367 | * | 368 | * |
368 | - * @param minElements the minimum elements. | 369 | + * @param minElements the minimum elements |
369 | */ | 370 | */ |
370 | public void setMinElements(int minElements) { | 371 | public void setMinElements(int minElements) { |
371 | this.minElements = minElements; | 372 | this.minElements = minElements; |
... | @@ -374,7 +375,7 @@ public class YangList extends YangNode | ... | @@ -374,7 +375,7 @@ public class YangList extends YangNode |
374 | /** | 375 | /** |
375 | * Get the textual reference. | 376 | * Get the textual reference. |
376 | * | 377 | * |
377 | - * @return the reference. | 378 | + * @return the reference |
378 | */ | 379 | */ |
379 | @Override | 380 | @Override |
380 | public String getReference() { | 381 | public String getReference() { |
... | @@ -384,7 +385,7 @@ public class YangList extends YangNode | ... | @@ -384,7 +385,7 @@ public class YangList extends YangNode |
384 | /** | 385 | /** |
385 | * Set the textual reference. | 386 | * Set the textual reference. |
386 | * | 387 | * |
387 | - * @param reference the reference to set. | 388 | + * @param reference the reference to set |
388 | */ | 389 | */ |
389 | @Override | 390 | @Override |
390 | public void setReference(String reference) { | 391 | public void setReference(String reference) { |
... | @@ -394,7 +395,7 @@ public class YangList extends YangNode | ... | @@ -394,7 +395,7 @@ public class YangList extends YangNode |
394 | /** | 395 | /** |
395 | * Get the status. | 396 | * Get the status. |
396 | * | 397 | * |
397 | - * @return the status. | 398 | + * @return the status |
398 | */ | 399 | */ |
399 | @Override | 400 | @Override |
400 | public YangStatusType getStatus() { | 401 | public YangStatusType getStatus() { |
... | @@ -404,7 +405,7 @@ public class YangList extends YangNode | ... | @@ -404,7 +405,7 @@ public class YangList extends YangNode |
404 | /** | 405 | /** |
405 | * Set the status. | 406 | * Set the status. |
406 | * | 407 | * |
407 | - * @param status the status to set. | 408 | + * @param status the status to set |
408 | */ | 409 | */ |
409 | @Override | 410 | @Override |
410 | public void setStatus(YangStatusType status) { | 411 | public void setStatus(YangStatusType status) { |
... | @@ -414,17 +415,17 @@ public class YangList extends YangNode | ... | @@ -414,17 +415,17 @@ public class YangList extends YangNode |
414 | /** | 415 | /** |
415 | * Returns the type of the parsed data. | 416 | * Returns the type of the parsed data. |
416 | * | 417 | * |
417 | - * @return returns LIST_DATA. | 418 | + * @return returns LIST_DATA |
418 | */ | 419 | */ |
419 | @Override | 420 | @Override |
420 | - public ParsableDataType getParsableDataType() { | 421 | + public YangConstructType getYangConstructType() { |
421 | - return ParsableDataType.LIST_DATA; | 422 | + return YangConstructType.LIST_DATA; |
422 | } | 423 | } |
423 | 424 | ||
424 | /** | 425 | /** |
425 | * Validate the data on entering the corresponding parse tree node. | 426 | * Validate the data on entering the corresponding parse tree node. |
426 | * | 427 | * |
427 | - * @throws DataModelException a violation of data model rules. | 428 | + * @throws DataModelException a violation of data model rules |
428 | */ | 429 | */ |
429 | @Override | 430 | @Override |
430 | public void validateDataOnEntry() throws DataModelException { | 431 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -434,7 +435,7 @@ public class YangList extends YangNode | ... | @@ -434,7 +435,7 @@ public class YangList extends YangNode |
434 | /** | 435 | /** |
435 | * Validate the data on exiting the corresponding parse tree node. | 436 | * Validate the data on exiting the corresponding parse tree node. |
436 | * | 437 | * |
437 | - * @throws DataModelException a violation of data model rules. | 438 | + * @throws DataModelException a violation of data model rules |
438 | */ | 439 | */ |
439 | @Override | 440 | @Override |
440 | public void validateDataOnExit() throws DataModelException { | 441 | public void validateDataOnExit() throws DataModelException { |
... | @@ -464,8 +465,8 @@ public class YangList extends YangNode | ... | @@ -464,8 +465,8 @@ public class YangList extends YangNode |
464 | * Sets the config's value to all leaf if leaf's config statement is not | 465 | * Sets the config's value to all leaf if leaf's config statement is not |
465 | * specified. | 466 | * specified. |
466 | * | 467 | * |
467 | - * @param leaves list of leaf attributes of YANG list. | 468 | + * @param leaves list of leaf attributes of YANG list |
468 | - * @param leafLists list of leaf-list attributes of YANG list. | 469 | + * @param leafLists list of leaf-list attributes of YANG list |
469 | */ | 470 | */ |
470 | private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) { | 471 | private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) { |
471 | 472 | ||
... | @@ -497,9 +498,9 @@ public class YangList extends YangNode | ... | @@ -497,9 +498,9 @@ public class YangList extends YangNode |
497 | /** | 498 | /** |
498 | * Validates config statement of YANG list. | 499 | * Validates config statement of YANG list. |
499 | * | 500 | * |
500 | - * @param leaves list of leaf attributes of YANG list. | 501 | + * @param leaves list of leaf attributes of YANG list |
501 | - * @param leafLists list of leaf-list attributes of YANG list. | 502 | + * @param leafLists list of leaf-list attributes of YANG list |
502 | - * @throws DataModelException a violation of data model rules. | 503 | + * @throws DataModelException a violation of data model rules |
503 | */ | 504 | */ |
504 | private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException { | 505 | private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException { |
505 | 506 | ||
... | @@ -529,9 +530,9 @@ public class YangList extends YangNode | ... | @@ -529,9 +530,9 @@ public class YangList extends YangNode |
529 | /** | 530 | /** |
530 | * Validates key statement of list. | 531 | * Validates key statement of list. |
531 | * | 532 | * |
532 | - * @param leaves list of leaf attributes of list. | 533 | + * @param leaves list of leaf attributes of list |
533 | - * @param keys list of key attributes of list. | 534 | + * @param keys list of key attributes of list |
534 | - * @throws DataModelException a violation of data model rules. | 535 | + * @throws DataModelException a violation of data model rules |
535 | */ | 536 | */ |
536 | private void validateLeafKey(List<YangLeaf> leaves, List<String> keys) throws DataModelException { | 537 | private void validateLeafKey(List<YangLeaf> leaves, List<String> keys) throws DataModelException { |
537 | boolean leafFound = false; | 538 | boolean leafFound = false; |
... | @@ -574,9 +575,9 @@ public class YangList extends YangNode | ... | @@ -574,9 +575,9 @@ public class YangList extends YangNode |
574 | /** | 575 | /** |
575 | * Validates key statement of list. | 576 | * Validates key statement of list. |
576 | * | 577 | * |
577 | - * @param leafLists list of leaf-list attributes of list. | 578 | + * @param leafLists list of leaf-list attributes of list |
578 | - * @param keys list of key attributes of list. | 579 | + * @param keys list of key attributes of list |
579 | - * @throws DataModelException a violation of data model rules. | 580 | + * @throws DataModelException a violation of data model rules |
580 | */ | 581 | */ |
581 | private void validateLeafListKey(List<YangLeafList> leafLists, List<String> keys) throws DataModelException { | 582 | private void validateLeafListKey(List<YangLeafList> leafLists, List<String> keys) throws DataModelException { |
582 | boolean leafFound = false; | 583 | boolean leafFound = false; |
... | @@ -668,4 +669,18 @@ public class YangList extends YangNode | ... | @@ -668,4 +669,18 @@ public class YangList extends YangNode |
668 | // TODO Auto-generated method stub | 669 | // TODO Auto-generated method stub |
669 | 670 | ||
670 | } | 671 | } |
672 | + | ||
673 | + @Override | ||
674 | + public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { | ||
675 | + // Asks helper to detect colliding child. | ||
676 | + detectCollidingChildUtil(identifierName, dataType, this); | ||
677 | + } | ||
678 | + | ||
679 | + @Override | ||
680 | + public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { | ||
681 | + if (this.getName().equals(identifierName)) { | ||
682 | + throw new DataModelException("YANG file error: Duplicate input identifier detected, same as list \"" + | ||
683 | + this.getName() + "\""); | ||
684 | + } | ||
685 | + } | ||
671 | } | 686 | } | ... | ... |
... | @@ -15,20 +15,21 @@ | ... | @@ -15,20 +15,21 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.datamodel; | 16 | package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | -import java.io.IOException; | ||
19 | -import java.util.LinkedList; | ||
20 | -import java.util.List; | ||
21 | - | ||
22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | ||
23 | import org.onosproject.yangutils.parser.Parsable; | 20 | import org.onosproject.yangutils.parser.Parsable; |
24 | -import org.onosproject.yangutils.parser.ParsableDataType; | ||
25 | import org.onosproject.yangutils.translator.CachedFileHandle; | 21 | import org.onosproject.yangutils.translator.CachedFileHandle; |
26 | import org.onosproject.yangutils.translator.CodeGenerator; | 22 | import org.onosproject.yangutils.translator.CodeGenerator; |
27 | import org.onosproject.yangutils.translator.GeneratedFileType; | 23 | import org.onosproject.yangutils.translator.GeneratedFileType; |
28 | import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax; | 24 | import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax; |
29 | import org.onosproject.yangutils.utils.UtilConstants; | 25 | import org.onosproject.yangutils.utils.UtilConstants; |
26 | +import org.onosproject.yangutils.utils.YangConstructType; | ||
30 | import org.onosproject.yangutils.utils.io.impl.FileSystemUtil; | 27 | import org.onosproject.yangutils.utils.io.impl.FileSystemUtil; |
31 | 28 | ||
29 | +import java.io.IOException; | ||
30 | +import java.util.LinkedList; | ||
31 | +import java.util.List; | ||
32 | + | ||
32 | /*- | 33 | /*- |
33 | * Reference:RFC 6020. | 34 | * Reference:RFC 6020. |
34 | * The "module" statement defines the module's name, | 35 | * The "module" statement defines the module's name, |
... | @@ -73,7 +74,7 @@ import org.onosproject.yangutils.utils.io.impl.FileSystemUtil; | ... | @@ -73,7 +74,7 @@ import org.onosproject.yangutils.utils.io.impl.FileSystemUtil; |
73 | * Data model node to maintain information defined in YANG module. | 74 | * Data model node to maintain information defined in YANG module. |
74 | */ | 75 | */ |
75 | public class YangModule extends YangNode | 76 | public class YangModule extends YangNode |
76 | - implements YangLeavesHolder, YangDesc, YangReference, Parsable, CodeGenerator { | 77 | + implements YangLeavesHolder, YangDesc, YangReference, Parsable, CodeGenerator, CollisionDetector { |
77 | 78 | ||
78 | /** | 79 | /** |
79 | * Name of the module. | 80 | * Name of the module. |
... | @@ -588,8 +589,8 @@ public class YangModule extends YangNode | ... | @@ -588,8 +589,8 @@ public class YangModule extends YangNode |
588 | * @return returns MODULE_DATA. | 589 | * @return returns MODULE_DATA. |
589 | */ | 590 | */ |
590 | @Override | 591 | @Override |
591 | - public ParsableDataType getParsableDataType() { | 592 | + public YangConstructType getYangConstructType() { |
592 | - return ParsableDataType.MODULE_DATA; | 593 | + return YangConstructType.MODULE_DATA; |
593 | } | 594 | } |
594 | 595 | ||
595 | /** | 596 | /** |
... | @@ -697,4 +698,15 @@ public class YangModule extends YangNode | ... | @@ -697,4 +698,15 @@ public class YangModule extends YangNode |
697 | module.addToNestedReferenceResoulutionList(node); | 698 | module.addToNestedReferenceResoulutionList(node); |
698 | return; | 699 | return; |
699 | } | 700 | } |
701 | + | ||
702 | + @Override | ||
703 | + public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { | ||
704 | + // Asks helper to detect colliding child. | ||
705 | + detectCollidingChildUtil(identifierName, dataType, this); | ||
706 | + } | ||
707 | + | ||
708 | + @Override | ||
709 | + public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { | ||
710 | + // Not required as module doesn't have any parent. | ||
711 | + } | ||
700 | } | 712 | } | ... | ... |
... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | import org.onosproject.yangutils.parser.Parsable; | 19 | import org.onosproject.yangutils.parser.Parsable; |
20 | -import org.onosproject.yangutils.parser.ParsableDataType; | 20 | +import org.onosproject.yangutils.utils.YangConstructType; |
21 | 21 | ||
22 | /*- | 22 | /*- |
23 | * The "must" statement, which is optional, takes as an argument a string that | 23 | * The "must" statement, which is optional, takes as an argument a string that |
... | @@ -59,7 +59,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { | ... | @@ -59,7 +59,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { |
59 | private String description; | 59 | private String description; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | - * reference string. | 62 | + * Reference string. |
63 | */ | 63 | */ |
64 | private String reference; | 64 | private String reference; |
65 | 65 | ||
... | @@ -72,7 +72,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { | ... | @@ -72,7 +72,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { |
72 | /** | 72 | /** |
73 | * Get the constraint. | 73 | * Get the constraint. |
74 | * | 74 | * |
75 | - * @return the constraint. | 75 | + * @return the constraint |
76 | */ | 76 | */ |
77 | public String getConstratint() { | 77 | public String getConstratint() { |
78 | return constratint; | 78 | return constratint; |
... | @@ -90,7 +90,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { | ... | @@ -90,7 +90,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { |
90 | /** | 90 | /** |
91 | * Get the description. | 91 | * Get the description. |
92 | * | 92 | * |
93 | - * @return the description. | 93 | + * @return the description |
94 | */ | 94 | */ |
95 | @Override | 95 | @Override |
96 | public String getDescription() { | 96 | public String getDescription() { |
... | @@ -100,7 +100,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { | ... | @@ -100,7 +100,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { |
100 | /** | 100 | /** |
101 | * Set the description. | 101 | * Set the description. |
102 | * | 102 | * |
103 | - * @param description set the description. | 103 | + * @param description set the description |
104 | */ | 104 | */ |
105 | @Override | 105 | @Override |
106 | public void setDescription(String description) { | 106 | public void setDescription(String description) { |
... | @@ -110,7 +110,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { | ... | @@ -110,7 +110,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { |
110 | /** | 110 | /** |
111 | * Get the textual reference. | 111 | * Get the textual reference. |
112 | * | 112 | * |
113 | - * @return the reference. | 113 | + * @return the reference |
114 | */ | 114 | */ |
115 | @Override | 115 | @Override |
116 | public String getReference() { | 116 | public String getReference() { |
... | @@ -120,7 +120,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { | ... | @@ -120,7 +120,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { |
120 | /** | 120 | /** |
121 | * Set the textual reference. | 121 | * Set the textual reference. |
122 | * | 122 | * |
123 | - * @param reference the reference to set. | 123 | + * @param reference the reference to set |
124 | */ | 124 | */ |
125 | @Override | 125 | @Override |
126 | public void setReference(String reference) { | 126 | public void setReference(String reference) { |
... | @@ -133,14 +133,14 @@ public class YangMust implements YangDesc, YangReference, Parsable { | ... | @@ -133,14 +133,14 @@ public class YangMust implements YangDesc, YangReference, Parsable { |
133 | * @return returns MUST_DATA | 133 | * @return returns MUST_DATA |
134 | */ | 134 | */ |
135 | @Override | 135 | @Override |
136 | - public ParsableDataType getParsableDataType() { | 136 | + public YangConstructType getYangConstructType() { |
137 | - return ParsableDataType.MUST_DATA; | 137 | + return YangConstructType.MUST_DATA; |
138 | } | 138 | } |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * Validate the data on entering the corresponding parse tree node. | 141 | * Validate the data on entering the corresponding parse tree node. |
142 | * | 142 | * |
143 | - * @throws DataModelException a violation of data model rules. | 143 | + * @throws DataModelException a violation of data model rules |
144 | */ | 144 | */ |
145 | @Override | 145 | @Override |
146 | public void validateDataOnEntry() throws DataModelException { | 146 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -150,7 +150,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { | ... | @@ -150,7 +150,7 @@ public class YangMust implements YangDesc, YangReference, Parsable { |
150 | /** | 150 | /** |
151 | * Validate the data on exiting the corresponding parse tree node. | 151 | * Validate the data on exiting the corresponding parse tree node. |
152 | * | 152 | * |
153 | - * @throws DataModelException a violation of data model rules. | 153 | + * @throws DataModelException a violation of data model rules |
154 | */ | 154 | */ |
155 | @Override | 155 | @Override |
156 | public void validateDataOnExit() throws DataModelException { | 156 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
20 | import org.onosproject.yangutils.parser.Parsable; | 20 | import org.onosproject.yangutils.parser.Parsable; |
21 | -import org.onosproject.yangutils.parser.ParsableDataType; | 21 | +import org.onosproject.yangutils.utils.YangConstructType; |
22 | 22 | ||
23 | /* | 23 | /* |
24 | * Reference:RFC 6020. | 24 | * Reference:RFC 6020. |
... | @@ -45,7 +45,7 @@ public class YangNameSpace implements Parsable { | ... | @@ -45,7 +45,7 @@ public class YangNameSpace implements Parsable { |
45 | /** | 45 | /** |
46 | * Get the name space URI. | 46 | * Get the name space URI. |
47 | * | 47 | * |
48 | - * @return the URI. | 48 | + * @return the URI |
49 | */ | 49 | */ |
50 | public String getUri() { | 50 | public String getUri() { |
51 | return uri; | 51 | return uri; |
... | @@ -63,17 +63,17 @@ public class YangNameSpace implements Parsable { | ... | @@ -63,17 +63,17 @@ public class YangNameSpace implements Parsable { |
63 | /** | 63 | /** |
64 | * Returns the type of the parsed data. | 64 | * Returns the type of the parsed data. |
65 | * | 65 | * |
66 | - * @return returns NAMESPACE_DATA. | 66 | + * @return returns NAMESPACE_DATA |
67 | */ | 67 | */ |
68 | @Override | 68 | @Override |
69 | - public ParsableDataType getParsableDataType() { | 69 | + public YangConstructType getYangConstructType() { |
70 | - return ParsableDataType.NAMESPACE_DATA; | 70 | + return YangConstructType.NAMESPACE_DATA; |
71 | } | 71 | } |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Validate the data on entering the corresponding parse tree node. | 74 | * Validate the data on entering the corresponding parse tree node. |
75 | * | 75 | * |
76 | - * @throws DataModelException a violation of data model rules. | 76 | + * @throws DataModelException a violation of data model rules |
77 | */ | 77 | */ |
78 | @Override | 78 | @Override |
79 | public void validateDataOnEntry() throws DataModelException { | 79 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -84,7 +84,7 @@ public class YangNameSpace implements Parsable { | ... | @@ -84,7 +84,7 @@ public class YangNameSpace implements Parsable { |
84 | /** | 84 | /** |
85 | * Validate the data on exiting the corresponding parse tree node. | 85 | * Validate the data on exiting the corresponding parse tree node. |
86 | * | 86 | * |
87 | - * @throws DataModelException a violation of data model rules. | 87 | + * @throws DataModelException a violation of data model rules |
88 | */ | 88 | */ |
89 | @Override | 89 | @Override |
90 | public void validateDataOnExit() throws DataModelException { | 90 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | import org.onosproject.yangutils.parser.Parsable; | 19 | import org.onosproject.yangutils.parser.Parsable; |
20 | -import org.onosproject.yangutils.parser.ParsableDataType; | 20 | +import org.onosproject.yangutils.utils.YangConstructType; |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * Reference:RFC 6020. | 23 | * Reference:RFC 6020. |
... | @@ -86,7 +86,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable { | ... | @@ -86,7 +86,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable { |
86 | /** | 86 | /** |
87 | * Get the description. | 87 | * Get the description. |
88 | * | 88 | * |
89 | - * @return the description. | 89 | + * @return the description |
90 | */ | 90 | */ |
91 | @Override | 91 | @Override |
92 | public String getDescription() { | 92 | public String getDescription() { |
... | @@ -96,7 +96,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable { | ... | @@ -96,7 +96,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable { |
96 | /** | 96 | /** |
97 | * Set the description. | 97 | * Set the description. |
98 | * | 98 | * |
99 | - * @param description set the description. | 99 | + * @param description set the description |
100 | */ | 100 | */ |
101 | @Override | 101 | @Override |
102 | public void setDescription(String description) { | 102 | public void setDescription(String description) { |
... | @@ -106,7 +106,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable { | ... | @@ -106,7 +106,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable { |
106 | /** | 106 | /** |
107 | * Get the textual reference. | 107 | * Get the textual reference. |
108 | * | 108 | * |
109 | - * @return the reference. | 109 | + * @return the reference |
110 | */ | 110 | */ |
111 | @Override | 111 | @Override |
112 | public String getReference() { | 112 | public String getReference() { |
... | @@ -116,7 +116,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable { | ... | @@ -116,7 +116,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable { |
116 | /** | 116 | /** |
117 | * Set the textual reference. | 117 | * Set the textual reference. |
118 | * | 118 | * |
119 | - * @param reference the reference to set. | 119 | + * @param reference the reference to set |
120 | */ | 120 | */ |
121 | @Override | 121 | @Override |
122 | public void setReference(String reference) { | 122 | public void setReference(String reference) { |
... | @@ -126,17 +126,17 @@ public class YangRevision implements YangDesc, YangReference, Parsable { | ... | @@ -126,17 +126,17 @@ public class YangRevision implements YangDesc, YangReference, Parsable { |
126 | /** | 126 | /** |
127 | * Returns the type of the parsed data. | 127 | * Returns the type of the parsed data. |
128 | * | 128 | * |
129 | - * @return returns REVISION_DATA. | 129 | + * @return returns REVISION_DATA |
130 | */ | 130 | */ |
131 | @Override | 131 | @Override |
132 | - public ParsableDataType getParsableDataType() { | 132 | + public YangConstructType getYangConstructType() { |
133 | - return ParsableDataType.REVISION_DATA; | 133 | + return YangConstructType.REVISION_DATA; |
134 | } | 134 | } |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Validate the data on entering the corresponding parse tree node. | 137 | * Validate the data on entering the corresponding parse tree node. |
138 | * | 138 | * |
139 | - * @throws DataModelException a violation of data model rules. | 139 | + * @throws DataModelException a violation of data model rules |
140 | */ | 140 | */ |
141 | @Override | 141 | @Override |
142 | public void validateDataOnEntry() throws DataModelException { | 142 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -147,7 +147,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable { | ... | @@ -147,7 +147,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable { |
147 | /** | 147 | /** |
148 | * Validate the data on exiting the corresponding parse tree node. | 148 | * Validate the data on exiting the corresponding parse tree node. |
149 | * | 149 | * |
150 | - * @throws DataModelException a violation of data model rules. | 150 | + * @throws DataModelException a violation of data model rules |
151 | */ | 151 | */ |
152 | @Override | 152 | @Override |
153 | public void validateDataOnExit() throws DataModelException { | 153 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -15,13 +15,14 @@ | ... | @@ -15,13 +15,14 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.datamodel; | 16 | package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | -import java.util.LinkedList; | ||
19 | -import java.util.List; | ||
20 | - | ||
21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | ||
22 | import org.onosproject.yangutils.parser.Parsable; | 20 | import org.onosproject.yangutils.parser.Parsable; |
23 | -import org.onosproject.yangutils.parser.ParsableDataType; | ||
24 | import org.onosproject.yangutils.translator.CachedFileHandle; | 21 | import org.onosproject.yangutils.translator.CachedFileHandle; |
22 | +import org.onosproject.yangutils.utils.YangConstructType; | ||
23 | + | ||
24 | +import java.util.LinkedList; | ||
25 | +import java.util.List; | ||
25 | 26 | ||
26 | /* | 27 | /* |
27 | * Reference RFC 6020. | 28 | * Reference RFC 6020. |
... | @@ -74,7 +75,7 @@ import org.onosproject.yangutils.translator.CachedFileHandle; | ... | @@ -74,7 +75,7 @@ import org.onosproject.yangutils.translator.CachedFileHandle; |
74 | * Data model node to maintain information defined in YANG sub-module. | 75 | * Data model node to maintain information defined in YANG sub-module. |
75 | */ | 76 | */ |
76 | public class YangSubModule extends YangNode | 77 | public class YangSubModule extends YangNode |
77 | - implements YangLeavesHolder, YangDesc, YangReference, Parsable { | 78 | + implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector { |
78 | 79 | ||
79 | /** | 80 | /** |
80 | * Name of sub module. | 81 | * Name of sub module. |
... | @@ -186,7 +187,7 @@ public class YangSubModule extends YangNode | ... | @@ -186,7 +187,7 @@ public class YangSubModule extends YangNode |
186 | /** | 187 | /** |
187 | * Set the module info. | 188 | * Set the module info. |
188 | * | 189 | * |
189 | - * @param belongsTo module info to set. | 190 | + * @param belongsTo module info to set |
190 | */ | 191 | */ |
191 | public void setBelongsTo(YangBelongsTo belongsTo) { | 192 | public void setBelongsTo(YangBelongsTo belongsTo) { |
192 | this.belongsTo = belongsTo; | 193 | this.belongsTo = belongsTo; |
... | @@ -195,7 +196,7 @@ public class YangSubModule extends YangNode | ... | @@ -195,7 +196,7 @@ public class YangSubModule extends YangNode |
195 | /** | 196 | /** |
196 | * Get the contact. | 197 | * Get the contact. |
197 | * | 198 | * |
198 | - * @return the contact. | 199 | + * @return the contact |
199 | */ | 200 | */ |
200 | public String getContact() { | 201 | public String getContact() { |
201 | return contact; | 202 | return contact; |
... | @@ -213,7 +214,7 @@ public class YangSubModule extends YangNode | ... | @@ -213,7 +214,7 @@ public class YangSubModule extends YangNode |
213 | /** | 214 | /** |
214 | * Get the description. | 215 | * Get the description. |
215 | * | 216 | * |
216 | - * @return the description. | 217 | + * @return the description |
217 | */ | 218 | */ |
218 | @Override | 219 | @Override |
219 | public String getDescription() { | 220 | public String getDescription() { |
... | @@ -223,7 +224,7 @@ public class YangSubModule extends YangNode | ... | @@ -223,7 +224,7 @@ public class YangSubModule extends YangNode |
223 | /** | 224 | /** |
224 | * Set the description. | 225 | * Set the description. |
225 | * | 226 | * |
226 | - * @param description set the description. | 227 | + * @param description set the description |
227 | */ | 228 | */ |
228 | @Override | 229 | @Override |
229 | public void setDescription(String description) { | 230 | public void setDescription(String description) { |
... | @@ -233,7 +234,7 @@ public class YangSubModule extends YangNode | ... | @@ -233,7 +234,7 @@ public class YangSubModule extends YangNode |
233 | /** | 234 | /** |
234 | * Get the list of imported modules. | 235 | * Get the list of imported modules. |
235 | * | 236 | * |
236 | - * @return the list of imported modules. | 237 | + * @return the list of imported modules |
237 | */ | 238 | */ |
238 | public List<YangImport> getImportList() { | 239 | public List<YangImport> getImportList() { |
239 | return importList; | 240 | return importList; |
... | @@ -242,7 +243,7 @@ public class YangSubModule extends YangNode | ... | @@ -242,7 +243,7 @@ public class YangSubModule extends YangNode |
242 | /** | 243 | /** |
243 | * prevent setting the import list from outside. | 244 | * prevent setting the import list from outside. |
244 | * | 245 | * |
245 | - * @param importList the import list to set. | 246 | + * @param importList the import list to set |
246 | */ | 247 | */ |
247 | private void setImportList(List<YangImport> importList) { | 248 | private void setImportList(List<YangImport> importList) { |
248 | this.importList = importList; | 249 | this.importList = importList; |
... | @@ -251,7 +252,7 @@ public class YangSubModule extends YangNode | ... | @@ -251,7 +252,7 @@ public class YangSubModule extends YangNode |
251 | /** | 252 | /** |
252 | * Add the imported module information to the import list. | 253 | * Add the imported module information to the import list. |
253 | * | 254 | * |
254 | - * @param importedModule module being imported. | 255 | + * @param importedModule module being imported |
255 | */ | 256 | */ |
256 | public void addImportedInfo(YangImport importedModule) { | 257 | public void addImportedInfo(YangImport importedModule) { |
257 | 258 | ||
... | @@ -267,7 +268,7 @@ public class YangSubModule extends YangNode | ... | @@ -267,7 +268,7 @@ public class YangSubModule extends YangNode |
267 | /** | 268 | /** |
268 | * Get the list of included sub modules. | 269 | * Get the list of included sub modules. |
269 | * | 270 | * |
270 | - * @return the included list of sub modules. | 271 | + * @return the included list of sub modules |
271 | */ | 272 | */ |
272 | public List<YangInclude> getIncludeList() { | 273 | public List<YangInclude> getIncludeList() { |
273 | return includeList; | 274 | return includeList; |
... | @@ -276,7 +277,7 @@ public class YangSubModule extends YangNode | ... | @@ -276,7 +277,7 @@ public class YangSubModule extends YangNode |
276 | /** | 277 | /** |
277 | * Set the list of included sub modules. | 278 | * Set the list of included sub modules. |
278 | * | 279 | * |
279 | - * @param includeList the included list to set. | 280 | + * @param includeList the included list to set |
280 | */ | 281 | */ |
281 | private void setIncludeList(List<YangInclude> includeList) { | 282 | private void setIncludeList(List<YangInclude> includeList) { |
282 | this.includeList = includeList; | 283 | this.includeList = includeList; |
... | @@ -285,7 +286,7 @@ public class YangSubModule extends YangNode | ... | @@ -285,7 +286,7 @@ public class YangSubModule extends YangNode |
285 | /** | 286 | /** |
286 | * Add the included sub module information to the include list. | 287 | * Add the included sub module information to the include list. |
287 | * | 288 | * |
288 | - * @param includeModule submodule being included. | 289 | + * @param includeModule submodule being included |
289 | */ | 290 | */ |
290 | public void addIncludedInfo(YangInclude includeModule) { | 291 | public void addIncludedInfo(YangInclude includeModule) { |
291 | 292 | ||
... | @@ -300,7 +301,7 @@ public class YangSubModule extends YangNode | ... | @@ -300,7 +301,7 @@ public class YangSubModule extends YangNode |
300 | /** | 301 | /** |
301 | * Get the list of leaves. | 302 | * Get the list of leaves. |
302 | * | 303 | * |
303 | - * @return the list of leaves. | 304 | + * @return the list of leaves |
304 | */ | 305 | */ |
305 | @Override | 306 | @Override |
306 | public List<YangLeaf> getListOfLeaf() { | 307 | public List<YangLeaf> getListOfLeaf() { |
... | @@ -310,7 +311,7 @@ public class YangSubModule extends YangNode | ... | @@ -310,7 +311,7 @@ public class YangSubModule extends YangNode |
310 | /** | 311 | /** |
311 | * Set the list of leaves. | 312 | * Set the list of leaves. |
312 | * | 313 | * |
313 | - * @param leafsList the list of leaf to set. | 314 | + * @param leafsList the list of leaf to set |
314 | */ | 315 | */ |
315 | private void setListOfLeaf(List<YangLeaf> leafsList) { | 316 | private void setListOfLeaf(List<YangLeaf> leafsList) { |
316 | listOfLeaf = leafsList; | 317 | listOfLeaf = leafsList; |
... | @@ -319,7 +320,7 @@ public class YangSubModule extends YangNode | ... | @@ -319,7 +320,7 @@ public class YangSubModule extends YangNode |
319 | /** | 320 | /** |
320 | * Add a leaf. | 321 | * Add a leaf. |
321 | * | 322 | * |
322 | - * @param leaf the leaf to be added. | 323 | + * @param leaf the leaf to be added |
323 | */ | 324 | */ |
324 | @Override | 325 | @Override |
325 | public void addLeaf(YangLeaf leaf) { | 326 | public void addLeaf(YangLeaf leaf) { |
... | @@ -333,7 +334,7 @@ public class YangSubModule extends YangNode | ... | @@ -333,7 +334,7 @@ public class YangSubModule extends YangNode |
333 | /** | 334 | /** |
334 | * Get the list of leaf-list. | 335 | * Get the list of leaf-list. |
335 | * | 336 | * |
336 | - * @return the list of leaf-list. | 337 | + * @return the list of leaf-list |
337 | */ | 338 | */ |
338 | @Override | 339 | @Override |
339 | public List<YangLeafList> getListOfLeafList() { | 340 | public List<YangLeafList> getListOfLeafList() { |
... | @@ -343,7 +344,7 @@ public class YangSubModule extends YangNode | ... | @@ -343,7 +344,7 @@ public class YangSubModule extends YangNode |
343 | /** | 344 | /** |
344 | * Set the list of leaf-list. | 345 | * Set the list of leaf-list. |
345 | * | 346 | * |
346 | - * @param listOfLeafList the list of leaf-list to set. | 347 | + * @param listOfLeafList the list of leaf-list to set |
347 | */ | 348 | */ |
348 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | 349 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
349 | this.listOfLeafList = listOfLeafList; | 350 | this.listOfLeafList = listOfLeafList; |
... | @@ -352,7 +353,7 @@ public class YangSubModule extends YangNode | ... | @@ -352,7 +353,7 @@ public class YangSubModule extends YangNode |
352 | /** | 353 | /** |
353 | * Add a leaf-list. | 354 | * Add a leaf-list. |
354 | * | 355 | * |
355 | - * @param leafList the leaf-list to be added. | 356 | + * @param leafList the leaf-list to be added |
356 | */ | 357 | */ |
357 | @Override | 358 | @Override |
358 | public void addLeafList(YangLeafList leafList) { | 359 | public void addLeafList(YangLeafList leafList) { |
... | @@ -366,7 +367,7 @@ public class YangSubModule extends YangNode | ... | @@ -366,7 +367,7 @@ public class YangSubModule extends YangNode |
366 | /** | 367 | /** |
367 | * Get the sub-modules organization. | 368 | * Get the sub-modules organization. |
368 | * | 369 | * |
369 | - * @return the organization. | 370 | + * @return the organization |
370 | */ | 371 | */ |
371 | public String getOrganization() { | 372 | public String getOrganization() { |
372 | return organization; | 373 | return organization; |
... | @@ -375,7 +376,7 @@ public class YangSubModule extends YangNode | ... | @@ -375,7 +376,7 @@ public class YangSubModule extends YangNode |
375 | /** | 376 | /** |
376 | * Set the sub-modules organization. | 377 | * Set the sub-modules organization. |
377 | * | 378 | * |
378 | - * @param org the organization to set. | 379 | + * @param org the organization to set |
379 | */ | 380 | */ |
380 | public void setOrganization(String org) { | 381 | public void setOrganization(String org) { |
381 | organization = org; | 382 | organization = org; |
... | @@ -384,7 +385,7 @@ public class YangSubModule extends YangNode | ... | @@ -384,7 +385,7 @@ public class YangSubModule extends YangNode |
384 | /** | 385 | /** |
385 | * Get the textual reference. | 386 | * Get the textual reference. |
386 | * | 387 | * |
387 | - * @return the reference. | 388 | + * @return the reference |
388 | */ | 389 | */ |
389 | @Override | 390 | @Override |
390 | public String getReference() { | 391 | public String getReference() { |
... | @@ -394,7 +395,7 @@ public class YangSubModule extends YangNode | ... | @@ -394,7 +395,7 @@ public class YangSubModule extends YangNode |
394 | /** | 395 | /** |
395 | * Set the textual reference. | 396 | * Set the textual reference. |
396 | * | 397 | * |
397 | - * @param reference the reference to set. | 398 | + * @param reference the reference to set |
398 | */ | 399 | */ |
399 | @Override | 400 | @Override |
400 | public void setReference(String reference) { | 401 | public void setReference(String reference) { |
... | @@ -404,7 +405,7 @@ public class YangSubModule extends YangNode | ... | @@ -404,7 +405,7 @@ public class YangSubModule extends YangNode |
404 | /** | 405 | /** |
405 | * Get the revision. | 406 | * Get the revision. |
406 | * | 407 | * |
407 | - * @return the revision. | 408 | + * @return the revision |
408 | */ | 409 | */ |
409 | public YangRevision getRevision() { | 410 | public YangRevision getRevision() { |
410 | return revision; | 411 | return revision; |
... | @@ -413,7 +414,7 @@ public class YangSubModule extends YangNode | ... | @@ -413,7 +414,7 @@ public class YangSubModule extends YangNode |
413 | /** | 414 | /** |
414 | * Set the revision. | 415 | * Set the revision. |
415 | * | 416 | * |
416 | - * @param revision the revision to set. | 417 | + * @param revision the revision to set |
417 | */ | 418 | */ |
418 | public void setRevision(YangRevision revision) { | 419 | public void setRevision(YangRevision revision) { |
419 | this.revision = revision; | 420 | this.revision = revision; |
... | @@ -422,7 +423,7 @@ public class YangSubModule extends YangNode | ... | @@ -422,7 +423,7 @@ public class YangSubModule extends YangNode |
422 | /** | 423 | /** |
423 | * Get the version. | 424 | * Get the version. |
424 | * | 425 | * |
425 | - * @return the version. | 426 | + * @return the version |
426 | */ | 427 | */ |
427 | public byte getVersion() { | 428 | public byte getVersion() { |
428 | return version; | 429 | return version; |
... | @@ -431,7 +432,7 @@ public class YangSubModule extends YangNode | ... | @@ -431,7 +432,7 @@ public class YangSubModule extends YangNode |
431 | /** | 432 | /** |
432 | * Set the version. | 433 | * Set the version. |
433 | * | 434 | * |
434 | - * @param version the version to set. | 435 | + * @param version the version to set |
435 | */ | 436 | */ |
436 | public void setVersion(byte version) { | 437 | public void setVersion(byte version) { |
437 | this.version = version; | 438 | this.version = version; |
... | @@ -440,17 +441,17 @@ public class YangSubModule extends YangNode | ... | @@ -440,17 +441,17 @@ public class YangSubModule extends YangNode |
440 | /** | 441 | /** |
441 | * Returns the type of the parsed data. | 442 | * Returns the type of the parsed data. |
442 | * | 443 | * |
443 | - * @return returns SUB_MODULE_DATA. | 444 | + * @return returns SUB_MODULE_DATA |
444 | */ | 445 | */ |
445 | @Override | 446 | @Override |
446 | - public ParsableDataType getParsableDataType() { | 447 | + public YangConstructType getYangConstructType() { |
447 | - return ParsableDataType.SUB_MODULE_DATA; | 448 | + return YangConstructType.SUB_MODULE_DATA; |
448 | } | 449 | } |
449 | 450 | ||
450 | /** | 451 | /** |
451 | * Validate the data on entering the corresponding parse tree node. | 452 | * Validate the data on entering the corresponding parse tree node. |
452 | * | 453 | * |
453 | - * @throws DataModelException a violation of data model rules. | 454 | + * @throws DataModelException a violation of data model rules |
454 | */ | 455 | */ |
455 | @Override | 456 | @Override |
456 | public void validateDataOnEntry() throws DataModelException { | 457 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -460,7 +461,7 @@ public class YangSubModule extends YangNode | ... | @@ -460,7 +461,7 @@ public class YangSubModule extends YangNode |
460 | /** | 461 | /** |
461 | * Validate the data on exiting the corresponding parse tree node. | 462 | * Validate the data on exiting the corresponding parse tree node. |
462 | * | 463 | * |
463 | - * @throws DataModelException a violation of data model rules. | 464 | + * @throws DataModelException a violation of data model rules |
464 | */ | 465 | */ |
465 | @Override | 466 | @Override |
466 | public void validateDataOnExit() throws DataModelException { | 467 | public void validateDataOnExit() throws DataModelException { |
... | @@ -515,4 +516,15 @@ public class YangSubModule extends YangNode | ... | @@ -515,4 +516,15 @@ public class YangSubModule extends YangNode |
515 | // TODO Auto-generated method stub | 516 | // TODO Auto-generated method stub |
516 | 517 | ||
517 | } | 518 | } |
519 | + | ||
520 | + @Override | ||
521 | + public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { | ||
522 | + // Asks helper to detect colliding child. | ||
523 | + detectCollidingChildUtil(identifierName, dataType, this); | ||
524 | + } | ||
525 | + | ||
526 | + @Override | ||
527 | + public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { | ||
528 | + // Not required as module doesn't have any parent. | ||
529 | + } | ||
518 | } | 530 | } | ... | ... |
... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
20 | import org.onosproject.yangutils.parser.Parsable; | 20 | import org.onosproject.yangutils.parser.Parsable; |
21 | -import org.onosproject.yangutils.parser.ParsableDataType; | 21 | +import org.onosproject.yangutils.utils.YangConstructType; |
22 | 22 | ||
23 | /* | 23 | /* |
24 | * Reference:RFC 6020. | 24 | * Reference:RFC 6020. |
... | @@ -77,7 +77,7 @@ public class YangType<T> implements Parsable { | ... | @@ -77,7 +77,7 @@ public class YangType<T> implements Parsable { |
77 | /** | 77 | /** |
78 | * Get the name of data type. | 78 | * Get the name of data type. |
79 | * | 79 | * |
80 | - * @return the name of data type. | 80 | + * @return the name of data type |
81 | */ | 81 | */ |
82 | public String getDataTypeName() { | 82 | public String getDataTypeName() { |
83 | return dataTypeName; | 83 | return dataTypeName; |
... | @@ -95,7 +95,7 @@ public class YangType<T> implements Parsable { | ... | @@ -95,7 +95,7 @@ public class YangType<T> implements Parsable { |
95 | /** | 95 | /** |
96 | * Get the type of data. | 96 | * Get the type of data. |
97 | * | 97 | * |
98 | - * @return the data type. | 98 | + * @return the data type |
99 | */ | 99 | */ |
100 | public YangDataTypes getDataType() { | 100 | public YangDataTypes getDataType() { |
101 | return dataType; | 101 | return dataType; |
... | @@ -104,7 +104,7 @@ public class YangType<T> implements Parsable { | ... | @@ -104,7 +104,7 @@ public class YangType<T> implements Parsable { |
104 | /** | 104 | /** |
105 | * Set the type of data. | 105 | * Set the type of data. |
106 | * | 106 | * |
107 | - * @param dataType data type. | 107 | + * @param dataType data type |
108 | */ | 108 | */ |
109 | public void setDataType(YangDataTypes dataType) { | 109 | public void setDataType(YangDataTypes dataType) { |
110 | this.dataType = dataType; | 110 | this.dataType = dataType; |
... | @@ -113,7 +113,7 @@ public class YangType<T> implements Parsable { | ... | @@ -113,7 +113,7 @@ public class YangType<T> implements Parsable { |
113 | /** | 113 | /** |
114 | * Get the data type meta data. | 114 | * Get the data type meta data. |
115 | * | 115 | * |
116 | - * @return the data type meta data. | 116 | + * @return the data type meta data |
117 | */ | 117 | */ |
118 | public T getDataTypeExtendedInfo() { | 118 | public T getDataTypeExtendedInfo() { |
119 | return dataTypeExtendedInfo; | 119 | return dataTypeExtendedInfo; |
... | @@ -131,17 +131,17 @@ public class YangType<T> implements Parsable { | ... | @@ -131,17 +131,17 @@ public class YangType<T> implements Parsable { |
131 | /** | 131 | /** |
132 | * Returns the type of the parsed data. | 132 | * Returns the type of the parsed data. |
133 | * | 133 | * |
134 | - * @return returns TYPE_DATA. | 134 | + * @return returns TYPE_DATA |
135 | */ | 135 | */ |
136 | @Override | 136 | @Override |
137 | - public ParsableDataType getParsableDataType() { | 137 | + public YangConstructType getYangConstructType() { |
138 | - return ParsableDataType.TYPE_DATA; | 138 | + return YangConstructType.TYPE_DATA; |
139 | } | 139 | } |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * Validate the data on entering the corresponding parse tree node. | 142 | * Validate the data on entering the corresponding parse tree node. |
143 | * | 143 | * |
144 | - * @throws DataModelException a violation of data model rules. | 144 | + * @throws DataModelException a violation of data model rules |
145 | */ | 145 | */ |
146 | @Override | 146 | @Override |
147 | public void validateDataOnEntry() throws DataModelException { | 147 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -152,7 +152,7 @@ public class YangType<T> implements Parsable { | ... | @@ -152,7 +152,7 @@ public class YangType<T> implements Parsable { |
152 | /** | 152 | /** |
153 | * Validate the data on exiting the corresponding parse tree node. | 153 | * Validate the data on exiting the corresponding parse tree node. |
154 | * | 154 | * |
155 | - * @throws DataModelException a violation of data model rules. | 155 | + * @throws DataModelException a violation of data model rules |
156 | */ | 156 | */ |
157 | @Override | 157 | @Override |
158 | public void validateDataOnExit() throws DataModelException { | 158 | public void validateDataOnExit() throws DataModelException { | ... | ... |
... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | import org.onosproject.yangutils.parser.Parsable; | 19 | import org.onosproject.yangutils.parser.Parsable; |
20 | -import org.onosproject.yangutils.parser.ParsableDataType; | 20 | +import org.onosproject.yangutils.utils.YangConstructType; |
21 | import org.onosproject.yangutils.translator.CachedFileHandle; | 21 | import org.onosproject.yangutils.translator.CachedFileHandle; |
22 | 22 | ||
23 | /*- | 23 | /*- |
... | @@ -103,7 +103,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -103,7 +103,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
103 | /** | 103 | /** |
104 | * Get the default value. | 104 | * Get the default value. |
105 | * | 105 | * |
106 | - * @return the default value. | 106 | + * @return the default value |
107 | */ | 107 | */ |
108 | public String getDefaultValueInString() { | 108 | public String getDefaultValueInString() { |
109 | return defaultValueInString; | 109 | return defaultValueInString; |
... | @@ -112,7 +112,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -112,7 +112,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
112 | /** | 112 | /** |
113 | * Set the default value. | 113 | * Set the default value. |
114 | * | 114 | * |
115 | - * @param defaultValueInString the default value. | 115 | + * @param defaultValueInString the default value |
116 | */ | 116 | */ |
117 | public void setDefaultValueInString(String defaultValueInString) { | 117 | public void setDefaultValueInString(String defaultValueInString) { |
118 | this.defaultValueInString = defaultValueInString; | 118 | this.defaultValueInString = defaultValueInString; |
... | @@ -121,7 +121,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -121,7 +121,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
121 | /** | 121 | /** |
122 | * Get the description. | 122 | * Get the description. |
123 | * | 123 | * |
124 | - * @return the description. | 124 | + * @return the description |
125 | */ | 125 | */ |
126 | @Override | 126 | @Override |
127 | public String getDescription() { | 127 | public String getDescription() { |
... | @@ -131,7 +131,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -131,7 +131,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
131 | /** | 131 | /** |
132 | * Set the description. | 132 | * Set the description. |
133 | * | 133 | * |
134 | - * @param description set the description. | 134 | + * @param description set the description |
135 | */ | 135 | */ |
136 | @Override | 136 | @Override |
137 | public void setDescription(String description) { | 137 | public void setDescription(String description) { |
... | @@ -141,7 +141,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -141,7 +141,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
141 | /** | 141 | /** |
142 | * Get the textual reference. | 142 | * Get the textual reference. |
143 | * | 143 | * |
144 | - * @return the reference. | 144 | + * @return the reference |
145 | */ | 145 | */ |
146 | @Override | 146 | @Override |
147 | public String getReference() { | 147 | public String getReference() { |
... | @@ -151,7 +151,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -151,7 +151,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
151 | /** | 151 | /** |
152 | * Set the textual reference. | 152 | * Set the textual reference. |
153 | * | 153 | * |
154 | - * @param reference the reference to set. | 154 | + * @param reference the reference to set |
155 | */ | 155 | */ |
156 | @Override | 156 | @Override |
157 | public void setReference(String reference) { | 157 | public void setReference(String reference) { |
... | @@ -161,7 +161,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -161,7 +161,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
161 | /** | 161 | /** |
162 | * Get the status. | 162 | * Get the status. |
163 | * | 163 | * |
164 | - * @return the status. | 164 | + * @return the status |
165 | */ | 165 | */ |
166 | @Override | 166 | @Override |
167 | public YangStatusType getStatus() { | 167 | public YangStatusType getStatus() { |
... | @@ -171,7 +171,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -171,7 +171,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
171 | /** | 171 | /** |
172 | * Set the status. | 172 | * Set the status. |
173 | * | 173 | * |
174 | - * @param status the status to set. | 174 | + * @param status the status to set |
175 | */ | 175 | */ |
176 | @Override | 176 | @Override |
177 | public void setStatus(YangStatusType status) { | 177 | public void setStatus(YangStatusType status) { |
... | @@ -181,7 +181,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -181,7 +181,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
181 | /** | 181 | /** |
182 | * Get the derived type. | 182 | * Get the derived type. |
183 | * | 183 | * |
184 | - * @return the derived type. | 184 | + * @return the derived type |
185 | */ | 185 | */ |
186 | public YangType<YangDerivedType> getDerivedType() { | 186 | public YangType<YangDerivedType> getDerivedType() { |
187 | return derivedType; | 187 | return derivedType; |
... | @@ -190,7 +190,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -190,7 +190,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
190 | /** | 190 | /** |
191 | * Set the derived type. | 191 | * Set the derived type. |
192 | * | 192 | * |
193 | - * @param derivedType the derived type. | 193 | + * @param derivedType the derived type |
194 | */ | 194 | */ |
195 | public void setDerivedType(YangType<YangDerivedType> derivedType) { | 195 | public void setDerivedType(YangType<YangDerivedType> derivedType) { |
196 | this.derivedType = derivedType; | 196 | this.derivedType = derivedType; |
... | @@ -220,14 +220,14 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -220,14 +220,14 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
220 | * @return returns TYPEDEF_DATA | 220 | * @return returns TYPEDEF_DATA |
221 | */ | 221 | */ |
222 | @Override | 222 | @Override |
223 | - public ParsableDataType getParsableDataType() { | 223 | + public YangConstructType getYangConstructType() { |
224 | - return ParsableDataType.TYPEDEF_DATA; | 224 | + return YangConstructType.TYPEDEF_DATA; |
225 | } | 225 | } |
226 | 226 | ||
227 | /** | 227 | /** |
228 | * Validate the data on entering the corresponding parse tree node. | 228 | * Validate the data on entering the corresponding parse tree node. |
229 | * | 229 | * |
230 | - * @throws DataModelException a violation of data model rules. | 230 | + * @throws DataModelException a violation of data model rules |
231 | */ | 231 | */ |
232 | @Override | 232 | @Override |
233 | public void validateDataOnEntry() throws DataModelException { | 233 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -237,7 +237,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -237,7 +237,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
237 | /** | 237 | /** |
238 | * Validate the data on exiting the corresponding parse tree node. | 238 | * Validate the data on exiting the corresponding parse tree node. |
239 | * | 239 | * |
240 | - * @throws DataModelException a violation of data model rules. | 240 | + * @throws DataModelException a violation of data model rules |
241 | */ | 241 | */ |
242 | @Override | 242 | @Override |
243 | public void validateDataOnExit() throws DataModelException { | 243 | public void validateDataOnExit() throws DataModelException { |
... | @@ -274,7 +274,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -274,7 +274,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
274 | /** | 274 | /** |
275 | * Get the YANG name of the typedef. | 275 | * Get the YANG name of the typedef. |
276 | * | 276 | * |
277 | - * @return YANG name of the typedef. | 277 | + * @return YANG name of the typedef |
278 | */ | 278 | */ |
279 | @Override | 279 | @Override |
280 | public String getName() { | 280 | public String getName() { |
... | @@ -287,7 +287,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -287,7 +287,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
287 | /** | 287 | /** |
288 | * Set YANG name of the typedef. | 288 | * Set YANG name of the typedef. |
289 | * | 289 | * |
290 | - * @param name YANG name of the typedef. | 290 | + * @param name YANG name of the typedef |
291 | */ | 291 | */ |
292 | @Override | 292 | @Override |
293 | public void setName(String name) { | 293 | public void setName(String name) { |
... | @@ -330,7 +330,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -330,7 +330,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
330 | /** | 330 | /** |
331 | * Set the mapped java package. | 331 | * Set the mapped java package. |
332 | * | 332 | * |
333 | - * @param pakg mapped java package. | 333 | + * @param pakg mapped java package |
334 | */ | 334 | */ |
335 | @Override | 335 | @Override |
336 | public void setPackage(String pakg) { | 336 | public void setPackage(String pakg) { |
... | @@ -341,7 +341,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -341,7 +341,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
341 | /** | 341 | /** |
342 | * Get the file handle of the cached file used during code generation. | 342 | * Get the file handle of the cached file used during code generation. |
343 | * | 343 | * |
344 | - * @return cached file handle. | 344 | + * @return cached file handle |
345 | */ | 345 | */ |
346 | @Override | 346 | @Override |
347 | public CachedFileHandle getFileHandle() { | 347 | public CachedFileHandle getFileHandle() { |
... | @@ -352,7 +352,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -352,7 +352,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
352 | /** | 352 | /** |
353 | * Set the file handle to be used used for code generation. | 353 | * Set the file handle to be used used for code generation. |
354 | * | 354 | * |
355 | - * @param fileHandle cached file handle. | 355 | + * @param fileHandle cached file handle |
356 | */ | 356 | */ |
357 | @Override | 357 | @Override |
358 | public void setFileHandle(CachedFileHandle fileHandle) { | 358 | public void setFileHandle(CachedFileHandle fileHandle) { | ... | ... |
... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | import org.onosproject.yangutils.parser.Parsable; | 19 | import org.onosproject.yangutils.parser.Parsable; |
20 | -import org.onosproject.yangutils.parser.ParsableDataType; | 20 | +import org.onosproject.yangutils.utils.YangConstructType; |
21 | import org.onosproject.yangutils.translator.CachedFileHandle; | 21 | import org.onosproject.yangutils.translator.CachedFileHandle; |
22 | 22 | ||
23 | /*- | 23 | /*- |
... | @@ -90,7 +90,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -90,7 +90,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
90 | /** | 90 | /** |
91 | * Get the name. | 91 | * Get the name. |
92 | * | 92 | * |
93 | - * @return the name. | 93 | + * @return the name |
94 | */ | 94 | */ |
95 | public String getRefGroupingName() { | 95 | public String getRefGroupingName() { |
96 | return name; | 96 | return name; |
... | @@ -108,7 +108,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -108,7 +108,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
108 | /** | 108 | /** |
109 | * Get the referred group. | 109 | * Get the referred group. |
110 | * | 110 | * |
111 | - * @return the referred group. | 111 | + * @return the referred group |
112 | */ | 112 | */ |
113 | public YangGrouping getRefGroup() { | 113 | public YangGrouping getRefGroup() { |
114 | return refGroup; | 114 | return refGroup; |
... | @@ -117,7 +117,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -117,7 +117,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
117 | /** | 117 | /** |
118 | * Set the referred group. | 118 | * Set the referred group. |
119 | * | 119 | * |
120 | - * @param refGroup the referred group. | 120 | + * @param refGroup the referred group |
121 | */ | 121 | */ |
122 | public void setRefGroup(YangGrouping refGroup) { | 122 | public void setRefGroup(YangGrouping refGroup) { |
123 | this.refGroup = refGroup; | 123 | this.refGroup = refGroup; |
... | @@ -126,7 +126,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -126,7 +126,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
126 | /** | 126 | /** |
127 | * Get the description. | 127 | * Get the description. |
128 | * | 128 | * |
129 | - * @return the description. | 129 | + * @return the description |
130 | */ | 130 | */ |
131 | @Override | 131 | @Override |
132 | public String getDescription() { | 132 | public String getDescription() { |
... | @@ -136,7 +136,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -136,7 +136,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
136 | /** | 136 | /** |
137 | * Set the description. | 137 | * Set the description. |
138 | * | 138 | * |
139 | - * @param description set the description. | 139 | + * @param description set the description |
140 | */ | 140 | */ |
141 | @Override | 141 | @Override |
142 | public void setDescription(String description) { | 142 | public void setDescription(String description) { |
... | @@ -146,7 +146,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -146,7 +146,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
146 | /** | 146 | /** |
147 | * Get the textual reference. | 147 | * Get the textual reference. |
148 | * | 148 | * |
149 | - * @return the reference. | 149 | + * @return the reference |
150 | */ | 150 | */ |
151 | @Override | 151 | @Override |
152 | public String getReference() { | 152 | public String getReference() { |
... | @@ -156,7 +156,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -156,7 +156,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
156 | /** | 156 | /** |
157 | * Set the textual reference. | 157 | * Set the textual reference. |
158 | * | 158 | * |
159 | - * @param reference the reference to set. | 159 | + * @param reference the reference to set |
160 | */ | 160 | */ |
161 | @Override | 161 | @Override |
162 | public void setReference(String reference) { | 162 | public void setReference(String reference) { |
... | @@ -166,7 +166,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -166,7 +166,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
166 | /** | 166 | /** |
167 | * Get the status. | 167 | * Get the status. |
168 | * | 168 | * |
169 | - * @return the status. | 169 | + * @return the status |
170 | */ | 170 | */ |
171 | @Override | 171 | @Override |
172 | public YangStatusType getStatus() { | 172 | public YangStatusType getStatus() { |
... | @@ -176,7 +176,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -176,7 +176,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
176 | /** | 176 | /** |
177 | * Set the status. | 177 | * Set the status. |
178 | * | 178 | * |
179 | - * @param status the status to set. | 179 | + * @param status the status to set |
180 | */ | 180 | */ |
181 | @Override | 181 | @Override |
182 | public void setStatus(YangStatusType status) { | 182 | public void setStatus(YangStatusType status) { |
... | @@ -186,17 +186,17 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -186,17 +186,17 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
186 | /** | 186 | /** |
187 | * Returns the type of the data. | 187 | * Returns the type of the data. |
188 | * | 188 | * |
189 | - * @return returns USES_DATA. | 189 | + * @return returns USES_DATA |
190 | */ | 190 | */ |
191 | @Override | 191 | @Override |
192 | - public ParsableDataType getParsableDataType() { | 192 | + public YangConstructType getYangConstructType() { |
193 | - return ParsableDataType.USES_DATA; | 193 | + return YangConstructType.USES_DATA; |
194 | } | 194 | } |
195 | 195 | ||
196 | /** | 196 | /** |
197 | * Validate the data on entering the corresponding parse tree node. | 197 | * Validate the data on entering the corresponding parse tree node. |
198 | * | 198 | * |
199 | - * @throws DataModelException a violation of data model rules. | 199 | + * @throws DataModelException a violation of data model rules |
200 | */ | 200 | */ |
201 | @Override | 201 | @Override |
202 | public void validateDataOnEntry() throws DataModelException { | 202 | public void validateDataOnEntry() throws DataModelException { |
... | @@ -206,7 +206,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -206,7 +206,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
206 | /** | 206 | /** |
207 | * Validate the data on exiting the corresponding parse tree node. | 207 | * Validate the data on exiting the corresponding parse tree node. |
208 | * | 208 | * |
209 | - * @throws DataModelException a violation of data model rules. | 209 | + * @throws DataModelException a violation of data model rules |
210 | */ | 210 | */ |
211 | @Override | 211 | @Override |
212 | public void validateDataOnExit() throws DataModelException { | 212 | public void validateDataOnExit() throws DataModelException { | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.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.datamodel.utils; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.CollisionDetector; | ||
20 | +import org.onosproject.yangutils.datamodel.YangLeaf; | ||
21 | +import org.onosproject.yangutils.datamodel.YangLeafList; | ||
22 | +import org.onosproject.yangutils.datamodel.YangLeavesHolder; | ||
23 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
24 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
25 | +import org.onosproject.yangutils.utils.YangConstructType; | ||
26 | + | ||
27 | +/** | ||
28 | + * Utilities for data model tree. | ||
29 | + */ | ||
30 | +public final class DataModelUtils { | ||
31 | + | ||
32 | + /** | ||
33 | + * Creates a new data model tree utility. | ||
34 | + */ | ||
35 | + private DataModelUtils() { | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * Detects the colliding identifier name in a given YANG node and its child. | ||
40 | + * | ||
41 | + * @param identifierName name for which collision detection is to be | ||
42 | + * checked. | ||
43 | + * @param dataType type of YANG node asking for detecting collision. | ||
44 | + * @param node instance of calling node. | ||
45 | + * @throws DataModelException a violation of data model rules. | ||
46 | + */ | ||
47 | + public static void detectCollidingChildUtil(String identifierName, YangConstructType dataType, YangNode node) | ||
48 | + throws DataModelException { | ||
49 | + if (((YangLeavesHolder) node).getListOfLeaf() != null) { | ||
50 | + for (YangLeaf leaf : ((YangLeavesHolder) node).getListOfLeaf()) { | ||
51 | + if (leaf.getLeafName().equals(identifierName)) { | ||
52 | + throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \"" | ||
53 | + + leaf.getLeafName() + "\""); | ||
54 | + } | ||
55 | + } | ||
56 | + } | ||
57 | + if (((YangLeavesHolder) node).getListOfLeafList() != null) { | ||
58 | + for (YangLeafList leafList : ((YangLeavesHolder) node).getListOfLeafList()) { | ||
59 | + if (leafList.getLeafName().equals(identifierName)) { | ||
60 | + throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " + | ||
61 | + "list \"" + leafList.getLeafName() + "\""); | ||
62 | + } | ||
63 | + } | ||
64 | + } | ||
65 | + node = node.getChild(); | ||
66 | + while ((node != null)) { | ||
67 | + if (node instanceof CollisionDetector) { | ||
68 | + ((CollisionDetector) node).detectSelfCollision(identifierName, dataType); | ||
69 | + } | ||
70 | + node = node.getNextSibling(); | ||
71 | + } | ||
72 | + } | ||
73 | +} |
utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/package-info.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 | +/** | ||
18 | + * Utilities for checking data model tree collisions. | ||
19 | + */ | ||
20 | +package org.onosproject.yangutils.datamodel.utils; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
17 | package org.onosproject.yangutils.parser; | 17 | package org.onosproject.yangutils.parser; |
18 | 18 | ||
19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
20 | +import org.onosproject.yangutils.utils.YangConstructType; | ||
20 | 21 | ||
21 | /** | 22 | /** |
22 | * Abstraction of an entity which process the data of lexer's parse tree. | 23 | * Abstraction of an entity which process the data of lexer's parse tree. |
... | @@ -24,11 +25,11 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ... | @@ -24,11 +25,11 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
24 | public interface Parsable { | 25 | public interface Parsable { |
25 | 26 | ||
26 | /** | 27 | /** |
27 | - * Get the type of parsable data. | 28 | + * Get the type of YANG construct data. |
28 | * | 29 | * |
29 | - * @return the type of parsable data | 30 | + * @return the type of YANG construct data. |
30 | */ | 31 | */ |
31 | - ParsableDataType getParsableDataType(); | 32 | + YangConstructType getYangConstructType(); |
32 | 33 | ||
33 | /** | 34 | /** |
34 | * Check if the node is valid as per YANG grammar's syntax and semantics. | 35 | * Check if the node is valid as per YANG grammar's syntax and semantics. | ... | ... |
... | @@ -29,10 +29,10 @@ public interface YangUtilsParser { | ... | @@ -29,10 +29,10 @@ public interface YangUtilsParser { |
29 | /** | 29 | /** |
30 | * It is an entry function to initiate the YANG file parsing. | 30 | * It is an entry function to initiate the YANG file parsing. |
31 | * | 31 | * |
32 | - * @param file input YANG file. | 32 | + * @param file input YANG file |
33 | - * @return YangNode root node of the data model tree. | 33 | + * @return YangNode root node of the data model tree |
34 | - * @throws ParserException when fails to get the data model. | 34 | + * @throws ParserException when fails to get the data model |
35 | - * @throws IOException when there is an exception in IO operation. | 35 | + * @throws IOException when there is an exception in IO operation |
36 | */ | 36 | */ |
37 | YangNode getDataModel(String file) throws IOException, ParserException; | 37 | YangNode getDataModel(String file) throws IOException, ParserException; |
38 | } | 38 | } | ... | ... |
... | @@ -88,7 +88,7 @@ public class TreeWalkListener implements GeneratedYangListener { | ... | @@ -88,7 +88,7 @@ public class TreeWalkListener implements GeneratedYangListener { |
88 | /** | 88 | /** |
89 | * Returns root node. | 89 | * Returns root node. |
90 | * | 90 | * |
91 | - * @return rootNode of data model tree. | 91 | + * @return rootNode of data model tree |
92 | */ | 92 | */ |
93 | public YangNode getRootNode() { | 93 | public YangNode getRootNode() { |
94 | return rootNode; | 94 | return rootNode; |
... | @@ -97,7 +97,7 @@ public class TreeWalkListener implements GeneratedYangListener { | ... | @@ -97,7 +97,7 @@ public class TreeWalkListener implements GeneratedYangListener { |
97 | /** | 97 | /** |
98 | * Set parsed data stack. | 98 | * Set parsed data stack. |
99 | * | 99 | * |
100 | - * @param parsedDataStack stack of parsable data objects. | 100 | + * @param parsedDataStack stack of parsable data objects |
101 | */ | 101 | */ |
102 | public void setParsedDataStack(Stack<Parsable> parsedDataStack) { | 102 | public void setParsedDataStack(Stack<Parsable> parsedDataStack) { |
103 | this.parsedDataStack = parsedDataStack; | 103 | this.parsedDataStack = parsedDataStack; |
... | @@ -106,7 +106,7 @@ public class TreeWalkListener implements GeneratedYangListener { | ... | @@ -106,7 +106,7 @@ public class TreeWalkListener implements GeneratedYangListener { |
106 | /** | 106 | /** |
107 | * Set root node. | 107 | * Set root node. |
108 | * | 108 | * |
109 | - * @param rootNode root node of data model tree. | 109 | + * @param rootNode root node of data model tree |
110 | */ | 110 | */ |
111 | public void setRootNode(YangNode rootNode) { | 111 | public void setRootNode(YangNode rootNode) { |
112 | this.rootNode = rootNode; | 112 | this.rootNode = rootNode; | ... | ... |
... | @@ -22,14 +22,15 @@ import org.onosproject.yangutils.datamodel.YangSubModule; | ... | @@ -22,14 +22,15 @@ import org.onosproject.yangutils.datamodel.YangSubModule; |
22 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 22 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | - | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.YANGBASE_DATA; | ||
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 25 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
30 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*; | 28 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CHILD; |
29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | ||
30 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty; |
32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
33 | +import static org.onosproject.yangutils.utils.YangConstructType.YANGBASE_DATA; | ||
33 | 34 | ||
34 | /* | 35 | /* |
35 | * Reference: RFC6020 and YANG ANTLR Grammar | 36 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -55,8 +56,8 @@ public final class BaseFileListener { | ... | @@ -55,8 +56,8 @@ public final class BaseFileListener { |
55 | * It is called when parser receives an input matching the grammar rule | 56 | * It is called when parser receives an input matching the grammar rule |
56 | * (yangfile), perform validations and update the data model tree. | 57 | * (yangfile), perform validations and update the data model tree. |
57 | * | 58 | * |
58 | - * @param listener Listener's object. | 59 | + * @param listener Listener's object |
59 | - * @param ctx context object of the grammar rule. | 60 | + * @param ctx context object of the grammar rule |
60 | */ | 61 | */ |
61 | public static void processYangFileEntry(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) { | 62 | public static void processYangFileEntry(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) { |
62 | 63 | ||
... | @@ -69,8 +70,8 @@ public final class BaseFileListener { | ... | @@ -69,8 +70,8 @@ public final class BaseFileListener { |
69 | * It is called when parser exits from grammar rule (yangfile), it perform | 70 | * It is called when parser exits from grammar rule (yangfile), it perform |
70 | * validations and update the data model tree. | 71 | * validations and update the data model tree. |
71 | * | 72 | * |
72 | - * @param listener Listener's object. | 73 | + * @param listener Listener's object |
73 | - * @param ctx context object of the grammar rule. | 74 | + * @param ctx context object of the grammar rule |
74 | */ | 75 | */ |
75 | public static void processYangFileExit(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) { | 76 | public static void processYangFileExit(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) { |
76 | 77 | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
... | @@ -22,13 +22,14 @@ import org.onosproject.yangutils.parser.Parsable; | ... | @@ -22,13 +22,14 @@ import org.onosproject.yangutils.parser.Parsable; |
22 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 22 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | - | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.BELONGS_TO_DATA; | ||
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 25 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
30 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*; | 28 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
30 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
32 | +import static org.onosproject.yangutils.utils.YangConstructType.BELONGS_TO_DATA; | ||
32 | 33 | ||
33 | /* | 34 | /* |
34 | * Reference: RFC6020 and YANG ANTLR Grammar | 35 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -70,8 +71,8 @@ public final class BelongsToListener { | ... | @@ -70,8 +71,8 @@ public final class BelongsToListener { |
70 | * It is called when parser receives an input matching the grammar rule | 71 | * It is called when parser receives an input matching the grammar rule |
71 | * (belongsto), perform validations and update the data model tree. | 72 | * (belongsto), perform validations and update the data model tree. |
72 | * | 73 | * |
73 | - * @param listener Listener's object. | 74 | + * @param listener Listener's object |
74 | - * @param ctx context object of the grammar rule. | 75 | + * @param ctx context object of the grammar rule |
75 | */ | 76 | */ |
76 | public static void processBelongsToEntry(TreeWalkListener listener, | 77 | public static void processBelongsToEntry(TreeWalkListener listener, |
77 | GeneratedYangParser.BelongstoStatementContext ctx) { | 78 | GeneratedYangParser.BelongstoStatementContext ctx) { |
... | @@ -91,8 +92,8 @@ public final class BelongsToListener { | ... | @@ -91,8 +92,8 @@ public final class BelongsToListener { |
91 | * It is called when parser exits from grammar rule (belongsto), it perform | 92 | * It is called when parser exits from grammar rule (belongsto), it perform |
92 | * validations and update the data model tree. | 93 | * validations and update the data model tree. |
93 | * | 94 | * |
94 | - * @param listener Listener's object. | 95 | + * @param listener Listener's object |
95 | - * @param ctx context object of the grammar rule. | 96 | + * @param ctx context object of the grammar rule |
96 | */ | 97 | */ |
97 | public static void processBelongsToExit(TreeWalkListener listener, | 98 | public static void processBelongsToExit(TreeWalkListener listener, |
98 | GeneratedYangParser.BelongstoStatementContext ctx) { | 99 | GeneratedYangParser.BelongstoStatementContext ctx) { |
... | @@ -110,7 +111,7 @@ public final class BelongsToListener { | ... | @@ -110,7 +111,7 @@ public final class BelongsToListener { |
110 | ctx.IDENTIFIER().getText(), EXIT); | 111 | ctx.IDENTIFIER().getText(), EXIT); |
111 | 112 | ||
112 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 113 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
113 | - switch (tmpNode.getParsableDataType()) { | 114 | + switch (tmpNode.getYangConstructType()) { |
114 | case SUB_MODULE_DATA: { | 115 | case SUB_MODULE_DATA: { |
115 | YangSubModule subModule = (YangSubModule) tmpNode; | 116 | YangSubModule subModule = (YangSubModule) tmpNode; |
116 | subModule.setBelongsTo((YangBelongsTo) tmpBelongstoNode); | 117 | subModule.setBelongsTo((YangBelongsTo) tmpBelongstoNode); | ... | ... |
... | @@ -65,7 +65,7 @@ import org.onosproject.yangutils.datamodel.YangBit; | ... | @@ -65,7 +65,7 @@ import org.onosproject.yangutils.datamodel.YangBit; |
65 | import org.onosproject.yangutils.datamodel.YangBits; | 65 | import org.onosproject.yangutils.datamodel.YangBits; |
66 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 66 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
67 | import org.onosproject.yangutils.parser.Parsable; | 67 | import org.onosproject.yangutils.parser.Parsable; |
68 | -import static org.onosproject.yangutils.parser.ParsableDataType.BIT_DATA; | 68 | +import static org.onosproject.yangutils.utils.YangConstructType.BIT_DATA; |
69 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 69 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
70 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 70 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
71 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 71 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
... | @@ -95,8 +95,8 @@ public final class BitListener { | ... | @@ -95,8 +95,8 @@ public final class BitListener { |
95 | * It is called when parser enters grammar rule (bit), it perform | 95 | * It is called when parser enters grammar rule (bit), it perform |
96 | * validations and updates the data model tree. | 96 | * validations and updates the data model tree. |
97 | * | 97 | * |
98 | - * @param listener listener's object. | 98 | + * @param listener listener's object |
99 | - * @param ctx context object of the grammar rule. | 99 | + * @param ctx context object of the grammar rule |
100 | */ | 100 | */ |
101 | public static void processBitEntry(TreeWalkListener listener, | 101 | public static void processBitEntry(TreeWalkListener listener, |
102 | GeneratedYangParser.BitStatementContext ctx) { | 102 | GeneratedYangParser.BitStatementContext ctx) { |
... | @@ -113,8 +113,8 @@ public final class BitListener { | ... | @@ -113,8 +113,8 @@ public final class BitListener { |
113 | * It is called when parser exits from grammar rule (bit), it perform | 113 | * It is called when parser exits from grammar rule (bit), it perform |
114 | * validations and update the data model tree. | 114 | * validations and update the data model tree. |
115 | * | 115 | * |
116 | - * @param listener Listener's object. | 116 | + * @param listener Listener's object |
117 | - * @param ctx context object of the grammar rule. | 117 | + * @param ctx context object of the grammar rule |
118 | */ | 118 | */ |
119 | public static void processBitExit(TreeWalkListener listener, | 119 | public static void processBitExit(TreeWalkListener listener, |
120 | GeneratedYangParser.BitStatementContext ctx) { | 120 | GeneratedYangParser.BitStatementContext ctx) { |
... | @@ -130,7 +130,7 @@ public final class BitListener { | ... | @@ -130,7 +130,7 @@ public final class BitListener { |
130 | checkStackIsNotEmpty(listener, MISSING_HOLDER, BIT_DATA, ctx.IDENTIFIER().getText(), EXIT); | 130 | checkStackIsNotEmpty(listener, MISSING_HOLDER, BIT_DATA, ctx.IDENTIFIER().getText(), EXIT); |
131 | 131 | ||
132 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 132 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
133 | - switch (tmpNode.getParsableDataType()) { | 133 | + switch (tmpNode.getYangConstructType()) { |
134 | case BITS_DATA: { | 134 | case BITS_DATA: { |
135 | YangBits yangBits = (YangBits) tmpNode; | 135 | YangBits yangBits = (YangBits) tmpNode; |
136 | if ((ctx.bitBodyStatement() == null) || (ctx.bitBodyStatement().positionStatement() == null)) { | 136 | if ((ctx.bitBodyStatement() == null) || (ctx.bitBodyStatement().positionStatement() == null)) { | ... | ... |
... | @@ -46,8 +46,8 @@ import org.onosproject.yangutils.datamodel.YangLeaf; | ... | @@ -46,8 +46,8 @@ import org.onosproject.yangutils.datamodel.YangLeaf; |
46 | import org.onosproject.yangutils.datamodel.YangLeafList; | 46 | import org.onosproject.yangutils.datamodel.YangLeafList; |
47 | import org.onosproject.yangutils.datamodel.YangType; | 47 | import org.onosproject.yangutils.datamodel.YangType; |
48 | import org.onosproject.yangutils.parser.Parsable; | 48 | import org.onosproject.yangutils.parser.Parsable; |
49 | -import static org.onosproject.yangutils.parser.ParsableDataType.BITS_DATA; | 49 | +import static org.onosproject.yangutils.utils.YangConstructType.BITS_DATA; |
50 | -import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA; | 50 | +import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA; |
51 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 51 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
52 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 52 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
53 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 53 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
... | @@ -75,8 +75,8 @@ public final class BitsListener { | ... | @@ -75,8 +75,8 @@ public final class BitsListener { |
75 | * It is called when parser enters grammar rule (bits), it perform | 75 | * It is called when parser enters grammar rule (bits), it perform |
76 | * validations and updates the data model tree. | 76 | * validations and updates the data model tree. |
77 | * | 77 | * |
78 | - * @param listener listener's object. | 78 | + * @param listener listener's object |
79 | - * @param ctx context object of the grammar rule. | 79 | + * @param ctx context object of the grammar rule |
80 | */ | 80 | */ |
81 | public static void processBitsEntry(TreeWalkListener listener, | 81 | public static void processBitsEntry(TreeWalkListener listener, |
82 | GeneratedYangParser.BitsSpecificationContext ctx) { | 82 | GeneratedYangParser.BitsSpecificationContext ctx) { |
... | @@ -93,7 +93,7 @@ public final class BitsListener { | ... | @@ -93,7 +93,7 @@ public final class BitsListener { |
93 | 93 | ||
94 | Parsable tmpData = listener.getParsedDataStack().peek(); | 94 | Parsable tmpData = listener.getParsedDataStack().peek(); |
95 | 95 | ||
96 | - switch (tmpData.getParsableDataType()) { | 96 | + switch (tmpData.getYangConstructType()) { |
97 | case LEAF_DATA: | 97 | case LEAF_DATA: |
98 | bitsNode.setBitsName(((YangLeaf) tmpData).getLeafName()); | 98 | bitsNode.setBitsName(((YangLeaf) tmpData).getLeafName()); |
99 | break; | 99 | break; |
... | @@ -116,8 +116,8 @@ public final class BitsListener { | ... | @@ -116,8 +116,8 @@ public final class BitsListener { |
116 | * It is called when parser exits from grammar rule (bits), it perform | 116 | * It is called when parser exits from grammar rule (bits), it perform |
117 | * validations and update the data model tree. | 117 | * validations and update the data model tree. |
118 | * | 118 | * |
119 | - * @param listener Listener's object. | 119 | + * @param listener Listener's object |
120 | - * @param ctx context object of the grammar rule. | 120 | + * @param ctx context object of the grammar rule |
121 | */ | 121 | */ |
122 | public static void processBitsExit(TreeWalkListener listener, | 122 | public static void processBitsExit(TreeWalkListener listener, |
123 | GeneratedYangParser.BitsSpecificationContext ctx) { | 123 | GeneratedYangParser.BitsSpecificationContext ctx) { |
... | @@ -133,7 +133,7 @@ public final class BitsListener { | ... | @@ -133,7 +133,7 @@ public final class BitsListener { |
133 | checkStackIsNotEmpty(listener, MISSING_HOLDER, BITS_DATA, "", EXIT); | 133 | checkStackIsNotEmpty(listener, MISSING_HOLDER, BITS_DATA, "", EXIT); |
134 | 134 | ||
135 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 135 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
136 | - switch (tmpNode.getParsableDataType()) { | 136 | + switch (tmpNode.getYangConstructType()) { |
137 | case TYPE_DATA: { | 137 | case TYPE_DATA: { |
138 | YangType typeNode = (YangType) tmpNode; | 138 | YangType typeNode = (YangType) tmpNode; |
139 | typeNode.setDataTypeExtendedInfo((YangBits) tmpBitsNode); | 139 | typeNode.setDataTypeExtendedInfo((YangBits) tmpBitsNode); | ... | ... |
... | @@ -24,13 +24,12 @@ import org.onosproject.yangutils.parser.Parsable; | ... | @@ -24,13 +24,12 @@ import org.onosproject.yangutils.parser.Parsable; |
24 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 24 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
25 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 25 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
26 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 26 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
27 | - | ||
28 | -import static org.onosproject.yangutils.parser.ParsableDataType.CONFIG_DATA; | ||
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
32 | +import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA; | ||
34 | 33 | ||
35 | /* | 34 | /* |
36 | * Reference: RFC6020 and YANG ANTLR Grammar | 35 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -62,8 +61,8 @@ public final class ConfigListener { | ... | @@ -62,8 +61,8 @@ public final class ConfigListener { |
62 | * It is called when parser receives an input matching the grammar rule | 61 | * It is called when parser receives an input matching the grammar rule |
63 | * (config), performs validation and updates the data model tree. | 62 | * (config), performs validation and updates the data model tree. |
64 | * | 63 | * |
65 | - * @param listener listener's object. | 64 | + * @param listener listener's object |
66 | - * @param ctx context object of the grammar rule. | 65 | + * @param ctx context object of the grammar rule |
67 | */ | 66 | */ |
68 | public static void processConfigEntry(TreeWalkListener listener, | 67 | public static void processConfigEntry(TreeWalkListener listener, |
69 | GeneratedYangParser.ConfigStatementContext ctx) { | 68 | GeneratedYangParser.ConfigStatementContext ctx) { |
... | @@ -77,7 +76,7 @@ public final class ConfigListener { | ... | @@ -77,7 +76,7 @@ public final class ConfigListener { |
77 | } | 76 | } |
78 | 77 | ||
79 | Parsable tmpData = listener.getParsedDataStack().peek(); | 78 | Parsable tmpData = listener.getParsedDataStack().peek(); |
80 | - switch (tmpData.getParsableDataType()) { | 79 | + switch (tmpData.getYangConstructType()) { |
81 | case LEAF_DATA: | 80 | case LEAF_DATA: |
82 | YangLeaf leaf = (YangLeaf) tmpData; | 81 | YangLeaf leaf = (YangLeaf) tmpData; |
83 | leaf.setConfig(isConfig); | 82 | leaf.setConfig(isConfig); | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.CONTACT_DATA; | 26 | +import static org.onosproject.yangutils.utils.YangConstructType.CONTACT_DATA; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -86,8 +86,8 @@ public final class ContactListener { | ... | @@ -86,8 +86,8 @@ public final class ContactListener { |
86 | * It is called when parser receives an input matching the grammar rule | 86 | * It is called when parser receives an input matching the grammar rule |
87 | * (contact), perform validations and update the data model tree. | 87 | * (contact), perform validations and update the data model tree. |
88 | * | 88 | * |
89 | - * @param listener Listener's object. | 89 | + * @param listener Listener's object |
90 | - * @param ctx context object of the grammar rule. | 90 | + * @param ctx context object of the grammar rule |
91 | */ | 91 | */ |
92 | public static void processContactEntry(TreeWalkListener listener, GeneratedYangParser.ContactStatementContext ctx) { | 92 | public static void processContactEntry(TreeWalkListener listener, GeneratedYangParser.ContactStatementContext ctx) { |
93 | 93 | ||
... | @@ -96,7 +96,7 @@ public final class ContactListener { | ... | @@ -96,7 +96,7 @@ public final class ContactListener { |
96 | 96 | ||
97 | // Obtain the node of the stack. | 97 | // Obtain the node of the stack. |
98 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 98 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
99 | - switch (tmpNode.getParsableDataType()) { | 99 | + switch (tmpNode.getYangConstructType()) { |
100 | case MODULE_DATA: { | 100 | case MODULE_DATA: { |
101 | YangModule module = (YangModule) tmpNode; | 101 | YangModule module = (YangModule) tmpNode; |
102 | module.setContact(ctx.string().getText()); | 102 | module.setContact(ctx.string().getText()); | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListener.java
... | @@ -22,24 +22,27 @@ import org.onosproject.yangutils.datamodel.YangModule; | ... | @@ -22,24 +22,27 @@ import org.onosproject.yangutils.datamodel.YangModule; |
22 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 23 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
24 | import org.onosproject.yangutils.parser.Parsable; | 24 | import org.onosproject.yangutils.parser.Parsable; |
25 | -import org.onosproject.yangutils.parser.ParsableDataType; | ||
26 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 25 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
27 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 26 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
28 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 27 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
29 | -import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 28 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; |
30 | -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; | ||
31 | - | ||
32 | -import static org.onosproject.yangutils.parser.ParsableDataType.CONTAINER_DATA; | ||
33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
35 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | ||
36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; |
32 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | ||
37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
34 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 35 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; | 36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; |
40 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY; | 37 | +import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; |
41 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
42 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
39 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality; | ||
40 | +import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA; | ||
41 | +import static org.onosproject.yangutils.utils.YangConstructType.CONTAINER_DATA; | ||
42 | +import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; | ||
43 | +import static org.onosproject.yangutils.utils.YangConstructType.PRESENCE_DATA; | ||
44 | +import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; | ||
45 | +import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; | ||
43 | 46 | ||
44 | /* | 47 | /* |
45 | * Reference: RFC6020 and YANG ANTLR Grammar | 48 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -76,8 +79,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati | ... | @@ -76,8 +79,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati |
76 | */ | 79 | */ |
77 | public final class ContainerListener { | 80 | public final class ContainerListener { |
78 | 81 | ||
79 | - private static ParsableDataType yangConstruct; | ||
80 | - | ||
81 | /** | 82 | /** |
82 | * Creates a new container listener. | 83 | * Creates a new container listener. |
83 | */ | 84 | */ |
... | @@ -85,30 +86,34 @@ public final class ContainerListener { | ... | @@ -85,30 +86,34 @@ public final class ContainerListener { |
85 | } | 86 | } |
86 | 87 | ||
87 | /** | 88 | /** |
88 | - * It is called when parser receives an input matching the grammar | 89 | + * It is called when parser receives an input matching the grammar rule |
89 | - * rule (container), performs validation and updates the data model | 90 | + * (container), performs validation and updates the data model tree. |
90 | - * tree. | ||
91 | * | 91 | * |
92 | - * @param listener listener's object. | 92 | + * @param listener listener's object |
93 | - * @param ctx context object of the grammar rule. | 93 | + * @param ctx context object of the grammar rule |
94 | */ | 94 | */ |
95 | public static void processContainerEntry(TreeWalkListener listener, | 95 | public static void processContainerEntry(TreeWalkListener listener, |
96 | - GeneratedYangParser.ContainerStatementContext ctx) { | 96 | + GeneratedYangParser.ContainerStatementContext ctx) { |
97 | 97 | ||
98 | - YangNode parentNode; | ||
99 | // Check for stack to be non empty. | 98 | // Check for stack to be non empty. |
100 | checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY); | 99 | checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY); |
101 | 100 | ||
102 | - boolean result = validateSubStatementsCardinality(ctx); | 101 | + // Validate sub statement cardinality. |
103 | - if (!result) { | 102 | + validateSubStatementsCardinality(ctx); |
104 | - throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY)); | 103 | + |
105 | - } | 104 | + // Check for identifier collision |
105 | + int line = ctx.IDENTIFIER().getSymbol().getLine(); | ||
106 | + int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine(); | ||
107 | + String identifierName = ctx.IDENTIFIER().getText(); | ||
108 | + detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, CONTAINER_DATA); | ||
106 | 109 | ||
107 | YangContainer container = new YangContainer(); | 110 | YangContainer container = new YangContainer(); |
108 | container.setName(ctx.IDENTIFIER().getText()); | 111 | container.setName(ctx.IDENTIFIER().getText()); |
109 | 112 | ||
110 | - /* If "config" is not specified, the default is the same as the parent | 113 | + /* |
111 | - schema node's "config" value. */ | 114 | + * If "config" is not specified, the default is the same as the parent |
115 | + * schema node's "config" value. | ||
116 | + */ | ||
112 | if (ctx.configStatement().isEmpty()) { | 117 | if (ctx.configStatement().isEmpty()) { |
113 | boolean parentConfig = ListenerValidation.getParentNodeConfig(listener); | 118 | boolean parentConfig = ListenerValidation.getParentNodeConfig(listener); |
114 | container.setConfig(parentConfig); | 119 | container.setConfig(parentConfig); |
... | @@ -122,7 +127,7 @@ public final class ContainerListener { | ... | @@ -122,7 +127,7 @@ public final class ContainerListener { |
122 | curNode.addChild(container); | 127 | curNode.addChild(container); |
123 | } catch (DataModelException e) { | 128 | } catch (DataModelException e) { |
124 | throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, | 129 | throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, |
125 | - CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY, e.getMessage())); | 130 | + CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY, e.getMessage())); |
126 | } | 131 | } |
127 | listener.getParsedDataStack().push(container); | 132 | listener.getParsedDataStack().push(container); |
128 | } else { | 133 | } else { |
... | @@ -135,11 +140,11 @@ public final class ContainerListener { | ... | @@ -135,11 +140,11 @@ public final class ContainerListener { |
135 | * It is called when parser exits from grammar rule (container), it perform | 140 | * It is called when parser exits from grammar rule (container), it perform |
136 | * validations and updates the data model tree. | 141 | * validations and updates the data model tree. |
137 | * | 142 | * |
138 | - * @param listener listener's object. | 143 | + * @param listener listener's object |
139 | - * @param ctx context object of the grammar rule. | 144 | + * @param ctx context object of the grammar rule |
140 | */ | 145 | */ |
141 | public static void processContainerExit(TreeWalkListener listener, | 146 | public static void processContainerExit(TreeWalkListener listener, |
142 | - GeneratedYangParser.ContainerStatementContext ctx) { | 147 | + GeneratedYangParser.ContainerStatementContext ctx) { |
143 | 148 | ||
144 | // Check for stack to be non empty. | 149 | // Check for stack to be non empty. |
145 | checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), EXIT); | 150 | checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), EXIT); |
... | @@ -155,48 +160,22 @@ public final class ContainerListener { | ... | @@ -155,48 +160,22 @@ public final class ContainerListener { |
155 | listener.getParsedDataStack().pop(); | 160 | listener.getParsedDataStack().pop(); |
156 | } else { | 161 | } else { |
157 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, CONTAINER_DATA, | 162 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, CONTAINER_DATA, |
158 | - ctx.IDENTIFIER().getText(), EXIT)); | 163 | + ctx.IDENTIFIER().getText(), EXIT)); |
159 | } | 164 | } |
160 | } | 165 | } |
161 | 166 | ||
162 | /** | 167 | /** |
163 | * Validates the cardinality of container sub-statements as per grammar. | 168 | * Validates the cardinality of container sub-statements as per grammar. |
164 | * | 169 | * |
165 | - * @param ctx context object of the grammar rule. | 170 | + * @param ctx context object of the grammar rule |
166 | - * @return true/false validation success or failure. | ||
167 | */ | 171 | */ |
168 | - private static boolean validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) { | 172 | + private static void validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) { |
169 | - | 173 | + |
170 | - if ((!ctx.presenceStatement().isEmpty()) | 174 | + validateCardinality(ctx.presenceStatement(), PRESENCE_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText()); |
171 | - && (ctx.presenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | 175 | + validateCardinality(ctx.configStatement(), CONFIG_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText()); |
172 | - yangConstruct = ParsableDataType.PRESENCE_DATA; | 176 | + validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText()); |
173 | - return false; | 177 | + validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText()); |
174 | - } | 178 | + validateCardinality(ctx.statusStatement(), STATUS_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText()); |
175 | - | 179 | + // TODO when, grouping, typedef. |
176 | - if ((!ctx.configStatement().isEmpty()) | ||
177 | - && (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
178 | - yangConstruct = ParsableDataType.CONFIG_DATA; | ||
179 | - return false; | ||
180 | - } | ||
181 | - | ||
182 | - if ((!ctx.descriptionStatement().isEmpty()) | ||
183 | - && (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
184 | - yangConstruct = ParsableDataType.DESCRIPTION_DATA; | ||
185 | - return false; | ||
186 | - } | ||
187 | - | ||
188 | - if ((!ctx.referenceStatement().isEmpty()) | ||
189 | - && (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
190 | - yangConstruct = ParsableDataType.REFERENCE_DATA; | ||
191 | - return false; | ||
192 | - } | ||
193 | - | ||
194 | - if ((!ctx.statusStatement().isEmpty()) | ||
195 | - && (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
196 | - yangConstruct = ParsableDataType.STATUS_DATA; | ||
197 | - return false; | ||
198 | - } | ||
199 | - | ||
200 | - return true; | ||
201 | } | 180 | } |
202 | } | 181 | } | ... | ... |
... | @@ -45,7 +45,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -45,7 +45,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
45 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 45 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
46 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 46 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
47 | 47 | ||
48 | -import static org.onosproject.yangutils.parser.ParsableDataType.DEFAULT_DATA; | 48 | +import static org.onosproject.yangutils.utils.YangConstructType.DEFAULT_DATA; |
49 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 49 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
50 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 50 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
51 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 51 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
... | @@ -64,8 +64,8 @@ public final class DefaultListener { | ... | @@ -64,8 +64,8 @@ public final class DefaultListener { |
64 | * It is called when parser enters grammar rule (default), it perform | 64 | * It is called when parser enters grammar rule (default), it perform |
65 | * validations and updates the data model tree. | 65 | * validations and updates the data model tree. |
66 | * | 66 | * |
67 | - * @param listener listener's object. | 67 | + * @param listener listener's object |
68 | - * @param ctx context object of the grammar rule. | 68 | + * @param ctx context object of the grammar rule |
69 | */ | 69 | */ |
70 | public static void processDefaultEntry(TreeWalkListener listener, | 70 | public static void processDefaultEntry(TreeWalkListener listener, |
71 | GeneratedYangParser.DefaultStatementContext ctx) { | 71 | GeneratedYangParser.DefaultStatementContext ctx) { |
... | @@ -74,7 +74,7 @@ public final class DefaultListener { | ... | @@ -74,7 +74,7 @@ public final class DefaultListener { |
74 | checkStackIsNotEmpty(listener, MISSING_HOLDER, DEFAULT_DATA, ctx.string().getText(), ENTRY); | 74 | checkStackIsNotEmpty(listener, MISSING_HOLDER, DEFAULT_DATA, ctx.string().getText(), ENTRY); |
75 | 75 | ||
76 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 76 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
77 | - switch (tmpNode.getParsableDataType()) { | 77 | + switch (tmpNode.getYangConstructType()) { |
78 | case TYPEDEF_DATA: { | 78 | case TYPEDEF_DATA: { |
79 | YangTypeDef typeDef = (YangTypeDef) tmpNode; | 79 | YangTypeDef typeDef = (YangTypeDef) tmpNode; |
80 | typeDef.setDefaultValueInString(ctx.string().getText()); | 80 | typeDef.setDefaultValueInString(ctx.string().getText()); | ... | ... |
... | @@ -22,7 +22,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -22,7 +22,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
22 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 22 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
23 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 23 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
24 | 24 | ||
25 | -import static org.onosproject.yangutils.parser.ParsableDataType.DESCRIPTION_DATA; | 25 | +import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; |
26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -56,8 +56,8 @@ public final class DescriptionListener { | ... | @@ -56,8 +56,8 @@ public final class DescriptionListener { |
56 | * rule (description), perform validations and updates the data model | 56 | * rule (description), perform validations and updates the data model |
57 | * tree. | 57 | * tree. |
58 | * | 58 | * |
59 | - * @param listener listener's object. | 59 | + * @param listener listener's object |
60 | - * @param ctx context object of the grammar rule. | 60 | + * @param ctx context object of the grammar rule |
61 | */ | 61 | */ |
62 | public static void processDescriptionEntry(TreeWalkListener listener, | 62 | public static void processDescriptionEntry(TreeWalkListener listener, |
63 | GeneratedYangParser.DescriptionStatementContext ctx) { | 63 | GeneratedYangParser.DescriptionStatementContext ctx) { | ... | ... |
... | @@ -64,7 +64,7 @@ import org.onosproject.yangutils.datamodel.YangEnum; | ... | @@ -64,7 +64,7 @@ import org.onosproject.yangutils.datamodel.YangEnum; |
64 | import org.onosproject.yangutils.datamodel.YangEnumeration; | 64 | import org.onosproject.yangutils.datamodel.YangEnumeration; |
65 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 65 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
66 | import org.onosproject.yangutils.parser.Parsable; | 66 | import org.onosproject.yangutils.parser.Parsable; |
67 | -import static org.onosproject.yangutils.parser.ParsableDataType.ENUM_DATA; | 67 | +import static org.onosproject.yangutils.utils.YangConstructType.ENUM_DATA; |
68 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 68 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
69 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 69 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
70 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 70 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
... | @@ -94,8 +94,8 @@ public final class EnumListener { | ... | @@ -94,8 +94,8 @@ public final class EnumListener { |
94 | * It is called when parser enters grammar rule (enum), it perform | 94 | * It is called when parser enters grammar rule (enum), it perform |
95 | * validations and updates the data model tree. | 95 | * validations and updates the data model tree. |
96 | * | 96 | * |
97 | - * @param listener listener's object. | 97 | + * @param listener listener's object |
98 | - * @param ctx context object of the grammar rule. | 98 | + * @param ctx context object of the grammar rule |
99 | */ | 99 | */ |
100 | public static void processEnumEntry(TreeWalkListener listener, GeneratedYangParser.EnumStatementContext ctx) { | 100 | public static void processEnumEntry(TreeWalkListener listener, GeneratedYangParser.EnumStatementContext ctx) { |
101 | 101 | ||
... | @@ -111,8 +111,8 @@ public final class EnumListener { | ... | @@ -111,8 +111,8 @@ public final class EnumListener { |
111 | * It is called when parser exits from grammar rule (enum), it perform | 111 | * It is called when parser exits from grammar rule (enum), it perform |
112 | * validations and update the data model tree. | 112 | * validations and update the data model tree. |
113 | * | 113 | * |
114 | - * @param listener Listener's object. | 114 | + * @param listener Listener's object |
115 | - * @param ctx context object of the grammar rule. | 115 | + * @param ctx context object of the grammar rule |
116 | */ | 116 | */ |
117 | public static void processEnumExit(TreeWalkListener listener, GeneratedYangParser.EnumStatementContext ctx) { | 117 | public static void processEnumExit(TreeWalkListener listener, GeneratedYangParser.EnumStatementContext ctx) { |
118 | 118 | ||
... | @@ -127,7 +127,7 @@ public final class EnumListener { | ... | @@ -127,7 +127,7 @@ public final class EnumListener { |
127 | checkStackIsNotEmpty(listener, MISSING_HOLDER, ENUM_DATA, ctx.string().getText(), EXIT); | 127 | checkStackIsNotEmpty(listener, MISSING_HOLDER, ENUM_DATA, ctx.string().getText(), EXIT); |
128 | 128 | ||
129 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 129 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
130 | - switch (tmpNode.getParsableDataType()) { | 130 | + switch (tmpNode.getYangConstructType()) { |
131 | case ENUMERATION_DATA: { | 131 | case ENUMERATION_DATA: { |
132 | YangEnumeration yangEnumeration = (YangEnumeration) tmpNode; | 132 | YangEnumeration yangEnumeration = (YangEnumeration) tmpNode; |
133 | if ((ctx.enumStatementBody() == null) || (ctx.enumStatementBody().valueStatement() == null)) { | 133 | if ((ctx.enumStatementBody() == null) || (ctx.enumStatementBody().valueStatement() == null)) { | ... | ... |
... | @@ -46,8 +46,8 @@ import org.onosproject.yangutils.datamodel.YangLeaf; | ... | @@ -46,8 +46,8 @@ import org.onosproject.yangutils.datamodel.YangLeaf; |
46 | import org.onosproject.yangutils.datamodel.YangLeafList; | 46 | import org.onosproject.yangutils.datamodel.YangLeafList; |
47 | import org.onosproject.yangutils.datamodel.YangType; | 47 | import org.onosproject.yangutils.datamodel.YangType; |
48 | import org.onosproject.yangutils.parser.Parsable; | 48 | import org.onosproject.yangutils.parser.Parsable; |
49 | -import static org.onosproject.yangutils.parser.ParsableDataType.ENUMERATION_DATA; | 49 | +import static org.onosproject.yangutils.utils.YangConstructType.ENUMERATION_DATA; |
50 | -import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA; | 50 | +import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA; |
51 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 51 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
52 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 52 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
53 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 53 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
... | @@ -76,8 +76,8 @@ public final class EnumerationListener { | ... | @@ -76,8 +76,8 @@ public final class EnumerationListener { |
76 | * It is called when parser enters grammar rule (enumeration), it perform | 76 | * It is called when parser enters grammar rule (enumeration), it perform |
77 | * validations and updates the data model tree. | 77 | * validations and updates the data model tree. |
78 | * | 78 | * |
79 | - * @param listener listener's object. | 79 | + * @param listener listener's object |
80 | - * @param ctx context object of the grammar rule. | 80 | + * @param ctx context object of the grammar rule |
81 | */ | 81 | */ |
82 | public static void processEnumerationEntry(TreeWalkListener listener, | 82 | public static void processEnumerationEntry(TreeWalkListener listener, |
83 | GeneratedYangParser.EnumSpecificationContext ctx) { | 83 | GeneratedYangParser.EnumSpecificationContext ctx) { |
... | @@ -94,7 +94,7 @@ public final class EnumerationListener { | ... | @@ -94,7 +94,7 @@ public final class EnumerationListener { |
94 | 94 | ||
95 | Parsable tmpData = listener.getParsedDataStack().peek(); | 95 | Parsable tmpData = listener.getParsedDataStack().peek(); |
96 | 96 | ||
97 | - switch (tmpData.getParsableDataType()) { | 97 | + switch (tmpData.getYangConstructType()) { |
98 | case LEAF_DATA: | 98 | case LEAF_DATA: |
99 | enumerationNode.setEnumerationName(((YangLeaf) tmpData).getLeafName()); | 99 | enumerationNode.setEnumerationName(((YangLeaf) tmpData).getLeafName()); |
100 | break; | 100 | break; |
... | @@ -117,8 +117,8 @@ public final class EnumerationListener { | ... | @@ -117,8 +117,8 @@ public final class EnumerationListener { |
117 | * It is called when parser exits from grammar rule (enumeration), it | 117 | * It is called when parser exits from grammar rule (enumeration), it |
118 | * perform validations and update the data model tree. | 118 | * perform validations and update the data model tree. |
119 | * | 119 | * |
120 | - * @param listener Listener's object. | 120 | + * @param listener Listener's object |
121 | - * @param ctx context object of the grammar rule. | 121 | + * @param ctx context object of the grammar rule |
122 | */ | 122 | */ |
123 | public static void processEnumerationExit(TreeWalkListener listener, | 123 | public static void processEnumerationExit(TreeWalkListener listener, |
124 | GeneratedYangParser.EnumSpecificationContext ctx) { | 124 | GeneratedYangParser.EnumSpecificationContext ctx) { |
... | @@ -134,7 +134,7 @@ public final class EnumerationListener { | ... | @@ -134,7 +134,7 @@ public final class EnumerationListener { |
134 | checkStackIsNotEmpty(listener, MISSING_HOLDER, ENUMERATION_DATA, "", EXIT); | 134 | checkStackIsNotEmpty(listener, MISSING_HOLDER, ENUMERATION_DATA, "", EXIT); |
135 | 135 | ||
136 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 136 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
137 | - switch (tmpNode.getParsableDataType()) { | 137 | + switch (tmpNode.getYangConstructType()) { |
138 | case TYPE_DATA: { | 138 | case TYPE_DATA: { |
139 | YangType typeNode = (YangType) tmpNode; | 139 | YangType typeNode = (YangType) tmpNode; |
140 | typeNode.setDataTypeExtendedInfo((YangEnumeration) tmpEnumerationNode); | 140 | typeNode.setDataTypeExtendedInfo((YangEnumeration) tmpEnumerationNode); | ... | ... |
... | @@ -23,13 +23,14 @@ import org.onosproject.yangutils.parser.Parsable; | ... | @@ -23,13 +23,14 @@ import org.onosproject.yangutils.parser.Parsable; |
23 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 23 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
24 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 24 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
26 | - | ||
27 | -import static org.onosproject.yangutils.parser.ParsableDataType.IMPORT_DATA; | ||
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
31 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*; | 29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
30 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
31 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
33 | +import static org.onosproject.yangutils.utils.YangConstructType.IMPORT_DATA; | ||
33 | 34 | ||
34 | /* | 35 | /* |
35 | * Reference: RFC6020 and YANG ANTLR Grammar | 36 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -69,8 +70,8 @@ public final class ImportListener { | ... | @@ -69,8 +70,8 @@ public final class ImportListener { |
69 | * It is called when parser receives an input matching the grammar rule | 70 | * It is called when parser receives an input matching the grammar rule |
70 | * (import), perform validations and update the data model tree. | 71 | * (import), perform validations and update the data model tree. |
71 | * | 72 | * |
72 | - * @param listener Listener's object. | 73 | + * @param listener Listener's object |
73 | - * @param ctx context object of the grammar rule. | 74 | + * @param ctx context object of the grammar rule |
74 | */ | 75 | */ |
75 | public static void processImportEntry(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) { | 76 | public static void processImportEntry(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) { |
76 | 77 | ||
... | @@ -88,8 +89,8 @@ public final class ImportListener { | ... | @@ -88,8 +89,8 @@ public final class ImportListener { |
88 | * It is called when parser exits from grammar rule (import), it perform | 89 | * It is called when parser exits from grammar rule (import), it perform |
89 | * validations and update the data model tree. | 90 | * validations and update the data model tree. |
90 | * | 91 | * |
91 | - * @param listener Listener's object. | 92 | + * @param listener Listener's object |
92 | - * @param ctx context object of the grammar rule. | 93 | + * @param ctx context object of the grammar rule |
93 | */ | 94 | */ |
94 | public static void processImportExit(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) { | 95 | public static void processImportExit(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) { |
95 | 96 | ||
... | @@ -105,7 +106,7 @@ public final class ImportListener { | ... | @@ -105,7 +106,7 @@ public final class ImportListener { |
105 | EXIT); | 106 | EXIT); |
106 | 107 | ||
107 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 108 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
108 | - switch (tmpNode.getParsableDataType()) { | 109 | + switch (tmpNode.getYangConstructType()) { |
109 | case MODULE_DATA: { | 110 | case MODULE_DATA: { |
110 | YangModule module = (YangModule) tmpNode; | 111 | YangModule module = (YangModule) tmpNode; |
111 | module.addImportedInfo((YangImport) tmpImportNode); | 112 | module.addImportedInfo((YangImport) tmpImportNode); | ... | ... |
... | @@ -23,13 +23,14 @@ import org.onosproject.yangutils.parser.Parsable; | ... | @@ -23,13 +23,14 @@ import org.onosproject.yangutils.parser.Parsable; |
23 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 23 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
24 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 24 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
26 | - | ||
27 | -import static org.onosproject.yangutils.parser.ParsableDataType.INCLUDE_DATA; | ||
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
31 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*; | 29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
30 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
31 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
33 | +import static org.onosproject.yangutils.utils.YangConstructType.INCLUDE_DATA; | ||
33 | 34 | ||
34 | /* | 35 | /* |
35 | * Reference: RFC6020 and YANG ANTLR Grammar | 36 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -68,8 +69,8 @@ public final class IncludeListener { | ... | @@ -68,8 +69,8 @@ public final class IncludeListener { |
68 | * It is called when parser receives an input matching the grammar rule | 69 | * It is called when parser receives an input matching the grammar rule |
69 | * (include), perform validations and update the data model tree. | 70 | * (include), perform validations and update the data model tree. |
70 | * | 71 | * |
71 | - * @param listener Listener's object. | 72 | + * @param listener Listener's object |
72 | - * @param ctx context object of the grammar rule. | 73 | + * @param ctx context object of the grammar rule |
73 | */ | 74 | */ |
74 | public static void processIncludeEntry(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) { | 75 | public static void processIncludeEntry(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) { |
75 | 76 | ||
... | @@ -87,8 +88,8 @@ public final class IncludeListener { | ... | @@ -87,8 +88,8 @@ public final class IncludeListener { |
87 | * It is called when parser exits from grammar rule (include), it perform | 88 | * It is called when parser exits from grammar rule (include), it perform |
88 | * validations and update the data model tree. | 89 | * validations and update the data model tree. |
89 | * | 90 | * |
90 | - * @param listener Listener's object. | 91 | + * @param listener Listener's object |
91 | - * @param ctx context object of the grammar rule. | 92 | + * @param ctx context object of the grammar rule |
92 | */ | 93 | */ |
93 | public static void processIncludeExit(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) { | 94 | public static void processIncludeExit(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) { |
94 | 95 | ||
... | @@ -104,7 +105,7 @@ public final class IncludeListener { | ... | @@ -104,7 +105,7 @@ public final class IncludeListener { |
104 | EXIT); | 105 | EXIT); |
105 | 106 | ||
106 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 107 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
107 | - switch (tmpNode.getParsableDataType()) { | 108 | + switch (tmpNode.getYangConstructType()) { |
108 | case MODULE_DATA: { | 109 | case MODULE_DATA: { |
109 | YangModule module = (YangModule) tmpNode; | 110 | YangModule module = (YangModule) tmpNode; |
110 | module.addIncludedInfo((YangInclude) tmpIncludeNode); | 111 | module.addIncludedInfo((YangInclude) tmpIncludeNode); | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.KEY_DATA; | 26 | +import static org.onosproject.yangutils.utils.YangConstructType.KEY_DATA; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; |
... | @@ -59,8 +59,8 @@ public final class KeyListener { | ... | @@ -59,8 +59,8 @@ public final class KeyListener { |
59 | * rule (key), perform validations and updates the data model | 59 | * rule (key), perform validations and updates the data model |
60 | * tree. | 60 | * tree. |
61 | * | 61 | * |
62 | - * @param listener listener's object. | 62 | + * @param listener listener's object |
63 | - * @param ctx context object of the grammar rule. | 63 | + * @param ctx context object of the grammar rule |
64 | */ | 64 | */ |
65 | public static void processKeyEntry(TreeWalkListener listener, | 65 | public static void processKeyEntry(TreeWalkListener listener, |
66 | GeneratedYangParser.KeyStatementContext ctx) { | 66 | GeneratedYangParser.KeyStatementContext ctx) { | ... | ... |
... | @@ -19,21 +19,28 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -19,21 +19,28 @@ package org.onosproject.yangutils.parser.impl.listeners; |
19 | import org.onosproject.yangutils.datamodel.YangLeafList; | 19 | import org.onosproject.yangutils.datamodel.YangLeafList; |
20 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; | 20 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
21 | import org.onosproject.yangutils.parser.Parsable; | 21 | import org.onosproject.yangutils.parser.Parsable; |
22 | -import org.onosproject.yangutils.parser.ParsableDataType; | ||
23 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 22 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
24 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
26 | -import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 25 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; |
27 | - | ||
28 | -import static org.onosproject.yangutils.parser.ParsableDataType.LEAF_LIST_DATA; | ||
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
33 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
34 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY; | ||
35 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
31 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
33 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality; | ||
34 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne; | ||
35 | +import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA; | ||
36 | +import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; | ||
37 | +import static org.onosproject.yangutils.utils.YangConstructType.LEAF_LIST_DATA; | ||
38 | +import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA; | ||
39 | +import static org.onosproject.yangutils.utils.YangConstructType.MIN_ELEMENT_DATA; | ||
40 | +import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; | ||
41 | +import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; | ||
42 | +import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA; | ||
43 | +import static org.onosproject.yangutils.utils.YangConstructType.UNITS_DATA; | ||
37 | 44 | ||
38 | /* | 45 | /* |
39 | * Reference: RFC6020 and YANG ANTLR Grammar | 46 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -68,8 +75,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati | ... | @@ -68,8 +75,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati |
68 | */ | 75 | */ |
69 | public final class LeafListListener { | 76 | public final class LeafListListener { |
70 | 77 | ||
71 | - private static ParsableDataType yangConstruct; | ||
72 | - | ||
73 | /** | 78 | /** |
74 | * Creates a new leaf list listener. | 79 | * Creates a new leaf list listener. |
75 | */ | 80 | */ |
... | @@ -77,23 +82,26 @@ public final class LeafListListener { | ... | @@ -77,23 +82,26 @@ public final class LeafListListener { |
77 | } | 82 | } |
78 | 83 | ||
79 | /** | 84 | /** |
80 | - * It is called when parser receives an input matching the grammar | 85 | + * It is called when parser receives an input matching the grammar rule |
81 | - * rule (leaf-list), performs validation and updates the data model | 86 | + * (leaf-list), performs validation and updates the data model tree. |
82 | - * tree. | ||
83 | * | 87 | * |
84 | - * @param listener listener's object. | 88 | + * @param listener listener's object |
85 | - * @param ctx context object of the grammar rule. | 89 | + * @param ctx context object of the grammar rule |
86 | */ | 90 | */ |
87 | public static void processLeafListEntry(TreeWalkListener listener, | 91 | public static void processLeafListEntry(TreeWalkListener listener, |
88 | - GeneratedYangParser.LeafListStatementContext ctx) { | 92 | + GeneratedYangParser.LeafListStatementContext ctx) { |
89 | 93 | ||
90 | // Check for stack to be non empty. | 94 | // Check for stack to be non empty. |
91 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY); | 95 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY); |
92 | 96 | ||
93 | - boolean result = validateSubStatementsCardinality(ctx); | 97 | + // Validate sub statement cardinality. |
94 | - if (!result) { | 98 | + validateSubStatementsCardinality(ctx); |
95 | - throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY)); | 99 | + |
96 | - } | 100 | + // Check for identifier collision |
101 | + int line = ctx.IDENTIFIER().getSymbol().getLine(); | ||
102 | + int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine(); | ||
103 | + String identifierName = ctx.IDENTIFIER().getText(); | ||
104 | + detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, LEAF_LIST_DATA); | ||
97 | 105 | ||
98 | YangLeafList leafList = new YangLeafList(); | 106 | YangLeafList leafList = new YangLeafList(); |
99 | leafList.setLeafName(ctx.IDENTIFIER().getText()); | 107 | leafList.setLeafName(ctx.IDENTIFIER().getText()); |
... | @@ -106,7 +114,7 @@ public final class LeafListListener { | ... | @@ -106,7 +114,7 @@ public final class LeafListListener { |
106 | leaves.addLeafList(leafList); | 114 | leaves.addLeafList(leafList); |
107 | } else { | 115 | } else { |
108 | throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_LIST_DATA, | 116 | throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_LIST_DATA, |
109 | - ctx.IDENTIFIER().getText(), ENTRY)); | 117 | + ctx.IDENTIFIER().getText(), ENTRY)); |
110 | } | 118 | } |
111 | listener.getParsedDataStack().push(leafList); | 119 | listener.getParsedDataStack().push(leafList); |
112 | } | 120 | } |
... | @@ -115,11 +123,11 @@ public final class LeafListListener { | ... | @@ -115,11 +123,11 @@ public final class LeafListListener { |
115 | * It is called when parser exits from grammar rule (leaf-list), it performs | 123 | * It is called when parser exits from grammar rule (leaf-list), it performs |
116 | * validation and updates the data model tree. | 124 | * validation and updates the data model tree. |
117 | * | 125 | * |
118 | - * @param listener listener's object. | 126 | + * @param listener listener's object |
119 | - * @param ctx context object of the grammar rule. | 127 | + * @param ctx context object of the grammar rule |
120 | */ | 128 | */ |
121 | public static void processLeafListExit(TreeWalkListener listener, | 129 | public static void processLeafListExit(TreeWalkListener listener, |
122 | - GeneratedYangParser.LeafListStatementContext ctx) { | 130 | + GeneratedYangParser.LeafListStatementContext ctx) { |
123 | 131 | ||
124 | // Check for stack to be non empty. | 132 | // Check for stack to be non empty. |
125 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), EXIT); | 133 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), EXIT); |
... | @@ -136,59 +144,17 @@ public final class LeafListListener { | ... | @@ -136,59 +144,17 @@ public final class LeafListListener { |
136 | * Validates the cardinality of leaf-list sub-statements as per grammar. | 144 | * Validates the cardinality of leaf-list sub-statements as per grammar. |
137 | * | 145 | * |
138 | * @param ctx context object of the grammar rule. | 146 | * @param ctx context object of the grammar rule. |
139 | - * @return true/false validation success or failure. | ||
140 | */ | 147 | */ |
141 | - private static boolean validateSubStatementsCardinality(GeneratedYangParser | 148 | + private static void validateSubStatementsCardinality(GeneratedYangParser.LeafListStatementContext ctx) { |
142 | - .LeafListStatementContext ctx) { | 149 | + |
143 | - | 150 | + validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText()); |
144 | - if (ctx.typeStatement().isEmpty() | 151 | + validateCardinality(ctx.unitsStatement(), UNITS_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText()); |
145 | - || (ctx.typeStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | 152 | + validateCardinality(ctx.configStatement(), CONFIG_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText()); |
146 | - yangConstruct = ParsableDataType.TYPE_DATA; | 153 | + validateCardinality(ctx.maxElementsStatement(), MAX_ELEMENT_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText()); |
147 | - return false; | 154 | + validateCardinality(ctx.minElementsStatement(), MIN_ELEMENT_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText()); |
148 | - } | 155 | + validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText()); |
149 | - | 156 | + validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText()); |
150 | - if ((!ctx.unitsStatement().isEmpty()) | 157 | + validateCardinality(ctx.statusStatement(), STATUS_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText()); |
151 | - && (ctx.unitsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | 158 | + //TODO ordered by |
152 | - yangConstruct = ParsableDataType.UNITS_DATA; | ||
153 | - return false; | ||
154 | - } | ||
155 | - | ||
156 | - if ((!ctx.configStatement().isEmpty()) | ||
157 | - && (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
158 | - yangConstruct = ParsableDataType.CONFIG_DATA; | ||
159 | - return false; | ||
160 | - } | ||
161 | - | ||
162 | - if ((!ctx.maxElementsStatement().isEmpty()) | ||
163 | - && (ctx.maxElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
164 | - yangConstruct = ParsableDataType.MAX_ELEMENT_DATA; | ||
165 | - return false; | ||
166 | - } | ||
167 | - | ||
168 | - if ((!ctx.minElementsStatement().isEmpty()) | ||
169 | - && (ctx.minElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
170 | - yangConstruct = ParsableDataType.MIN_ELEMENT_DATA; | ||
171 | - return false; | ||
172 | - } | ||
173 | - | ||
174 | - if ((!ctx.descriptionStatement().isEmpty()) | ||
175 | - && (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
176 | - yangConstruct = ParsableDataType.DESCRIPTION_DATA; | ||
177 | - return false; | ||
178 | - } | ||
179 | - | ||
180 | - if ((!ctx.referenceStatement().isEmpty()) | ||
181 | - && (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
182 | - yangConstruct = ParsableDataType.REFERENCE_DATA; | ||
183 | - return false; | ||
184 | - } | ||
185 | - | ||
186 | - if ((!ctx.statusStatement().isEmpty()) | ||
187 | - && (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
188 | - yangConstruct = ParsableDataType.STATUS_DATA; | ||
189 | - return false; | ||
190 | - } | ||
191 | - | ||
192 | - return true; | ||
193 | } | 159 | } |
194 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
160 | +} | ... | ... |
... | @@ -21,23 +21,29 @@ | ... | @@ -21,23 +21,29 @@ |
21 | package org.onosproject.yangutils.parser.impl.listeners; | 21 | package org.onosproject.yangutils.parser.impl.listeners; |
22 | 22 | ||
23 | import org.onosproject.yangutils.datamodel.YangLeaf; | 23 | import org.onosproject.yangutils.datamodel.YangLeaf; |
24 | +import org.onosproject.yangutils.datamodel.YangLeavesHolder; | ||
24 | import org.onosproject.yangutils.parser.Parsable; | 25 | import org.onosproject.yangutils.parser.Parsable; |
25 | -import org.onosproject.yangutils.parser.ParsableDataType; | ||
26 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 26 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
27 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 27 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
28 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 28 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
29 | -import org.onosproject.yangutils.datamodel.YangLeavesHolder; | 29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; |
30 | -import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | ||
31 | - | ||
32 | -import static org.onosproject.yangutils.parser.ParsableDataType.LEAF_DATA; | ||
33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
35 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
37 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
38 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY; | ||
39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
35 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
40 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
37 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality; | ||
38 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne; | ||
39 | +import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA; | ||
40 | +import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; | ||
41 | +import static org.onosproject.yangutils.utils.YangConstructType.LEAF_DATA; | ||
42 | +import static org.onosproject.yangutils.utils.YangConstructType.MANDATORY_DATA; | ||
43 | +import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; | ||
44 | +import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; | ||
45 | +import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA; | ||
46 | +import static org.onosproject.yangutils.utils.YangConstructType.UNITS_DATA; | ||
41 | 47 | ||
42 | /* | 48 | /* |
43 | * Reference: RFC6020 and YANG ANTLR Grammar | 49 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -66,13 +72,11 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati | ... | @@ -66,13 +72,11 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati |
66 | */ | 72 | */ |
67 | 73 | ||
68 | /** | 74 | /** |
69 | - * Implements listener based call back function corresponding to the "leaf" | 75 | + * Implements listener based call back function corresponding to the "leaf" rule |
70 | - * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | 76 | + * defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. |
71 | */ | 77 | */ |
72 | public final class LeafListener { | 78 | public final class LeafListener { |
73 | 79 | ||
74 | - private static ParsableDataType yangConstruct; | ||
75 | - | ||
76 | /** | 80 | /** |
77 | * Creates a new leaf listener. | 81 | * Creates a new leaf listener. |
78 | */ | 82 | */ |
... | @@ -80,23 +84,26 @@ public final class LeafListener { | ... | @@ -80,23 +84,26 @@ public final class LeafListener { |
80 | } | 84 | } |
81 | 85 | ||
82 | /** | 86 | /** |
83 | - * It is called when parser receives an input matching the grammar | 87 | + * It is called when parser receives an input matching the grammar rule |
84 | - * rule (leaf), performs validation and updates the data model | 88 | + * (leaf), performs validation and updates the data model tree. |
85 | - * tree. | ||
86 | * | 89 | * |
87 | - * @param listener listener's object. | 90 | + * @param listener listener's object |
88 | - * @param ctx context object of the grammar rule. | 91 | + * @param ctx context object of the grammar rule |
89 | */ | 92 | */ |
90 | public static void processLeafEntry(TreeWalkListener listener, | 93 | public static void processLeafEntry(TreeWalkListener listener, |
91 | - GeneratedYangParser.LeafStatementContext ctx) { | 94 | + GeneratedYangParser.LeafStatementContext ctx) { |
92 | 95 | ||
93 | // Check for stack to be non empty. | 96 | // Check for stack to be non empty. |
94 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), ENTRY); | 97 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), ENTRY); |
95 | 98 | ||
96 | - boolean result = validateSubStatementsCardinality(ctx); | 99 | + // Validate sub statement cardinality. |
97 | - if (!result) { | 100 | + validateSubStatementsCardinality(ctx); |
98 | - throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY)); | 101 | + |
99 | - } | 102 | + // Check for identifier collision |
103 | + int line = ctx.IDENTIFIER().getSymbol().getLine(); | ||
104 | + int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine(); | ||
105 | + String identifierName = ctx.IDENTIFIER().getText(); | ||
106 | + detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, LEAF_DATA); | ||
100 | 107 | ||
101 | YangLeaf leaf = new YangLeaf(); | 108 | YangLeaf leaf = new YangLeaf(); |
102 | leaf.setLeafName(ctx.IDENTIFIER().getText()); | 109 | leaf.setLeafName(ctx.IDENTIFIER().getText()); |
... | @@ -123,7 +130,7 @@ public final class LeafListener { | ... | @@ -123,7 +130,7 @@ public final class LeafListener { |
123 | * @param ctx context object of the grammar rule. | 130 | * @param ctx context object of the grammar rule. |
124 | */ | 131 | */ |
125 | public static void processLeafExit(TreeWalkListener listener, | 132 | public static void processLeafExit(TreeWalkListener listener, |
126 | - GeneratedYangParser.LeafStatementContext ctx) { | 133 | + GeneratedYangParser.LeafStatementContext ctx) { |
127 | 134 | ||
128 | // Check for stack to be non empty. | 135 | // Check for stack to be non empty. |
129 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), EXIT); | 136 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), EXIT); |
... | @@ -132,7 +139,7 @@ public final class LeafListener { | ... | @@ -132,7 +139,7 @@ public final class LeafListener { |
132 | listener.getParsedDataStack().pop(); | 139 | listener.getParsedDataStack().pop(); |
133 | } else { | 140 | } else { |
134 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_DATA, | 141 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_DATA, |
135 | - ctx.IDENTIFIER().getText(), EXIT)); | 142 | + ctx.IDENTIFIER().getText(), EXIT)); |
136 | } | 143 | } |
137 | } | 144 | } |
138 | 145 | ||
... | @@ -140,53 +147,16 @@ public final class LeafListener { | ... | @@ -140,53 +147,16 @@ public final class LeafListener { |
140 | * Validates the cardinality of leaf sub-statements as per grammar. | 147 | * Validates the cardinality of leaf sub-statements as per grammar. |
141 | * | 148 | * |
142 | * @param ctx context object of the grammar rule. | 149 | * @param ctx context object of the grammar rule. |
143 | - * @return true/false validation success or failure. | ||
144 | */ | 150 | */ |
145 | - private static boolean validateSubStatementsCardinality(GeneratedYangParser | 151 | + private static void validateSubStatementsCardinality(GeneratedYangParser.LeafStatementContext ctx) { |
146 | - .LeafStatementContext ctx) { | 152 | + |
147 | - | 153 | + validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, LEAF_DATA, ctx.IDENTIFIER().getText()); |
148 | - if (ctx.typeStatement().isEmpty() | 154 | + validateCardinality(ctx.unitsStatement(), UNITS_DATA, LEAF_DATA, ctx.IDENTIFIER().getText()); |
149 | - || (ctx.typeStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | 155 | + validateCardinality(ctx.configStatement(), CONFIG_DATA, LEAF_DATA, ctx.IDENTIFIER().getText()); |
150 | - yangConstruct = ParsableDataType.TYPE_DATA; | 156 | + validateCardinality(ctx.mandatoryStatement(), MANDATORY_DATA, LEAF_DATA, ctx.IDENTIFIER().getText()); |
151 | - return false; | 157 | + validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LEAF_DATA, ctx.IDENTIFIER().getText()); |
152 | - } | 158 | + validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LEAF_DATA, ctx.IDENTIFIER().getText()); |
153 | - | 159 | + validateCardinality(ctx.statusStatement(), STATUS_DATA, LEAF_DATA, ctx.IDENTIFIER().getText()); |
154 | - if ((!ctx.unitsStatement().isEmpty()) | 160 | + //TODO when. |
155 | - && (ctx.unitsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
156 | - yangConstruct = ParsableDataType.UNITS_DATA; | ||
157 | - return false; | ||
158 | - } | ||
159 | - | ||
160 | - if ((!ctx.configStatement().isEmpty()) | ||
161 | - && (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
162 | - yangConstruct = ParsableDataType.CONFIG_DATA; | ||
163 | - return false; | ||
164 | - } | ||
165 | - | ||
166 | - if ((!ctx.mandatoryStatement().isEmpty()) | ||
167 | - && (ctx.mandatoryStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
168 | - yangConstruct = ParsableDataType.MANDATORY_DATA; | ||
169 | - return false; | ||
170 | - } | ||
171 | - | ||
172 | - if ((!ctx.descriptionStatement().isEmpty()) | ||
173 | - && (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
174 | - yangConstruct = ParsableDataType.DESCRIPTION_DATA; | ||
175 | - return false; | ||
176 | - } | ||
177 | - | ||
178 | - if ((!ctx.referenceStatement().isEmpty()) | ||
179 | - && (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
180 | - yangConstruct = ParsableDataType.REFERENCE_DATA; | ||
181 | - return false; | ||
182 | - } | ||
183 | - | ||
184 | - if ((!ctx.statusStatement().isEmpty()) | ||
185 | - && (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
186 | - yangConstruct = ParsableDataType.STATUS_DATA; | ||
187 | - return false; | ||
188 | - } | ||
189 | - | ||
190 | - return true; | ||
191 | } | 161 | } |
192 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
162 | +} | ... | ... |
... | @@ -16,31 +16,38 @@ | ... | @@ -16,31 +16,38 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.parser.impl.listeners; | 17 | package org.onosproject.yangutils.parser.impl.listeners; |
18 | 18 | ||
19 | -import org.onosproject.yangutils.datamodel.YangList; | ||
20 | import org.onosproject.yangutils.datamodel.YangContainer; | 19 | import org.onosproject.yangutils.datamodel.YangContainer; |
20 | +import org.onosproject.yangutils.datamodel.YangList; | ||
21 | import org.onosproject.yangutils.datamodel.YangModule; | 21 | import org.onosproject.yangutils.datamodel.YangModule; |
22 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.datamodel.YangNodeType; | 23 | import org.onosproject.yangutils.datamodel.YangNodeType; |
24 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 24 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
25 | import org.onosproject.yangutils.parser.Parsable; | 25 | import org.onosproject.yangutils.parser.Parsable; |
26 | -import org.onosproject.yangutils.parser.ParsableDataType; | ||
27 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 26 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
28 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 27 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
29 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 28 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
30 | -import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; |
31 | -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; | ||
32 | - | ||
33 | -import static org.onosproject.yangutils.parser.ParsableDataType.LIST_DATA; | ||
34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
35 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; |
37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
34 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | ||
38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 35 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
40 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | ||
41 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; | 37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; |
42 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY; | 38 | +import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; |
43 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
40 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality; | ||
41 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonNull; | ||
42 | +import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA; | ||
43 | +import static org.onosproject.yangutils.utils.YangConstructType.DATA_DEF_DATA; | ||
44 | +import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; | ||
45 | +import static org.onosproject.yangutils.utils.YangConstructType.KEY_DATA; | ||
46 | +import static org.onosproject.yangutils.utils.YangConstructType.LIST_DATA; | ||
47 | +import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA; | ||
48 | +import static org.onosproject.yangutils.utils.YangConstructType.MIN_ELEMENT_DATA; | ||
49 | +import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; | ||
50 | +import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; | ||
44 | 51 | ||
45 | /* | 52 | /* |
46 | * Reference: RFC6020 and YANG ANTLR Grammar | 53 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -74,13 +81,11 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati | ... | @@ -74,13 +81,11 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati |
74 | */ | 81 | */ |
75 | 82 | ||
76 | /** | 83 | /** |
77 | - * Implements listener based call back function corresponding to the "list" | 84 | + * Implements listener based call back function corresponding to the "list" rule |
78 | - * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | 85 | + * defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. |
79 | */ | 86 | */ |
80 | public final class ListListener { | 87 | public final class ListListener { |
81 | 88 | ||
82 | - private static ParsableDataType yangConstruct; | ||
83 | - | ||
84 | /** | 89 | /** |
85 | * Creates a new list listener. | 90 | * Creates a new list listener. |
86 | */ | 91 | */ |
... | @@ -88,30 +93,35 @@ public final class ListListener { | ... | @@ -88,30 +93,35 @@ public final class ListListener { |
88 | } | 93 | } |
89 | 94 | ||
90 | /** | 95 | /** |
91 | - * It is called when parser receives an input matching the grammar | 96 | + * It is called when parser receives an input matching the grammar rule |
92 | - * rule (list), performs validation and updates the data model | 97 | + * (list), performs validation and updates the data model tree. |
93 | - * tree. | ||
94 | * | 98 | * |
95 | - * @param listener listener's object. | 99 | + * @param listener listener's object |
96 | - * @param ctx context object of the grammar rule. | 100 | + * @param ctx context object of the grammar rule |
97 | */ | 101 | */ |
98 | public static void processListEntry(TreeWalkListener listener, | 102 | public static void processListEntry(TreeWalkListener listener, |
99 | - GeneratedYangParser.ListStatementContext ctx) { | 103 | + GeneratedYangParser.ListStatementContext ctx) { |
100 | 104 | ||
101 | YangNode curNode; | 105 | YangNode curNode; |
102 | 106 | ||
103 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY); | 107 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY); |
104 | 108 | ||
105 | - boolean result = validateSubStatementsCardinality(ctx); | 109 | + // Validate sub statement cardinality. |
106 | - if (!result) { | 110 | + validateSubStatementsCardinality(ctx); |
107 | - throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY)); | 111 | + |
108 | - } | 112 | + // Check for identifier collision |
113 | + int line = ctx.IDENTIFIER().getSymbol().getLine(); | ||
114 | + int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine(); | ||
115 | + String identifierName = ctx.IDENTIFIER().getText(); | ||
116 | + detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, LIST_DATA); | ||
109 | 117 | ||
110 | YangList yangList = new YangList(YangNodeType.LIST_NODE); | 118 | YangList yangList = new YangList(YangNodeType.LIST_NODE); |
111 | yangList.setName(ctx.IDENTIFIER().getText()); | 119 | yangList.setName(ctx.IDENTIFIER().getText()); |
112 | 120 | ||
113 | - /* If "config" is not specified, the default is the same as the parent | 121 | + /* |
114 | - schema node's "config" value. */ | 122 | + * If "config" is not specified, the default is the same as the parent |
123 | + * schema node's "config" value. | ||
124 | + */ | ||
115 | if (ctx.configStatement().isEmpty()) { | 125 | if (ctx.configStatement().isEmpty()) { |
116 | boolean parentConfig = ListenerValidation.getParentNodeConfig(listener); | 126 | boolean parentConfig = ListenerValidation.getParentNodeConfig(listener); |
117 | yangList.setConfig(parentConfig); | 127 | yangList.setConfig(parentConfig); |
... | @@ -130,7 +140,7 @@ public final class ListListener { | ... | @@ -130,7 +140,7 @@ public final class ListListener { |
130 | listener.getParsedDataStack().push(yangList); | 140 | listener.getParsedDataStack().push(yangList); |
131 | } else { | 141 | } else { |
132 | throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LIST_DATA, | 142 | throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LIST_DATA, |
133 | - ctx.IDENTIFIER().getText(), ENTRY)); | 143 | + ctx.IDENTIFIER().getText(), ENTRY)); |
134 | } | 144 | } |
135 | } | 145 | } |
136 | 146 | ||
... | @@ -138,11 +148,11 @@ public final class ListListener { | ... | @@ -138,11 +148,11 @@ public final class ListListener { |
138 | * It is called when parser exits from grammar rule (list), it performs | 148 | * It is called when parser exits from grammar rule (list), it performs |
139 | * validation and updates the data model tree. | 149 | * validation and updates the data model tree. |
140 | * | 150 | * |
141 | - * @param listener listener's object. | 151 | + * @param listener listener's object |
142 | - * @param ctx context object of the grammar rule. | 152 | + * @param ctx context object of the grammar rule |
143 | */ | 153 | */ |
144 | public static void processListExit(TreeWalkListener listener, | 154 | public static void processListExit(TreeWalkListener listener, |
145 | - GeneratedYangParser.ListStatementContext ctx) { | 155 | + GeneratedYangParser.ListStatementContext ctx) { |
146 | 156 | ||
147 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LIST_DATA, ctx.IDENTIFIER().getText(), EXIT); | 157 | checkStackIsNotEmpty(listener, MISSING_HOLDER, LIST_DATA, ctx.IDENTIFIER().getText(), EXIT); |
148 | 158 | ||
... | @@ -157,65 +167,25 @@ public final class ListListener { | ... | @@ -157,65 +167,25 @@ public final class ListListener { |
157 | listener.getParsedDataStack().pop(); | 167 | listener.getParsedDataStack().pop(); |
158 | } else { | 168 | } else { |
159 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LIST_DATA, | 169 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LIST_DATA, |
160 | - ctx.IDENTIFIER().getText(), EXIT)); | 170 | + ctx.IDENTIFIER().getText(), EXIT)); |
161 | } | 171 | } |
162 | } | 172 | } |
163 | 173 | ||
164 | /** | 174 | /** |
165 | * Validates the cardinality of list sub-statements as per grammar. | 175 | * Validates the cardinality of list sub-statements as per grammar. |
166 | * | 176 | * |
167 | - * @param ctx context object of the grammar rule. | 177 | + * @param ctx context object of the grammar rule |
168 | - * @return true/false validation success or failure. | ||
169 | */ | 178 | */ |
170 | - private static boolean validateSubStatementsCardinality(GeneratedYangParser.ListStatementContext ctx) { | 179 | + private static void validateSubStatementsCardinality(GeneratedYangParser.ListStatementContext ctx) { |
171 | - | 180 | + |
172 | - if ((!ctx.keyStatement().isEmpty()) | 181 | + validateCardinality(ctx.keyStatement(), KEY_DATA, LIST_DATA, ctx.IDENTIFIER().getText()); |
173 | - && (ctx.keyStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | 182 | + validateCardinality(ctx.configStatement(), CONFIG_DATA, LIST_DATA, ctx.IDENTIFIER().getText()); |
174 | - yangConstruct = ParsableDataType.KEY_DATA; | 183 | + validateCardinality(ctx.maxElementsStatement(), MAX_ELEMENT_DATA, LIST_DATA, ctx.IDENTIFIER().getText()); |
175 | - return false; | 184 | + validateCardinality(ctx.minElementsStatement(), MIN_ELEMENT_DATA, LIST_DATA, ctx.IDENTIFIER().getText()); |
176 | - } | 185 | + validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LIST_DATA, ctx.IDENTIFIER().getText()); |
177 | - | 186 | + validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LIST_DATA, ctx.IDENTIFIER().getText()); |
178 | - if ((!ctx.configStatement().isEmpty()) | 187 | + validateCardinality(ctx.statusStatement(), STATUS_DATA, LIST_DATA, ctx.IDENTIFIER().getText()); |
179 | - && (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | 188 | + validateCardinalityNonNull(ctx.dataDefStatement(), DATA_DEF_DATA, LIST_DATA, ctx.IDENTIFIER().getText()); |
180 | - yangConstruct = ParsableDataType.CONFIG_DATA; | 189 | + //TODO when, typedef, grouping, unique |
181 | - return false; | ||
182 | - } | ||
183 | - | ||
184 | - if ((!ctx.maxElementsStatement().isEmpty()) | ||
185 | - && (ctx.maxElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
186 | - yangConstruct = ParsableDataType.MAX_ELEMENT_DATA; | ||
187 | - return false; | ||
188 | - } | ||
189 | - | ||
190 | - if ((!ctx.minElementsStatement().isEmpty()) | ||
191 | - && (ctx.minElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
192 | - yangConstruct = ParsableDataType.MIN_ELEMENT_DATA; | ||
193 | - return false; | ||
194 | - } | ||
195 | - | ||
196 | - if ((!ctx.descriptionStatement().isEmpty()) | ||
197 | - && (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
198 | - yangConstruct = ParsableDataType.DESCRIPTION_DATA; | ||
199 | - return false; | ||
200 | - } | ||
201 | - | ||
202 | - if ((!ctx.referenceStatement().isEmpty()) | ||
203 | - && (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
204 | - yangConstruct = ParsableDataType.REFERENCE_DATA; | ||
205 | - return false; | ||
206 | - } | ||
207 | - | ||
208 | - if ((!ctx.statusStatement().isEmpty()) | ||
209 | - && (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
210 | - yangConstruct = ParsableDataType.STATUS_DATA; | ||
211 | - return false; | ||
212 | - } | ||
213 | - | ||
214 | - if (ctx.dataDefStatement().isEmpty()) { | ||
215 | - yangConstruct = ParsableDataType.LIST_DATA; | ||
216 | - return false; | ||
217 | - } | ||
218 | - | ||
219 | - return true; | ||
220 | } | 190 | } |
221 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
191 | +} | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListener.java
... | @@ -22,7 +22,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -22,7 +22,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
22 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 22 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
23 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 23 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
24 | 24 | ||
25 | -import static org.onosproject.yangutils.parser.ParsableDataType.MANDATORY_DATA; | 25 | +import static org.onosproject.yangutils.utils.YangConstructType.MANDATORY_DATA; |
26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -62,8 +62,8 @@ public final class MandatoryListener { | ... | @@ -62,8 +62,8 @@ public final class MandatoryListener { |
62 | * rule (mandatory), performs validation and updates the data model | 62 | * rule (mandatory), performs validation and updates the data model |
63 | * tree. | 63 | * tree. |
64 | * | 64 | * |
65 | - * @param listener listener's object. | 65 | + * @param listener listener's object |
66 | - * @param ctx context object of the grammar rule. | 66 | + * @param ctx context object of the grammar rule |
67 | */ | 67 | */ |
68 | public static void processMandatoryEntry(TreeWalkListener listener, | 68 | public static void processMandatoryEntry(TreeWalkListener listener, |
69 | GeneratedYangParser.MandatoryStatementContext ctx) { | 69 | GeneratedYangParser.MandatoryStatementContext ctx) { |
... | @@ -72,7 +72,7 @@ public final class MandatoryListener { | ... | @@ -72,7 +72,7 @@ public final class MandatoryListener { |
72 | checkStackIsNotEmpty(listener, MISSING_HOLDER, MANDATORY_DATA, "", ENTRY); | 72 | checkStackIsNotEmpty(listener, MISSING_HOLDER, MANDATORY_DATA, "", ENTRY); |
73 | 73 | ||
74 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 74 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
75 | - switch (tmpNode.getParsableDataType()) { | 75 | + switch (tmpNode.getYangConstructType()) { |
76 | case LEAF_DATA: | 76 | case LEAF_DATA: |
77 | YangLeaf leaf = (YangLeaf) tmpNode; | 77 | YangLeaf leaf = (YangLeaf) tmpNode; |
78 | if (ctx.TRUE_KEYWORD() != null) { | 78 | if (ctx.TRUE_KEYWORD() != null) { | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.MAX_ELEMENT_DATA; | 26 | +import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -60,8 +60,8 @@ public final class MaxElementsListener { | ... | @@ -60,8 +60,8 @@ public final class MaxElementsListener { |
60 | * rule (max-elements), performs validation and updates the data model | 60 | * rule (max-elements), performs validation and updates the data model |
61 | * tree. | 61 | * tree. |
62 | * | 62 | * |
63 | - * @param listener listener's object. | 63 | + * @param listener listener's object |
64 | - * @param ctx context object of the grammar rule. | 64 | + * @param ctx context object of the grammar rule |
65 | */ | 65 | */ |
66 | public static void processMaxElementsEntry(TreeWalkListener listener, | 66 | public static void processMaxElementsEntry(TreeWalkListener listener, |
67 | GeneratedYangParser.MaxElementsStatementContext ctx) { | 67 | GeneratedYangParser.MaxElementsStatementContext ctx) { |
... | @@ -77,7 +77,7 @@ public final class MaxElementsListener { | ... | @@ -77,7 +77,7 @@ public final class MaxElementsListener { |
77 | } | 77 | } |
78 | 78 | ||
79 | Parsable tmpData = listener.getParsedDataStack().peek(); | 79 | Parsable tmpData = listener.getParsedDataStack().peek(); |
80 | - switch (tmpData.getParsableDataType()) { | 80 | + switch (tmpData.getYangConstructType()) { |
81 | case LEAF_LIST_DATA: | 81 | case LEAF_LIST_DATA: |
82 | YangLeafList leafList = (YangLeafList) tmpData; | 82 | YangLeafList leafList = (YangLeafList) tmpData; |
83 | leafList.setMaxElelements(maxElementsValue); | 83 | leafList.setMaxElelements(maxElementsValue); | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.MIN_ELEMENT_DATA; | 26 | +import static org.onosproject.yangutils.utils.YangConstructType.MIN_ELEMENT_DATA; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -61,8 +61,8 @@ public final class MinElementsListener { | ... | @@ -61,8 +61,8 @@ public final class MinElementsListener { |
61 | * rule (min-elements), performs validation and updates the data model | 61 | * rule (min-elements), performs validation and updates the data model |
62 | * tree. | 62 | * tree. |
63 | * | 63 | * |
64 | - * @param listener listener's object. | 64 | + * @param listener listener's object |
65 | - * @param ctx context object of the grammar rule. | 65 | + * @param ctx context object of the grammar rule |
66 | */ | 66 | */ |
67 | public static void processMinElementsEntry(TreeWalkListener listener, | 67 | public static void processMinElementsEntry(TreeWalkListener listener, |
68 | GeneratedYangParser.MinElementsStatementContext ctx) { | 68 | GeneratedYangParser.MinElementsStatementContext ctx) { |
... | @@ -71,7 +71,7 @@ public final class MinElementsListener { | ... | @@ -71,7 +71,7 @@ public final class MinElementsListener { |
71 | checkStackIsNotEmpty(listener, MISSING_HOLDER, MIN_ELEMENT_DATA, ctx.INTEGER().getText(), ENTRY); | 71 | checkStackIsNotEmpty(listener, MISSING_HOLDER, MIN_ELEMENT_DATA, ctx.INTEGER().getText(), ENTRY); |
72 | 72 | ||
73 | Parsable tmpData = listener.getParsedDataStack().peek(); | 73 | Parsable tmpData = listener.getParsedDataStack().peek(); |
74 | - switch (tmpData.getParsableDataType()) { | 74 | + switch (tmpData.getYangConstructType()) { |
75 | case LEAF_LIST_DATA: | 75 | case LEAF_LIST_DATA: |
76 | YangLeafList leafList = (YangLeafList) tmpData; | 76 | YangLeafList leafList = (YangLeafList) tmpData; |
77 | leafList.setMinElements(Integer.parseInt(ctx.INTEGER().getText())); | 77 | leafList.setMinElements(Integer.parseInt(ctx.INTEGER().getText())); | ... | ... |
... | @@ -20,14 +20,15 @@ import org.onosproject.yangutils.datamodel.YangModule; | ... | @@ -20,14 +20,15 @@ import org.onosproject.yangutils.datamodel.YangModule; |
20 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 20 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
21 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 21 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
22 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 22 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
23 | - | ||
24 | -import static org.onosproject.yangutils.parser.ParsableDataType.MODULE_DATA; | ||
25 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 23 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 24 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 25 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
28 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*; | 26 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
27 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
28 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
31 | +import static org.onosproject.yangutils.utils.YangConstructType.MODULE_DATA; | ||
31 | 32 | ||
32 | /* | 33 | /* |
33 | * Reference: RFC6020 and YANG ANTLR Grammar | 34 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -63,8 +64,8 @@ public final class ModuleListener { | ... | @@ -63,8 +64,8 @@ public final class ModuleListener { |
63 | * It is called when parser receives an input matching the grammar rule | 64 | * It is called when parser receives an input matching the grammar rule |
64 | * (module), perform validations and update the data model tree. | 65 | * (module), perform validations and update the data model tree. |
65 | * | 66 | * |
66 | - * @param listener Listener's object. | 67 | + * @param listener Listener's object |
67 | - * @param ctx context object of the grammar rule. | 68 | + * @param ctx context object of the grammar rule |
68 | */ | 69 | */ |
69 | public static void processModuleEntry(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) { | 70 | public static void processModuleEntry(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) { |
70 | 71 | ||
... | @@ -74,6 +75,10 @@ public final class ModuleListener { | ... | @@ -74,6 +75,10 @@ public final class ModuleListener { |
74 | YangModule yangModule = new YangModule(); | 75 | YangModule yangModule = new YangModule(); |
75 | yangModule.setName(ctx.IDENTIFIER().getText()); | 76 | yangModule.setName(ctx.IDENTIFIER().getText()); |
76 | 77 | ||
78 | + if (ctx.moduleBody(0).moduleHeaderStatement().yangVersionStatement() == null) { | ||
79 | + yangModule.setVersion((byte) 1); | ||
80 | + } | ||
81 | + | ||
77 | listener.getParsedDataStack().push(yangModule); | 82 | listener.getParsedDataStack().push(yangModule); |
78 | } | 83 | } |
79 | 84 | ||
... | @@ -81,8 +86,8 @@ public final class ModuleListener { | ... | @@ -81,8 +86,8 @@ public final class ModuleListener { |
81 | * It is called when parser exits from grammar rule (module), it perform | 86 | * It is called when parser exits from grammar rule (module), it perform |
82 | * validations and update the data model tree. | 87 | * validations and update the data model tree. |
83 | * | 88 | * |
84 | - * @param listener Listener's object. | 89 | + * @param listener Listener's object |
85 | - * @param ctx context object of the grammar rule. | 90 | + * @param ctx context object of the grammar rule |
86 | */ | 91 | */ |
87 | public static void processModuleExit(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) { | 92 | public static void processModuleExit(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) { |
88 | 93 | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListener.java
... | @@ -25,7 +25,7 @@ import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ... | @@ -25,7 +25,7 @@ import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | import java.net.URI; | 26 | import java.net.URI; |
27 | 27 | ||
28 | -import static org.onosproject.yangutils.parser.ParsableDataType.NAMESPACE_DATA; | 28 | +import static org.onosproject.yangutils.utils.YangConstructType.NAMESPACE_DATA; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -70,8 +70,8 @@ public final class NamespaceListener { | ... | @@ -70,8 +70,8 @@ public final class NamespaceListener { |
70 | * It is called when parser receives an input matching the grammar rule | 70 | * It is called when parser receives an input matching the grammar rule |
71 | * (namespace), perform validations and update the data model tree. | 71 | * (namespace), perform validations and update the data model tree. |
72 | * | 72 | * |
73 | - * @param listener Listener's object. | 73 | + * @param listener Listener's object |
74 | - * @param ctx context object of the grammar rule. | 74 | + * @param ctx context object of the grammar rule |
75 | */ | 75 | */ |
76 | public static void processNamespaceEntry(TreeWalkListener listener, | 76 | public static void processNamespaceEntry(TreeWalkListener listener, |
77 | GeneratedYangParser.NamespaceStatementContext ctx) { | 77 | GeneratedYangParser.NamespaceStatementContext ctx) { |
... | @@ -80,7 +80,7 @@ public final class NamespaceListener { | ... | @@ -80,7 +80,7 @@ public final class NamespaceListener { |
80 | checkStackIsNotEmpty(listener, MISSING_HOLDER, NAMESPACE_DATA, ctx.string().getText(), ENTRY); | 80 | checkStackIsNotEmpty(listener, MISSING_HOLDER, NAMESPACE_DATA, ctx.string().getText(), ENTRY); |
81 | 81 | ||
82 | if (!validateUriValue(ctx.string().getText())) { | 82 | if (!validateUriValue(ctx.string().getText())) { |
83 | - ParserException parserException = new ParserException("Invalid namespace URI"); | 83 | + ParserException parserException = new ParserException("YANG file error: Invalid namespace URI"); |
84 | parserException.setLine(ctx.string().STRING(0).getSymbol().getLine()); | 84 | parserException.setLine(ctx.string().STRING(0).getSymbol().getLine()); |
85 | parserException.setCharPosition(ctx.string().STRING(0).getSymbol().getCharPositionInLine()); | 85 | parserException.setCharPosition(ctx.string().STRING(0).getSymbol().getCharPositionInLine()); |
86 | throw parserException; | 86 | throw parserException; |
... | @@ -88,7 +88,7 @@ public final class NamespaceListener { | ... | @@ -88,7 +88,7 @@ public final class NamespaceListener { |
88 | 88 | ||
89 | // Obtain the node of the stack. | 89 | // Obtain the node of the stack. |
90 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 90 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
91 | - switch (tmpNode.getParsableDataType()) { | 91 | + switch (tmpNode.getYangConstructType()) { |
92 | case MODULE_DATA: { | 92 | case MODULE_DATA: { |
93 | YangModule module = (YangModule) tmpNode; | 93 | YangModule module = (YangModule) tmpNode; |
94 | YangNameSpace uri = new YangNameSpace(); | 94 | YangNameSpace uri = new YangNameSpace(); | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.ORGANIZATION_DATA; | 26 | +import static org.onosproject.yangutils.utils.YangConstructType.ORGANIZATION_DATA; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -88,8 +88,8 @@ public final class OrganizationListener { | ... | @@ -88,8 +88,8 @@ public final class OrganizationListener { |
88 | * It is called when parser receives an input matching the grammar rule | 88 | * It is called when parser receives an input matching the grammar rule |
89 | * (organization), perform validations and update the data model tree. | 89 | * (organization), perform validations and update the data model tree. |
90 | * | 90 | * |
91 | - * @param listener Listener's object. | 91 | + * @param listener Listener's object |
92 | - * @param ctx context object of the grammar rule. | 92 | + * @param ctx context object of the grammar rule |
93 | */ | 93 | */ |
94 | public static void processOrganizationEntry(TreeWalkListener listener, | 94 | public static void processOrganizationEntry(TreeWalkListener listener, |
95 | GeneratedYangParser.OrganizationStatementContext ctx) { | 95 | GeneratedYangParser.OrganizationStatementContext ctx) { |
... | @@ -100,7 +100,7 @@ public final class OrganizationListener { | ... | @@ -100,7 +100,7 @@ public final class OrganizationListener { |
100 | 100 | ||
101 | // Obtain the node of the stack. | 101 | // Obtain the node of the stack. |
102 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 102 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
103 | - switch (tmpNode.getParsableDataType()) { | 103 | + switch (tmpNode.getYangConstructType()) { |
104 | case MODULE_DATA: { | 104 | case MODULE_DATA: { |
105 | YangModule module = (YangModule) tmpNode; | 105 | YangModule module = (YangModule) tmpNode; |
106 | module.setOrganization(ctx.string().getText()); | 106 | module.setOrganization(ctx.string().getText()); | ... | ... |
... | @@ -36,7 +36,7 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -36,7 +36,7 @@ package org.onosproject.yangutils.parser.impl.listeners; |
36 | import org.onosproject.yangutils.datamodel.YangBit; | 36 | import org.onosproject.yangutils.datamodel.YangBit; |
37 | import org.onosproject.yangutils.datamodel.YangBits; | 37 | import org.onosproject.yangutils.datamodel.YangBits; |
38 | import org.onosproject.yangutils.parser.Parsable; | 38 | import org.onosproject.yangutils.parser.Parsable; |
39 | -import static org.onosproject.yangutils.parser.ParsableDataType.POSITION_DATA; | 39 | +import static org.onosproject.yangutils.utils.YangConstructType.POSITION_DATA; |
40 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 40 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
41 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 41 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
42 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 42 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
... | @@ -65,8 +65,8 @@ public final class PositionListener { | ... | @@ -65,8 +65,8 @@ public final class PositionListener { |
65 | * It is called when parser receives an input matching the grammar rule | 65 | * It is called when parser receives an input matching the grammar rule |
66 | * (position), perform validations and update the data model tree. | 66 | * (position), perform validations and update the data model tree. |
67 | * | 67 | * |
68 | - * @param listener Listener's object. | 68 | + * @param listener Listener's object |
69 | - * @param ctx context object of the grammar rule. | 69 | + * @param ctx context object of the grammar rule |
70 | */ | 70 | */ |
71 | public static void processPositionEntry(TreeWalkListener listener, | 71 | public static void processPositionEntry(TreeWalkListener listener, |
72 | GeneratedYangParser.PositionStatementContext ctx) { | 72 | GeneratedYangParser.PositionStatementContext ctx) { |
... | @@ -76,7 +76,7 @@ public final class PositionListener { | ... | @@ -76,7 +76,7 @@ public final class PositionListener { |
76 | 76 | ||
77 | // Obtain the node of the stack. | 77 | // Obtain the node of the stack. |
78 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 78 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
79 | - switch (tmpNode.getParsableDataType()) { | 79 | + switch (tmpNode.getYangConstructType()) { |
80 | case BIT_DATA: { | 80 | case BIT_DATA: { |
81 | YangBit bitNode = (YangBit) tmpNode; | 81 | YangBit bitNode = (YangBit) tmpNode; |
82 | if (!isBitPositionValid(listener, ctx)) { | 82 | if (!isBitPositionValid(listener, ctx)) { |
... | @@ -97,8 +97,8 @@ public final class PositionListener { | ... | @@ -97,8 +97,8 @@ public final class PositionListener { |
97 | /** | 97 | /** |
98 | * Validates BITS position value correctness and uniqueness. | 98 | * Validates BITS position value correctness and uniqueness. |
99 | * | 99 | * |
100 | - * @param listener Listener's object. | 100 | + * @param listener Listener's object |
101 | - * @param ctx context object of the grammar rule. | 101 | + * @param ctx context object of the grammar rule |
102 | * @return validation result | 102 | * @return validation result |
103 | */ | 103 | */ |
104 | private static boolean isBitPositionValid(TreeWalkListener listener, | 104 | private static boolean isBitPositionValid(TreeWalkListener listener, |
... | @@ -109,18 +109,18 @@ public final class PositionListener { | ... | @@ -109,18 +109,18 @@ public final class PositionListener { |
109 | checkStackIsNotEmpty(listener, MISSING_HOLDER, POSITION_DATA, ctx.INTEGER().getText(), ENTRY); | 109 | checkStackIsNotEmpty(listener, MISSING_HOLDER, POSITION_DATA, ctx.INTEGER().getText(), ENTRY); |
110 | 110 | ||
111 | if (Integer.valueOf(ctx.INTEGER().getText()) < 0) { | 111 | if (Integer.valueOf(ctx.INTEGER().getText()) < 0) { |
112 | - errMsg = "Negative value of position is invalid"; | 112 | + errMsg = "YANG file error: Negative value of position is invalid."; |
113 | listener.getParsedDataStack().push(bitNode); | 113 | listener.getParsedDataStack().push(bitNode); |
114 | return false; | 114 | return false; |
115 | } | 115 | } |
116 | 116 | ||
117 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 117 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
118 | - switch (tmpNode.getParsableDataType()) { | 118 | + switch (tmpNode.getYangConstructType()) { |
119 | case BITS_DATA: { | 119 | case BITS_DATA: { |
120 | YangBits yangBits = (YangBits) tmpNode; | 120 | YangBits yangBits = (YangBits) tmpNode; |
121 | for (YangBit curBit : yangBits.getBitSet()) { | 121 | for (YangBit curBit : yangBits.getBitSet()) { |
122 | if (Integer.valueOf(ctx.INTEGER().getText()) == curBit.getPosition()) { | 122 | if (Integer.valueOf(ctx.INTEGER().getText()) == curBit.getPosition()) { |
123 | - errMsg = "Duplicate value of position is invalid"; | 123 | + errMsg = "YANG file error: Duplicate value of position is invalid."; |
124 | listener.getParsedDataStack().push(bitNode); | 124 | listener.getParsedDataStack().push(bitNode); |
125 | return false; | 125 | return false; |
126 | } | 126 | } | ... | ... |
... | @@ -24,7 +24,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -24,7 +24,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
24 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 24 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
26 | 26 | ||
27 | -import static org.onosproject.yangutils.parser.ParsableDataType.PREFIX_DATA; | 27 | +import static org.onosproject.yangutils.utils.YangConstructType.PREFIX_DATA; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -70,8 +70,8 @@ public final class PrefixListener { | ... | @@ -70,8 +70,8 @@ public final class PrefixListener { |
70 | * It is called when parser receives an input matching the grammar rule | 70 | * It is called when parser receives an input matching the grammar rule |
71 | * (prefix),perform validations and update the data model tree. | 71 | * (prefix),perform validations and update the data model tree. |
72 | * | 72 | * |
73 | - * @param listener Listener's object. | 73 | + * @param listener Listener's object |
74 | - * @param ctx context object of the grammar rule. | 74 | + * @param ctx context object of the grammar rule |
75 | */ | 75 | */ |
76 | public static void processPrefixEntry(TreeWalkListener listener, GeneratedYangParser.PrefixStatementContext ctx) { | 76 | public static void processPrefixEntry(TreeWalkListener listener, GeneratedYangParser.PrefixStatementContext ctx) { |
77 | 77 | ||
... | @@ -80,7 +80,7 @@ public final class PrefixListener { | ... | @@ -80,7 +80,7 @@ public final class PrefixListener { |
80 | 80 | ||
81 | // Obtain the node of the stack. | 81 | // Obtain the node of the stack. |
82 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 82 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
83 | - switch (tmpNode.getParsableDataType()) { | 83 | + switch (tmpNode.getYangConstructType()) { |
84 | case MODULE_DATA: { | 84 | case MODULE_DATA: { |
85 | YangModule module = (YangModule) tmpNode; | 85 | YangModule module = (YangModule) tmpNode; |
86 | module.setPrefix(ctx.IDENTIFIER().getText()); | 86 | module.setPrefix(ctx.IDENTIFIER().getText()); | ... | ... |
... | @@ -22,8 +22,8 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -22,8 +22,8 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
22 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 22 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
23 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 23 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
24 | 24 | ||
25 | -import static org.onosproject.yangutils.parser.ParsableDataType.PRESENCE_DATA; | 25 | +import static org.onosproject.yangutils.utils.YangConstructType.PRESENCE_DATA; |
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.CONTAINER_DATA; | 26 | +import static org.onosproject.yangutils.utils.YangConstructType.CONTAINER_DATA; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -57,8 +57,8 @@ public final class PresenceListener { | ... | @@ -57,8 +57,8 @@ public final class PresenceListener { |
57 | * rule (presence), performs validation and updates the data model | 57 | * rule (presence), performs validation and updates the data model |
58 | * tree. | 58 | * tree. |
59 | * | 59 | * |
60 | - * @param listener listener's object. | 60 | + * @param listener listener's object |
61 | - * @param ctx context object of the grammar rule. | 61 | + * @param ctx context object of the grammar rule |
62 | */ | 62 | */ |
63 | public static void processPresenceEntry(TreeWalkListener listener, | 63 | public static void processPresenceEntry(TreeWalkListener listener, |
64 | GeneratedYangParser.PresenceStatementContext ctx) { | 64 | GeneratedYangParser.PresenceStatementContext ctx) { |
... | @@ -67,7 +67,7 @@ public final class PresenceListener { | ... | @@ -67,7 +67,7 @@ public final class PresenceListener { |
67 | checkStackIsNotEmpty(listener, MISSING_HOLDER, PRESENCE_DATA, ctx.string().getText(), ENTRY); | 67 | checkStackIsNotEmpty(listener, MISSING_HOLDER, PRESENCE_DATA, ctx.string().getText(), ENTRY); |
68 | 68 | ||
69 | Parsable tmpData = listener.getParsedDataStack().peek(); | 69 | Parsable tmpData = listener.getParsedDataStack().peek(); |
70 | - if (tmpData.getParsableDataType() == CONTAINER_DATA) { | 70 | + if (tmpData.getYangConstructType() == CONTAINER_DATA) { |
71 | YangContainer container = (YangContainer) tmpData; | 71 | YangContainer container = (YangContainer) tmpData; |
72 | container.setPresence(ctx.string().getText()); | 72 | container.setPresence(ctx.string().getText()); |
73 | } else { | 73 | } else { | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListener.java
... | @@ -22,7 +22,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -22,7 +22,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
22 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 22 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
23 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 23 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
24 | 24 | ||
25 | -import static org.onosproject.yangutils.parser.ParsableDataType.REFERENCE_DATA; | 25 | +import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; |
26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -56,8 +56,8 @@ public final class ReferenceListener { | ... | @@ -56,8 +56,8 @@ public final class ReferenceListener { |
56 | * rule (reference), performs validation and updates the data model | 56 | * rule (reference), performs validation and updates the data model |
57 | * tree. | 57 | * tree. |
58 | * | 58 | * |
59 | - * @param listener listener's object. | 59 | + * @param listener listener's object |
60 | - * @param ctx context object of the grammar rule. | 60 | + * @param ctx context object of the grammar rule |
61 | */ | 61 | */ |
62 | public static void processReferenceEntry(TreeWalkListener listener, | 62 | public static void processReferenceEntry(TreeWalkListener listener, |
63 | GeneratedYangParser.ReferenceStatementContext ctx) { | 63 | GeneratedYangParser.ReferenceStatementContext ctx) { | ... | ... |
... | @@ -27,7 +27,7 @@ import java.text.ParseException; | ... | @@ -27,7 +27,7 @@ import java.text.ParseException; |
27 | import java.text.SimpleDateFormat; | 27 | import java.text.SimpleDateFormat; |
28 | import java.util.Date; | 28 | import java.util.Date; |
29 | 29 | ||
30 | -import static org.onosproject.yangutils.parser.ParsableDataType.REVISION_DATE_DATA; | 30 | +import static org.onosproject.yangutils.utils.YangConstructType.REVISION_DATE_DATA; |
31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -79,8 +79,8 @@ public final class RevisionDateListener { | ... | @@ -79,8 +79,8 @@ public final class RevisionDateListener { |
79 | * It is called when parser receives an input matching the grammar rule | 79 | * It is called when parser receives an input matching the grammar rule |
80 | * (revision date),perform validations and update the data model tree. | 80 | * (revision date),perform validations and update the data model tree. |
81 | * | 81 | * |
82 | - * @param listener Listener's object. | 82 | + * @param listener Listener's object |
83 | - * @param ctx context object of the grammar rule. | 83 | + * @param ctx context object of the grammar rule |
84 | */ | 84 | */ |
85 | public static void processRevisionDateEntry(TreeWalkListener listener, | 85 | public static void processRevisionDateEntry(TreeWalkListener listener, |
86 | GeneratedYangParser.RevisionDateStatementContext ctx) { | 86 | GeneratedYangParser.RevisionDateStatementContext ctx) { |
... | @@ -90,7 +90,7 @@ public final class RevisionDateListener { | ... | @@ -90,7 +90,7 @@ public final class RevisionDateListener { |
90 | ENTRY); | 90 | ENTRY); |
91 | 91 | ||
92 | if (!isDateValid(ctx.DATE_ARG().getText())) { | 92 | if (!isDateValid(ctx.DATE_ARG().getText())) { |
93 | - ParserException parserException = new ParserException("Input date is not correct"); | 93 | + ParserException parserException = new ParserException("YANG file error: Input date is not correct"); |
94 | parserException.setLine(ctx.DATE_ARG().getSymbol().getLine()); | 94 | parserException.setLine(ctx.DATE_ARG().getSymbol().getLine()); |
95 | parserException.setCharPosition(ctx.DATE_ARG().getSymbol().getCharPositionInLine()); | 95 | parserException.setCharPosition(ctx.DATE_ARG().getSymbol().getCharPositionInLine()); |
96 | throw parserException; | 96 | throw parserException; |
... | @@ -98,7 +98,7 @@ public final class RevisionDateListener { | ... | @@ -98,7 +98,7 @@ public final class RevisionDateListener { |
98 | 98 | ||
99 | // Obtain the node of the stack. | 99 | // Obtain the node of the stack. |
100 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 100 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
101 | - switch (tmpNode.getParsableDataType()) { | 101 | + switch (tmpNode.getYangConstructType()) { |
102 | case IMPORT_DATA: { | 102 | case IMPORT_DATA: { |
103 | YangImport importNode = (YangImport) tmpNode; | 103 | YangImport importNode = (YangImport) tmpNode; |
104 | importNode.setRevision(ctx.DATE_ARG().getText()); | 104 | importNode.setRevision(ctx.DATE_ARG().getText()); |
... | @@ -118,8 +118,8 @@ public final class RevisionDateListener { | ... | @@ -118,8 +118,8 @@ public final class RevisionDateListener { |
118 | /** | 118 | /** |
119 | * Validates the revision date. | 119 | * Validates the revision date. |
120 | * | 120 | * |
121 | - * @param dateToValidate input revision date. | 121 | + * @param dateToValidate input revision date |
122 | - * @return validation result, true for success, false for failure. | 122 | + * @return validation result, true for success, false for failure |
123 | */ | 123 | */ |
124 | private static boolean isDateValid(String dateToValidate) { | 124 | private static boolean isDateValid(String dateToValidate) { |
125 | 125 | ... | ... |
... | @@ -24,13 +24,19 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -24,13 +24,19 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
24 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 24 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
26 | 26 | ||
27 | -import static org.onosproject.yangutils.parser.ParsableDataType.REVISION_DATA; | 27 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
28 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | ||
29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
30 | +import static org.onosproject.yangutils.utils.YangConstructType.REVISION_DATA; | ||
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
31 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*; | ||
32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
33 | 35 | ||
36 | +import java.text.ParseException; | ||
37 | +import java.text.SimpleDateFormat; | ||
38 | +import java.util.Date; | ||
39 | + | ||
34 | /* | 40 | /* |
35 | * Reference: RFC6020 and YANG ANTLR Grammar | 41 | * Reference: RFC6020 and YANG ANTLR Grammar |
36 | * | 42 | * |
... | @@ -75,8 +81,8 @@ public final class RevisionListener { | ... | @@ -75,8 +81,8 @@ public final class RevisionListener { |
75 | * It is called when parser receives an input matching the grammar rule | 81 | * It is called when parser receives an input matching the grammar rule |
76 | * (revision),perform validations and update the data model tree. | 82 | * (revision),perform validations and update the data model tree. |
77 | * | 83 | * |
78 | - * @param listener Listener's object. | 84 | + * @param listener Listener's object |
79 | - * @param ctx context object of the grammar rule. | 85 | + * @param ctx context object of the grammar rule |
80 | */ | 86 | */ |
81 | public static void processRevisionEntry(TreeWalkListener listener, | 87 | public static void processRevisionEntry(TreeWalkListener listener, |
82 | GeneratedYangParser.RevisionStatementContext ctx) { | 88 | GeneratedYangParser.RevisionStatementContext ctx) { |
... | @@ -91,6 +97,13 @@ public final class RevisionListener { | ... | @@ -91,6 +97,13 @@ public final class RevisionListener { |
91 | // TODO to be implemented. | 97 | // TODO to be implemented. |
92 | } | 98 | } |
93 | 99 | ||
100 | + if (!isDateValid(ctx.DATE_ARG().getText())) { | ||
101 | + ParserException parserException = new ParserException("YANG file error: Input date is not correct"); | ||
102 | + parserException.setLine(ctx.DATE_ARG().getSymbol().getLine()); | ||
103 | + parserException.setCharPosition(ctx.DATE_ARG().getSymbol().getCharPositionInLine()); | ||
104 | + throw parserException; | ||
105 | + } | ||
106 | + | ||
94 | YangRevision revisionNode = new YangRevision(); | 107 | YangRevision revisionNode = new YangRevision(); |
95 | revisionNode.setRevDate(ctx.DATE_ARG().getText()); | 108 | revisionNode.setRevDate(ctx.DATE_ARG().getText()); |
96 | 109 | ||
... | @@ -101,8 +114,8 @@ public final class RevisionListener { | ... | @@ -101,8 +114,8 @@ public final class RevisionListener { |
101 | * It is called when parser exits from grammar rule (revision), it perform | 114 | * It is called when parser exits from grammar rule (revision), it perform |
102 | * validations and update the data model tree. | 115 | * validations and update the data model tree. |
103 | * | 116 | * |
104 | - * @param listener Listener's object. | 117 | + * @param listener Listener's object |
105 | - * @param ctx context object of the grammar rule. | 118 | + * @param ctx context object of the grammar rule |
106 | */ | 119 | */ |
107 | public static void processRevisionExit(TreeWalkListener listener, GeneratedYangParser.RevisionStatementContext | 120 | public static void processRevisionExit(TreeWalkListener listener, GeneratedYangParser.RevisionStatementContext |
108 | ctx) { | 121 | ctx) { |
... | @@ -119,7 +132,7 @@ public final class RevisionListener { | ... | @@ -119,7 +132,7 @@ public final class RevisionListener { |
119 | EXIT); | 132 | EXIT); |
120 | 133 | ||
121 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 134 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
122 | - switch (tmpNode.getParsableDataType()) { | 135 | + switch (tmpNode.getYangConstructType()) { |
123 | case MODULE_DATA: { | 136 | case MODULE_DATA: { |
124 | YangModule module = (YangModule) tmpNode; | 137 | YangModule module = (YangModule) tmpNode; |
125 | module.setRevision((YangRevision) tmpRevisionNode); | 138 | module.setRevision((YangRevision) tmpRevisionNode); |
... | @@ -144,8 +157,8 @@ public final class RevisionListener { | ... | @@ -144,8 +157,8 @@ public final class RevisionListener { |
144 | /** | 157 | /** |
145 | * Validate revision. | 158 | * Validate revision. |
146 | * | 159 | * |
147 | - * @param listener Listener's object. | 160 | + * @param listener Listener's object |
148 | - * @param ctx context object of the grammar rule. | 161 | + * @param ctx context object of the grammar rule |
149 | * @return validation result | 162 | * @return validation result |
150 | */ | 163 | */ |
151 | private static boolean validateRevision(TreeWalkListener listener, | 164 | private static boolean validateRevision(TreeWalkListener listener, |
... | @@ -153,4 +166,29 @@ public final class RevisionListener { | ... | @@ -153,4 +166,29 @@ public final class RevisionListener { |
153 | // TODO to be implemented | 166 | // TODO to be implemented |
154 | return true; | 167 | return true; |
155 | } | 168 | } |
169 | + | ||
170 | + /** | ||
171 | + * Validates the revision date. | ||
172 | + * | ||
173 | + * @param dateToValidate input revision date | ||
174 | + * @return validation result, true for success, false for failure | ||
175 | + */ | ||
176 | + private static boolean isDateValid(String dateToValidate) { | ||
177 | + | ||
178 | + if (dateToValidate == null) { | ||
179 | + return false; | ||
180 | + } | ||
181 | + | ||
182 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
183 | + sdf.setLenient(false); | ||
184 | + | ||
185 | + try { | ||
186 | + //if not valid, it will throw ParseException | ||
187 | + Date date = sdf.parse(dateToValidate); | ||
188 | + System.out.println(date); | ||
189 | + } catch (ParseException e) { | ||
190 | + return false; | ||
191 | + } | ||
192 | + return true; | ||
193 | + } | ||
156 | } | 194 | } | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.STATUS_DATA; | 26 | +import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -62,8 +62,8 @@ public final class StatusListener { | ... | @@ -62,8 +62,8 @@ public final class StatusListener { |
62 | * rule (status), performs validation and updates the data model | 62 | * rule (status), performs validation and updates the data model |
63 | * tree. | 63 | * tree. |
64 | * | 64 | * |
65 | - * @param listener listener's object. | 65 | + * @param listener listener's object |
66 | - * @param ctx context object of the grammar rule. | 66 | + * @param ctx context object of the grammar rule |
67 | */ | 67 | */ |
68 | public static void processStatusEntry(TreeWalkListener listener, | 68 | public static void processStatusEntry(TreeWalkListener listener, |
69 | GeneratedYangParser.StatusStatementContext ctx) { | 69 | GeneratedYangParser.StatusStatementContext ctx) { | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
... | @@ -20,14 +20,15 @@ import org.onosproject.yangutils.datamodel.YangSubModule; | ... | @@ -20,14 +20,15 @@ import org.onosproject.yangutils.datamodel.YangSubModule; |
20 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 20 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
21 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 21 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
22 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 22 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
23 | - | ||
24 | -import static org.onosproject.yangutils.parser.ParsableDataType.SUB_MODULE_DATA; | ||
25 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 23 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 24 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 25 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
28 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*; | 26 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
27 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
28 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
31 | +import static org.onosproject.yangutils.utils.YangConstructType.SUB_MODULE_DATA; | ||
31 | 32 | ||
32 | /* | 33 | /* |
33 | * Reference: RFC6020 and YANG ANTLR Grammar | 34 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -64,8 +65,8 @@ public final class SubModuleListener { | ... | @@ -64,8 +65,8 @@ public final class SubModuleListener { |
64 | * It is called when parser receives an input matching the grammar rule (sub | 65 | * It is called when parser receives an input matching the grammar rule (sub |
65 | * module), perform validations and update the data model tree. | 66 | * module), perform validations and update the data model tree. |
66 | * | 67 | * |
67 | - * @param listener Listener's object. | 68 | + * @param listener Listener's object |
68 | - * @param ctx context object of the grammar rule. | 69 | + * @param ctx context object of the grammar rule |
69 | */ | 70 | */ |
70 | public static void processSubModuleEntry(TreeWalkListener listener, | 71 | public static void processSubModuleEntry(TreeWalkListener listener, |
71 | GeneratedYangParser.SubModuleStatementContext ctx) { | 72 | GeneratedYangParser.SubModuleStatementContext ctx) { |
... | @@ -77,6 +78,10 @@ public final class SubModuleListener { | ... | @@ -77,6 +78,10 @@ public final class SubModuleListener { |
77 | YangSubModule yangSubModule = new YangSubModule(); | 78 | YangSubModule yangSubModule = new YangSubModule(); |
78 | yangSubModule.setName(ctx.IDENTIFIER().getText()); | 79 | yangSubModule.setName(ctx.IDENTIFIER().getText()); |
79 | 80 | ||
81 | + if (ctx.submoduleBody(0).submoduleHeaderStatement().yangVersionStatement() == null) { | ||
82 | + yangSubModule.setVersion((byte) 1); | ||
83 | + } | ||
84 | + | ||
80 | listener.getParsedDataStack().push(yangSubModule); | 85 | listener.getParsedDataStack().push(yangSubModule); |
81 | } | 86 | } |
82 | 87 | ||
... | @@ -84,8 +89,8 @@ public final class SubModuleListener { | ... | @@ -84,8 +89,8 @@ public final class SubModuleListener { |
84 | * It is called when parser exits from grammar rule (submodule), it perform | 89 | * It is called when parser exits from grammar rule (submodule), it perform |
85 | * validations and update the data model tree. | 90 | * validations and update the data model tree. |
86 | * | 91 | * |
87 | - * @param listener Listener's object. | 92 | + * @param listener Listener's object |
88 | - * @param ctx context object of the grammar rule. | 93 | + * @param ctx context object of the grammar rule |
89 | */ | 94 | */ |
90 | public static void processSubModuleExit(TreeWalkListener listener, | 95 | public static void processSubModuleExit(TreeWalkListener listener, |
91 | GeneratedYangParser.SubModuleStatementContext ctx) { | 96 | GeneratedYangParser.SubModuleStatementContext ctx) { | ... | ... |
... | @@ -58,24 +58,23 @@ import org.onosproject.yangutils.datamodel.YangType; | ... | @@ -58,24 +58,23 @@ import org.onosproject.yangutils.datamodel.YangType; |
58 | import org.onosproject.yangutils.datamodel.YangTypeDef; | 58 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
59 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 59 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
60 | import org.onosproject.yangutils.parser.Parsable; | 60 | import org.onosproject.yangutils.parser.Parsable; |
61 | -import org.onosproject.yangutils.parser.ParsableDataType; | 61 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality; |
62 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne; | ||
62 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 63 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
63 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 64 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
64 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 65 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
65 | -import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 66 | + |
66 | - | 67 | +import static org.onosproject.yangutils.utils.YangConstructType.DEFAULT_DATA; |
67 | -import static org.onosproject.yangutils.parser.ParsableDataType.DEFAULT_DATA; | 68 | +import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; |
68 | -import static org.onosproject.yangutils.parser.ParsableDataType.DESCRIPTION_DATA; | 69 | +import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; |
69 | -import static org.onosproject.yangutils.parser.ParsableDataType.REFERENCE_DATA; | 70 | +import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; |
70 | -import static org.onosproject.yangutils.parser.ParsableDataType.STATUS_DATA; | 71 | +import static org.onosproject.yangutils.utils.YangConstructType.TYPEDEF_DATA; |
71 | -import static org.onosproject.yangutils.parser.ParsableDataType.TYPEDEF_DATA; | 72 | +import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA; |
72 | -import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA; | 73 | +import static org.onosproject.yangutils.utils.YangConstructType.UNITS_DATA; |
73 | -import static org.onosproject.yangutils.parser.ParsableDataType.UNITS_DATA; | ||
74 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 74 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
75 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 75 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
76 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; | 76 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; |
77 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 77 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
78 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY; | ||
79 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 78 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
80 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 79 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
81 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 80 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
... | @@ -88,8 +87,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati | ... | @@ -88,8 +87,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati |
88 | */ | 87 | */ |
89 | public final class TypeDefListener { | 88 | public final class TypeDefListener { |
90 | 89 | ||
91 | - private static ParsableDataType yangConstruct; | ||
92 | - | ||
93 | /** | 90 | /** |
94 | * Creates a new typedef listener. | 91 | * Creates a new typedef listener. |
95 | */ | 92 | */ |
... | @@ -100,8 +97,8 @@ public final class TypeDefListener { | ... | @@ -100,8 +97,8 @@ public final class TypeDefListener { |
100 | * It is called when parser enters grammar rule (typedef), it perform | 97 | * It is called when parser enters grammar rule (typedef), it perform |
101 | * validations and updates the data model tree. | 98 | * validations and updates the data model tree. |
102 | * | 99 | * |
103 | - * @param listener listener's object. | 100 | + * @param listener listener's object |
104 | - * @param ctx context object of the grammar rule. | 101 | + * @param ctx context object of the grammar rule |
105 | */ | 102 | */ |
106 | public static void processTypeDefEntry(TreeWalkListener listener, | 103 | public static void processTypeDefEntry(TreeWalkListener listener, |
107 | GeneratedYangParser.TypedefStatementContext ctx) { | 104 | GeneratedYangParser.TypedefStatementContext ctx) { |
... | @@ -109,10 +106,8 @@ public final class TypeDefListener { | ... | @@ -109,10 +106,8 @@ public final class TypeDefListener { |
109 | // Check for stack to be non empty. | 106 | // Check for stack to be non empty. |
110 | checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPEDEF_DATA, ctx.IDENTIFIER().getText(), ENTRY); | 107 | checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPEDEF_DATA, ctx.IDENTIFIER().getText(), ENTRY); |
111 | 108 | ||
112 | - boolean result = validateSubStatementsCardinality(ctx); | 109 | + // Validate sub statement cardinality. |
113 | - if (!result) { | 110 | + validateSubStatementsCardinality(ctx); |
114 | - throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY)); | ||
115 | - } | ||
116 | 111 | ||
117 | /* | 112 | /* |
118 | * Create a derived type information, the base type must be set in type | 113 | * Create a derived type information, the base type must be set in type |
... | @@ -150,8 +145,8 @@ public final class TypeDefListener { | ... | @@ -150,8 +145,8 @@ public final class TypeDefListener { |
150 | * It is called when parser exits from grammar rule (typedef), it perform | 145 | * It is called when parser exits from grammar rule (typedef), it perform |
151 | * validations and updates the data model tree. | 146 | * validations and updates the data model tree. |
152 | * | 147 | * |
153 | - * @param listener listener's object. | 148 | + * @param listener listener's object |
154 | - * @param ctx context object of the grammar rule. | 149 | + * @param ctx context object of the grammar rule |
155 | */ | 150 | */ |
156 | public static void processTypeDefExit(TreeWalkListener listener, | 151 | public static void processTypeDefExit(TreeWalkListener listener, |
157 | GeneratedYangParser.TypedefStatementContext ctx) { | 152 | GeneratedYangParser.TypedefStatementContext ctx) { |
... | @@ -178,45 +173,15 @@ public final class TypeDefListener { | ... | @@ -178,45 +173,15 @@ public final class TypeDefListener { |
178 | /** | 173 | /** |
179 | * Validates the cardinality of typedef sub-statements as per grammar. | 174 | * Validates the cardinality of typedef sub-statements as per grammar. |
180 | * | 175 | * |
181 | - * @param ctx context object of the grammar rule. | 176 | + * @param ctx context object of the grammar rule |
182 | - * @return true/false validation success or failure. | ||
183 | */ | 177 | */ |
184 | - private static boolean validateSubStatementsCardinality(GeneratedYangParser.TypedefStatementContext ctx) { | 178 | + private static void validateSubStatementsCardinality(GeneratedYangParser.TypedefStatementContext ctx) { |
185 | - | 179 | + |
186 | - if ((!ctx.unitsStatement().isEmpty()) | 180 | + validateCardinality(ctx.unitsStatement(), UNITS_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText()); |
187 | - && (ctx.unitsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | 181 | + validateCardinality(ctx.defaultStatement(), DEFAULT_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText()); |
188 | - yangConstruct = UNITS_DATA; | 182 | + validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText()); |
189 | - return false; | 183 | + validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText()); |
190 | - } | 184 | + validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText()); |
191 | - | 185 | + validateCardinality(ctx.statusStatement(), STATUS_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText()); |
192 | - if ((!ctx.defaultStatement().isEmpty()) | ||
193 | - && (ctx.defaultStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
194 | - yangConstruct = DEFAULT_DATA; | ||
195 | - return false; | ||
196 | - } | ||
197 | - | ||
198 | - if (ctx.typeStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY) { | ||
199 | - yangConstruct = TYPE_DATA; | ||
200 | - return false; | ||
201 | - } | ||
202 | - | ||
203 | - if ((!ctx.descriptionStatement().isEmpty()) | ||
204 | - && (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
205 | - yangConstruct = DESCRIPTION_DATA; | ||
206 | - return false; | ||
207 | - } | ||
208 | - | ||
209 | - if ((!ctx.referenceStatement().isEmpty()) | ||
210 | - && (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
211 | - yangConstruct = REFERENCE_DATA; | ||
212 | - return false; | ||
213 | - } | ||
214 | - | ||
215 | - if ((!ctx.statusStatement().isEmpty()) | ||
216 | - && (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { | ||
217 | - yangConstruct = STATUS_DATA; | ||
218 | - return false; | ||
219 | - } | ||
220 | - return true; | ||
221 | } | 186 | } |
222 | } | 187 | } | ... | ... |
... | @@ -27,7 +27,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -27,7 +27,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
27 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 27 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
28 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 28 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
29 | 29 | ||
30 | -import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA; | 30 | +import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA; |
31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
... | @@ -66,8 +66,8 @@ public final class TypeListener { | ... | @@ -66,8 +66,8 @@ public final class TypeListener { |
66 | * It is called when parser receives an input matching the grammar rule | 66 | * It is called when parser receives an input matching the grammar rule |
67 | * (type), performs validation and updates the data model tree. | 67 | * (type), performs validation and updates the data model tree. |
68 | * | 68 | * |
69 | - * @param listener listener's object. | 69 | + * @param listener listener's object |
70 | - * @param ctx context object of the grammar rule. | 70 | + * @param ctx context object of the grammar rule |
71 | */ | 71 | */ |
72 | public static void processTypeEntry(TreeWalkListener listener, | 72 | public static void processTypeEntry(TreeWalkListener listener, |
73 | GeneratedYangParser.TypeStatementContext ctx) { | 73 | GeneratedYangParser.TypeStatementContext ctx) { |
... | @@ -88,8 +88,8 @@ public final class TypeListener { | ... | @@ -88,8 +88,8 @@ public final class TypeListener { |
88 | * It is called when parser exits from grammar rule (type), it perform | 88 | * It is called when parser exits from grammar rule (type), it perform |
89 | * validations and update the data model tree. | 89 | * validations and update the data model tree. |
90 | * | 90 | * |
91 | - * @param listener Listener's object. | 91 | + * @param listener Listener's object |
92 | - * @param ctx context object of the grammar rule. | 92 | + * @param ctx context object of the grammar rule |
93 | */ | 93 | */ |
94 | public static void processTypeExit(TreeWalkListener listener, | 94 | public static void processTypeExit(TreeWalkListener listener, |
95 | GeneratedYangParser.TypeStatementContext ctx) { | 95 | GeneratedYangParser.TypeStatementContext ctx) { |
... | @@ -107,7 +107,7 @@ public final class TypeListener { | ... | @@ -107,7 +107,7 @@ public final class TypeListener { |
107 | checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPE_DATA, ctx.string().getText(), EXIT); | 107 | checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPE_DATA, ctx.string().getText(), EXIT); |
108 | 108 | ||
109 | Parsable tmpData = listener.getParsedDataStack().peek(); | 109 | Parsable tmpData = listener.getParsedDataStack().peek(); |
110 | - switch (tmpData.getParsableDataType()) { | 110 | + switch (tmpData.getYangConstructType()) { |
111 | case LEAF_DATA: | 111 | case LEAF_DATA: |
112 | YangLeaf leaf = (YangLeaf) tmpData; | 112 | YangLeaf leaf = (YangLeaf) tmpData; |
113 | leaf.setDataType((YangType) type); | 113 | leaf.setDataType((YangType) type); | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.UNITS_DATA; | 26 | +import static org.onosproject.yangutils.utils.YangConstructType.UNITS_DATA; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -57,8 +57,8 @@ public final class UnitsListener { | ... | @@ -57,8 +57,8 @@ public final class UnitsListener { |
57 | * rule (units), performs validation and updates the data model | 57 | * rule (units), performs validation and updates the data model |
58 | * tree. | 58 | * tree. |
59 | * | 59 | * |
60 | - * @param listener listener's object. | 60 | + * @param listener listener's object |
61 | - * @param ctx context object of the grammar rule. | 61 | + * @param ctx context object of the grammar rule |
62 | */ | 62 | */ |
63 | public static void processUnitsEntry(TreeWalkListener listener, | 63 | public static void processUnitsEntry(TreeWalkListener listener, |
64 | GeneratedYangParser.UnitsStatementContext ctx) { | 64 | GeneratedYangParser.UnitsStatementContext ctx) { |
... | @@ -67,7 +67,7 @@ public final class UnitsListener { | ... | @@ -67,7 +67,7 @@ public final class UnitsListener { |
67 | checkStackIsNotEmpty(listener, MISSING_HOLDER, UNITS_DATA, ctx.string().getText(), ENTRY); | 67 | checkStackIsNotEmpty(listener, MISSING_HOLDER, UNITS_DATA, ctx.string().getText(), ENTRY); |
68 | 68 | ||
69 | Parsable tmpData = listener.getParsedDataStack().peek(); | 69 | Parsable tmpData = listener.getParsedDataStack().peek(); |
70 | - switch (tmpData.getParsableDataType()) { | 70 | + switch (tmpData.getYangConstructType()) { |
71 | case LEAF_DATA: | 71 | case LEAF_DATA: |
72 | YangLeaf leaf = (YangLeaf) tmpData; | 72 | YangLeaf leaf = (YangLeaf) tmpData; |
73 | leaf.setUnits(ctx.string().getText()); | 73 | leaf.setUnits(ctx.string().getText()); | ... | ... |
... | @@ -29,7 +29,7 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -29,7 +29,7 @@ package org.onosproject.yangutils.parser.impl.listeners; |
29 | import org.onosproject.yangutils.datamodel.YangEnum; | 29 | import org.onosproject.yangutils.datamodel.YangEnum; |
30 | import org.onosproject.yangutils.datamodel.YangEnumeration; | 30 | import org.onosproject.yangutils.datamodel.YangEnumeration; |
31 | import org.onosproject.yangutils.parser.Parsable; | 31 | import org.onosproject.yangutils.parser.Parsable; |
32 | -import static org.onosproject.yangutils.parser.ParsableDataType.VALUE_DATA; | 32 | +import static org.onosproject.yangutils.utils.YangConstructType.VALUE_DATA; |
33 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 33 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
34 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 34 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
35 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 35 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
... | @@ -55,8 +55,8 @@ public final class ValueListener { | ... | @@ -55,8 +55,8 @@ public final class ValueListener { |
55 | * It is called when parser receives an input matching the grammar rule | 55 | * It is called when parser receives an input matching the grammar rule |
56 | * (value), perform validations and update the data model tree. | 56 | * (value), perform validations and update the data model tree. |
57 | * | 57 | * |
58 | - * @param listener Listener's object. | 58 | + * @param listener Listener's object |
59 | - * @param ctx context object of the grammar rule. | 59 | + * @param ctx context object of the grammar rule |
60 | */ | 60 | */ |
61 | public static void processValueEntry(TreeWalkListener listener, GeneratedYangParser.ValueStatementContext ctx) { | 61 | public static void processValueEntry(TreeWalkListener listener, GeneratedYangParser.ValueStatementContext ctx) { |
62 | 62 | ||
... | @@ -65,7 +65,7 @@ public final class ValueListener { | ... | @@ -65,7 +65,7 @@ public final class ValueListener { |
65 | 65 | ||
66 | // Obtain the node of the stack. | 66 | // Obtain the node of the stack. |
67 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 67 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
68 | - switch (tmpNode.getParsableDataType()) { | 68 | + switch (tmpNode.getYangConstructType()) { |
69 | case ENUM_DATA: { | 69 | case ENUM_DATA: { |
70 | YangEnum enumNode = (YangEnum) tmpNode; | 70 | YangEnum enumNode = (YangEnum) tmpNode; |
71 | if (!isEnumValueValid(listener, ctx)) { | 71 | if (!isEnumValueValid(listener, ctx)) { |
... | @@ -86,8 +86,8 @@ public final class ValueListener { | ... | @@ -86,8 +86,8 @@ public final class ValueListener { |
86 | /** | 86 | /** |
87 | * Validates ENUM value uniqueness. | 87 | * Validates ENUM value uniqueness. |
88 | * | 88 | * |
89 | - * @param listener Listener's object. | 89 | + * @param listener Listener's object |
90 | - * @param ctx context object of the grammar rule. | 90 | + * @param ctx context object of the grammar rule |
91 | * @return validation result | 91 | * @return validation result |
92 | */ | 92 | */ |
93 | private static boolean isEnumValueValid(TreeWalkListener listener, GeneratedYangParser.ValueStatementContext ctx) { | 93 | private static boolean isEnumValueValid(TreeWalkListener listener, GeneratedYangParser.ValueStatementContext ctx) { |
... | @@ -97,7 +97,7 @@ public final class ValueListener { | ... | @@ -97,7 +97,7 @@ public final class ValueListener { |
97 | checkStackIsNotEmpty(listener, MISSING_HOLDER, VALUE_DATA, ctx.INTEGER().getText(), ENTRY); | 97 | checkStackIsNotEmpty(listener, MISSING_HOLDER, VALUE_DATA, ctx.INTEGER().getText(), ENTRY); |
98 | 98 | ||
99 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 99 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
100 | - switch (tmpNode.getParsableDataType()) { | 100 | + switch (tmpNode.getYangConstructType()) { |
101 | case ENUMERATION_DATA: { | 101 | case ENUMERATION_DATA: { |
102 | YangEnumeration yangEnumeration = (YangEnumeration) tmpNode; | 102 | YangEnumeration yangEnumeration = (YangEnumeration) tmpNode; |
103 | for (YangEnum curEnum : yangEnumeration.getEnumSet()) { | 103 | for (YangEnum curEnum : yangEnumeration.getEnumSet()) { | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.VERSION_DATA; | 26 | +import static org.onosproject.yangutils.utils.YangConstructType.VERSION_DATA; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
... | @@ -78,8 +78,8 @@ public final class VersionListener { | ... | @@ -78,8 +78,8 @@ public final class VersionListener { |
78 | * It is called when parser receives an input matching the grammar rule | 78 | * It is called when parser receives an input matching the grammar rule |
79 | * (version), perform validations and update the data model tree. | 79 | * (version), perform validations and update the data model tree. |
80 | * | 80 | * |
81 | - * @param listener Listener's object. | 81 | + * @param listener Listener's object |
82 | - * @param ctx context object of the grammar rule. | 82 | + * @param ctx context object of the grammar rule |
83 | */ | 83 | */ |
84 | public static void processVersionEntry(TreeWalkListener listener, | 84 | public static void processVersionEntry(TreeWalkListener listener, |
85 | GeneratedYangParser.YangVersionStatementContext ctx) { | 85 | GeneratedYangParser.YangVersionStatementContext ctx) { |
... | @@ -89,7 +89,7 @@ public final class VersionListener { | ... | @@ -89,7 +89,7 @@ public final class VersionListener { |
89 | 89 | ||
90 | Integer version = Integer.valueOf(ctx.INTEGER().getText()); | 90 | Integer version = Integer.valueOf(ctx.INTEGER().getText()); |
91 | if (!isVersionValid(version)) { | 91 | if (!isVersionValid(version)) { |
92 | - ParserException parserException = new ParserException("Input version not supported"); | 92 | + ParserException parserException = new ParserException("YANG file error: Input version not supported"); |
93 | parserException.setLine(ctx.INTEGER().getSymbol().getLine()); | 93 | parserException.setLine(ctx.INTEGER().getSymbol().getLine()); |
94 | parserException.setCharPosition(ctx.INTEGER().getSymbol().getCharPositionInLine()); | 94 | parserException.setCharPosition(ctx.INTEGER().getSymbol().getCharPositionInLine()); |
95 | throw parserException; | 95 | throw parserException; |
... | @@ -97,7 +97,7 @@ public final class VersionListener { | ... | @@ -97,7 +97,7 @@ public final class VersionListener { |
97 | 97 | ||
98 | // Obtain the node of the stack. | 98 | // Obtain the node of the stack. |
99 | Parsable tmpNode = listener.getParsedDataStack().peek(); | 99 | Parsable tmpNode = listener.getParsedDataStack().peek(); |
100 | - switch (tmpNode.getParsableDataType()) { | 100 | + switch (tmpNode.getYangConstructType()) { |
101 | case MODULE_DATA: { | 101 | case MODULE_DATA: { |
102 | YangModule module = (YangModule) tmpNode; | 102 | YangModule module = (YangModule) tmpNode; |
103 | module.setVersion((byte) 1); | 103 | module.setVersion((byte) 1); | ... | ... |
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 | +import org.onosproject.yangutils.datamodel.CollisionDetector; | ||
20 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
21 | +import org.onosproject.yangutils.parser.exceptions.ParserException; | ||
22 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
23 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | ||
24 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | ||
25 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | ||
26 | +import org.onosproject.yangutils.utils.YangConstructType; | ||
27 | + | ||
28 | +/** | ||
29 | + * Check the YANG construct collision in a YANG file. | ||
30 | + */ | ||
31 | +public final class ListenerCollisionDetector { | ||
32 | + | ||
33 | + /** | ||
34 | + * Creates a new listener collision. | ||
35 | + */ | ||
36 | + private ListenerCollisionDetector() { | ||
37 | + } | ||
38 | + | ||
39 | + /** | ||
40 | + * Detects that the identifiers of all these child nodes must be unique | ||
41 | + * within all cases in a choice. | ||
42 | + * | ||
43 | + * @param listener listener's object | ||
44 | + * @param line line of identifier in YANG file, required for error | ||
45 | + * reporting | ||
46 | + * @param charPosition character position of identifier in YANG file, | ||
47 | + * required for error reporting | ||
48 | + * @param identifierName name for which uniqueness is to be detected | ||
49 | + * @param constructType type of YANG construct for which collision check is | ||
50 | + * to be performed | ||
51 | + * @throws ParserException if identifier is not unique | ||
52 | + */ | ||
53 | + public static void detectCollidingChildUtil(TreeWalkListener listener, int line, int charPosition, | ||
54 | + String identifierName, YangConstructType constructType) | ||
55 | + throws ParserException { | ||
56 | + | ||
57 | + if (listener.getParsedDataStack().peek() instanceof CollisionDetector) { | ||
58 | + try { | ||
59 | + ((CollisionDetector) listener.getParsedDataStack().peek()).detectCollidingChild( | ||
60 | + identifierName, constructType); | ||
61 | + } catch (DataModelException e) { | ||
62 | + ParserException parserException = new ParserException(e.getMessage()); | ||
63 | + parserException.setLine(line); | ||
64 | + parserException.setCharPosition(charPosition); | ||
65 | + throw parserException; | ||
66 | + } | ||
67 | + } else { | ||
68 | + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, constructType, identifierName, | ||
69 | + EXIT)); | ||
70 | + } | ||
71 | + } | ||
72 | +} |
... | @@ -33,8 +33,8 @@ public enum ListenerErrorLocation { | ... | @@ -33,8 +33,8 @@ public enum ListenerErrorLocation { |
33 | /** | 33 | /** |
34 | * Returns the message corresponding to listener error location. | 34 | * Returns the message corresponding to listener error location. |
35 | * | 35 | * |
36 | - * @param errorLocation enum value for type of error. | 36 | + * @param errorLocation enum value for type of error |
37 | - * @return message corresponding to listener error location. | 37 | + * @return message corresponding to listener error location |
38 | */ | 38 | */ |
39 | public static String getErrorLocationMessage(ListenerErrorLocation errorLocation) { | 39 | public static String getErrorLocationMessage(ListenerErrorLocation errorLocation) { |
40 | 40 | ... | ... |
... | @@ -16,9 +16,9 @@ | ... | @@ -16,9 +16,9 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.parser.impl.parserutils; | 17 | package org.onosproject.yangutils.parser.impl.parserutils; |
18 | 18 | ||
19 | -import org.onosproject.yangutils.parser.ParsableDataType; | 19 | +import org.onosproject.yangutils.utils.YangConstructType; |
20 | 20 | ||
21 | -import static org.onosproject.yangutils.parser.ParsableDataType.getParsableDataType; | 21 | +import static org.onosproject.yangutils.utils.YangConstructType.getYangConstructType; |
22 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.getErrorLocationMessage; | 22 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.getErrorLocationMessage; |
23 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.getErrorType; | 23 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.getErrorType; |
24 | 24 | ||
... | @@ -37,21 +37,21 @@ public final class ListenerErrorMessageConstruction { | ... | @@ -37,21 +37,21 @@ public final class ListenerErrorMessageConstruction { |
37 | * Constructs message for error with extended information and returns the | 37 | * Constructs message for error with extended information and returns the |
38 | * same. | 38 | * same. |
39 | * | 39 | * |
40 | - * @param errorType error type needs to be set in error message. | 40 | + * @param errorType error type needs to be set in error message |
41 | - * @param parsableDataType type of parsable data in which error occurred. | 41 | + * @param yangConstructType type of parsable data in which error occurred |
42 | * @param parsableDataTypeName identifier/string of parsable data type in | 42 | * @param parsableDataTypeName identifier/string of parsable data type in |
43 | - * which error occurred. | 43 | + * which error occurred |
44 | - * @param errorLocation location where error occurred. | 44 | + * @param errorLocation location where error occurred |
45 | - * @param extendedErrorInformation extended error information. | 45 | + * @param extendedErrorInformation extended error information |
46 | - * @return constructed error message. | 46 | + * @return constructed error message |
47 | */ | 47 | */ |
48 | public static String constructExtendedListenerErrorMessage(ListenerErrorType errorType, | 48 | public static String constructExtendedListenerErrorMessage(ListenerErrorType errorType, |
49 | - ParsableDataType parsableDataType, | 49 | + YangConstructType yangConstructType, |
50 | String parsableDataTypeName, | 50 | String parsableDataTypeName, |
51 | ListenerErrorLocation errorLocation, | 51 | ListenerErrorLocation errorLocation, |
52 | String extendedErrorInformation) { | 52 | String extendedErrorInformation) { |
53 | String newErrorMessage; | 53 | String newErrorMessage; |
54 | - newErrorMessage = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName, | 54 | + newErrorMessage = constructListenerErrorMessage(errorType, yangConstructType, parsableDataTypeName, |
55 | errorLocation) | 55 | errorLocation) |
56 | + "\n" | 56 | + "\n" |
57 | + "Error Information: " | 57 | + "Error Information: " |
... | @@ -63,22 +63,22 @@ public final class ListenerErrorMessageConstruction { | ... | @@ -63,22 +63,22 @@ public final class ListenerErrorMessageConstruction { |
63 | * Constructs message for error during listener based tree walk and returns | 63 | * Constructs message for error during listener based tree walk and returns |
64 | * the same. | 64 | * the same. |
65 | * | 65 | * |
66 | - * @param errorType error type needs to be set in error message. | 66 | + * @param errorType error type needs to be set in error message |
67 | - * @param parsableDataType type of parsable data in which error occurred. | 67 | + * @param yangConstructType type of parsable data in which error occurred |
68 | * @param parsableDataTypeName identifier/string of parsable data type in | 68 | * @param parsableDataTypeName identifier/string of parsable data type in |
69 | - * which error occurred. | 69 | + * which error occurred |
70 | - * @param errorLocation location where error occurred. | 70 | + * @param errorLocation location where error occurred |
71 | - * @return constructed error message. | 71 | + * @return constructed error message |
72 | */ | 72 | */ |
73 | public static String constructListenerErrorMessage(ListenerErrorType errorType, | 73 | public static String constructListenerErrorMessage(ListenerErrorType errorType, |
74 | - ParsableDataType parsableDataType, | 74 | + YangConstructType yangConstructType, |
75 | String parsableDataTypeName, | 75 | String parsableDataTypeName, |
76 | ListenerErrorLocation errorLocation) { | 76 | ListenerErrorLocation errorLocation) { |
77 | 77 | ||
78 | String errorMessage; | 78 | String errorMessage; |
79 | 79 | ||
80 | errorMessage = "Internal parser error detected: " + getErrorType(errorType) + " " | 80 | errorMessage = "Internal parser error detected: " + getErrorType(errorType) + " " |
81 | - + getParsableDataType(parsableDataType); | 81 | + + getYangConstructType(yangConstructType); |
82 | 82 | ||
83 | if (!parsableDataTypeName.isEmpty()) { | 83 | if (!parsableDataTypeName.isEmpty()) { |
84 | errorMessage = errorMessage + " \"" + parsableDataTypeName + "\" "; | 84 | errorMessage = errorMessage + " \"" + parsableDataTypeName + "\" "; | ... | ... |
... | @@ -60,6 +60,11 @@ public enum ListenerErrorType { | ... | @@ -60,6 +60,11 @@ public enum ListenerErrorType { |
60 | INVALID_CONTENT(), | 60 | INVALID_CONTENT(), |
61 | 61 | ||
62 | /** | 62 | /** |
63 | + * Represents that the identifier collision is detected. | ||
64 | + */ | ||
65 | + IDENTIFIER_COLLISION(), | ||
66 | + | ||
67 | + /** | ||
63 | * Represents that some of earlier parsed data is not handled correctly. | 68 | * Represents that some of earlier parsed data is not handled correctly. |
64 | */ | 69 | */ |
65 | UNHANDLED_PARSED_DATA(); | 70 | UNHANDLED_PARSED_DATA(); |
... | @@ -67,8 +72,8 @@ public enum ListenerErrorType { | ... | @@ -67,8 +72,8 @@ public enum ListenerErrorType { |
67 | /** | 72 | /** |
68 | * Returns the message corresponding to listener error type. | 73 | * Returns the message corresponding to listener error type. |
69 | * | 74 | * |
70 | - * @param errorType enum value for type of error. | 75 | + * @param errorType enum value for type of error |
71 | - * @return message corresponding to listener error type. | 76 | + * @return message corresponding to listener error type |
72 | */ | 77 | */ |
73 | public static String getErrorType(ListenerErrorType errorType) { | 78 | public static String getErrorType(ListenerErrorType errorType) { |
74 | 79 | ||
... | @@ -87,6 +92,8 @@ public enum ListenerErrorType { | ... | @@ -87,6 +92,8 @@ public enum ListenerErrorType { |
87 | return "Duplicate"; | 92 | return "Duplicate"; |
88 | case INVALID_CONTENT: | 93 | case INVALID_CONTENT: |
89 | return "Invalid content in"; | 94 | return "Invalid content in"; |
95 | + case IDENTIFIER_COLLISION: | ||
96 | + return "Identifier collision detected for"; | ||
90 | case UNHANDLED_PARSED_DATA: | 97 | case UNHANDLED_PARSED_DATA: |
91 | return "Unhandled parsed data at"; | 98 | return "Unhandled parsed data at"; |
92 | default: | 99 | default: | ... | ... |
... | @@ -20,10 +20,13 @@ import org.onosproject.yangutils.datamodel.YangContainer; | ... | @@ -20,10 +20,13 @@ import org.onosproject.yangutils.datamodel.YangContainer; |
20 | import org.onosproject.yangutils.datamodel.YangList; | 20 | import org.onosproject.yangutils.datamodel.YangList; |
21 | import org.onosproject.yangutils.datamodel.YangNode; | 21 | import org.onosproject.yangutils.datamodel.YangNode; |
22 | import org.onosproject.yangutils.parser.Parsable; | 22 | import org.onosproject.yangutils.parser.Parsable; |
23 | -import org.onosproject.yangutils.parser.ParsableDataType; | ||
24 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 25 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
26 | +import org.onosproject.yangutils.utils.YangConstructType; | ||
27 | +import static org.onosproject.yangutils.utils.YangConstructType.getYangConstructType; | ||
28 | + | ||
29 | +import java.util.List; | ||
27 | 30 | ||
28 | /** | 31 | /** |
29 | * It's a utility to carry out listener validation. | 32 | * It's a utility to carry out listener validation. |
... | @@ -39,15 +42,15 @@ public final class ListenerValidation { | ... | @@ -39,15 +42,15 @@ public final class ListenerValidation { |
39 | /** | 42 | /** |
40 | * Checks parsed data stack is not empty. | 43 | * Checks parsed data stack is not empty. |
41 | * | 44 | * |
42 | - * @param listener Listener's object. | 45 | + * @param listener Listener's object |
43 | - * @param errorType error type needs to be set in error message. | 46 | + * @param errorType error type needs to be set in error message |
44 | - * @param parsableDataType type of parsable data in which error occurred. | 47 | + * @param yangConstructType type of parsable data in which error occurred |
45 | * @param parsableDataTypeName name of parsable data type in which error | 48 | * @param parsableDataTypeName name of parsable data type in which error |
46 | - * occurred. | 49 | + * occurred |
47 | - * @param errorLocation location where error occurred. | 50 | + * @param errorLocation location where error occurred |
48 | */ | 51 | */ |
49 | public static void checkStackIsNotEmpty(TreeWalkListener listener, ListenerErrorType errorType, | 52 | public static void checkStackIsNotEmpty(TreeWalkListener listener, ListenerErrorType errorType, |
50 | - ParsableDataType parsableDataType, String parsableDataTypeName, | 53 | + YangConstructType yangConstructType, String parsableDataTypeName, |
51 | ListenerErrorLocation errorLocation) { | 54 | ListenerErrorLocation errorLocation) { |
52 | if (listener.getParsedDataStack().empty()) { | 55 | if (listener.getParsedDataStack().empty()) { |
53 | /* | 56 | /* |
... | @@ -55,7 +58,7 @@ public final class ListenerValidation { | ... | @@ -55,7 +58,7 @@ public final class ListenerValidation { |
55 | * parsableDataTypeName will be null in case there is no name | 58 | * parsableDataTypeName will be null in case there is no name |
56 | * attached to parsable data type. | 59 | * attached to parsable data type. |
57 | */ | 60 | */ |
58 | - String message = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName, | 61 | + String message = constructListenerErrorMessage(errorType, yangConstructType, parsableDataTypeName, |
59 | errorLocation); | 62 | errorLocation); |
60 | throw new ParserException(message); | 63 | throw new ParserException(message); |
61 | } | 64 | } |
... | @@ -64,16 +67,15 @@ public final class ListenerValidation { | ... | @@ -64,16 +67,15 @@ public final class ListenerValidation { |
64 | /** | 67 | /** |
65 | * Checks parsed data stack is empty. | 68 | * Checks parsed data stack is empty. |
66 | * | 69 | * |
67 | - * @param listener Listener's object. | 70 | + * @param listener Listener's object |
68 | - * @param errorType error type needs to be set in error message. | 71 | + * @param errorType error type needs to be set in error message |
69 | - * @param parsableDataType type of parsable data in which error occurred. | 72 | + * @param yangConstructType type of parsable data in which error occurred |
70 | * @param parsableDataTypeName name of parsable data type in which error | 73 | * @param parsableDataTypeName name of parsable data type in which error |
71 | - * occurred. | 74 | + * occurred |
72 | - * @param errorLocation location where error occurred. | 75 | + * @param errorLocation location where error occurred |
73 | */ | 76 | */ |
74 | - | ||
75 | public static void checkStackIsEmpty(TreeWalkListener listener, ListenerErrorType errorType, | 77 | public static void checkStackIsEmpty(TreeWalkListener listener, ListenerErrorType errorType, |
76 | - ParsableDataType parsableDataType, String parsableDataTypeName, | 78 | + YangConstructType yangConstructType, String parsableDataTypeName, |
77 | ListenerErrorLocation errorLocation) { | 79 | ListenerErrorLocation errorLocation) { |
78 | 80 | ||
79 | if (!listener.getParsedDataStack().empty()) { | 81 | if (!listener.getParsedDataStack().empty()) { |
... | @@ -82,7 +84,7 @@ public final class ListenerValidation { | ... | @@ -82,7 +84,7 @@ public final class ListenerValidation { |
82 | * parsableDataTypeName will be null in case there is no name | 84 | * parsableDataTypeName will be null in case there is no name |
83 | * attached to parsable data type. | 85 | * attached to parsable data type. |
84 | */ | 86 | */ |
85 | - String message = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName, | 87 | + String message = constructListenerErrorMessage(errorType, yangConstructType, parsableDataTypeName, |
86 | errorLocation); | 88 | errorLocation); |
87 | throw new ParserException(message); | 89 | throw new ParserException(message); |
88 | } | 90 | } |
... | @@ -92,8 +94,8 @@ public final class ListenerValidation { | ... | @@ -92,8 +94,8 @@ public final class ListenerValidation { |
92 | * Returns parent node config value, if top node does not specify a config statement | 94 | * Returns parent node config value, if top node does not specify a config statement |
93 | * then default value true is returned. | 95 | * then default value true is returned. |
94 | * | 96 | * |
95 | - * @param listener listener's object. | 97 | + * @param listener listener's object |
96 | - * @return true/false parent's config value. | 98 | + * @return true/false parent's config value |
97 | */ | 99 | */ |
98 | public static boolean getParentNodeConfig(TreeWalkListener listener) { | 100 | public static boolean getParentNodeConfig(TreeWalkListener listener) { |
99 | YangNode parentNode; | 101 | YangNode parentNode; |
... | @@ -108,4 +110,71 @@ public final class ListenerValidation { | ... | @@ -108,4 +110,71 @@ public final class ListenerValidation { |
108 | } | 110 | } |
109 | return true; | 111 | return true; |
110 | } | 112 | } |
113 | + | ||
114 | + /** | ||
115 | + * Checks if a rule occurrences is as per the expected YANG grammar's | ||
116 | + * cardinality. | ||
117 | + * | ||
118 | + * @param childContext child's context | ||
119 | + * @param yangChildConstruct child construct for whom cardinality is to be | ||
120 | + * validated | ||
121 | + * @param yangParentConstruct parent construct | ||
122 | + * @param parentName parent name | ||
123 | + * @throws ParserException exception if cardinality check fails | ||
124 | + */ | ||
125 | + public static void validateCardinality(List<?> childContext, YangConstructType yangChildConstruct, | ||
126 | + YangConstructType yangParentConstruct, String parentName) | ||
127 | + throws ParserException { | ||
128 | + | ||
129 | + if (!childContext.isEmpty() && childContext.size() != 1) { | ||
130 | + ParserException parserException = new ParserException("YANG file error: Invalid cardinality of " | ||
131 | + + getYangConstructType(yangChildConstruct) + " in " + getYangConstructType(yangParentConstruct) | ||
132 | + + " \"" + parentName + "\"."); | ||
133 | + throw parserException; | ||
134 | + } | ||
135 | + } | ||
136 | + | ||
137 | + /** | ||
138 | + * Checks if a rule occurrences is exactly 1. | ||
139 | + * | ||
140 | + * @param childContext child's context | ||
141 | + * @param yangChildConstruct child construct for whom cardinality is to be | ||
142 | + * validated | ||
143 | + * @param yangParentConstruct parent construct | ||
144 | + * @param parentName parent name | ||
145 | + * @throws ParserException exception if cardinality check fails | ||
146 | + */ | ||
147 | + public static void validateCardinalityEqualsOne(List<?> childContext, YangConstructType yangChildConstruct, | ||
148 | + YangConstructType yangParentConstruct, String parentName) | ||
149 | + throws ParserException { | ||
150 | + | ||
151 | + if (childContext.isEmpty() || childContext.size() != 1) { | ||
152 | + ParserException parserException = new ParserException("YANG file error: Invalid cardinality of " | ||
153 | + + getYangConstructType(yangChildConstruct) + " in " + getYangConstructType(yangParentConstruct) | ||
154 | + + " \"" + parentName + "\"."); | ||
155 | + throw parserException; | ||
156 | + } | ||
157 | + } | ||
158 | + | ||
159 | + /** | ||
160 | + * Checks if a rule occurrences is minimum 1. | ||
161 | + * | ||
162 | + * @param childContext child's context | ||
163 | + * @param yangChildConstruct child construct for whom cardinality is to be | ||
164 | + * validated | ||
165 | + * @param yangParentConstruct parent construct | ||
166 | + * @param parentName parent name | ||
167 | + * @throws ParserException exception if cardinality check fails | ||
168 | + */ | ||
169 | + public static void validateCardinalityNonNull(List<?> childContext, YangConstructType yangChildConstruct, | ||
170 | + YangConstructType yangParentConstruct, String parentName) | ||
171 | + throws ParserException { | ||
172 | + | ||
173 | + if (childContext.isEmpty()) { | ||
174 | + ParserException parserException = new ParserException("YANG file error: Invalid cardinality of " | ||
175 | + + getYangConstructType(yangChildConstruct) + " in " + getYangConstructType(yangParentConstruct) | ||
176 | + + " \"" + parentName + "\"."); | ||
177 | + throw parserException; | ||
178 | + } | ||
179 | + } | ||
111 | } | 180 | } | ... | ... |
... | @@ -13,12 +13,12 @@ | ... | @@ -13,12 +13,12 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.yangutils.parser; | 16 | +package org.onosproject.yangutils.utils; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * ENUM to represent the type of data in parse tree. | 19 | * ENUM to represent the type of data in parse tree. |
20 | */ | 20 | */ |
21 | -public enum ParsableDataType { | 21 | +public enum YangConstructType { |
22 | /** | 22 | /** |
23 | * Identifies the module parsed data. | 23 | * Identifies the module parsed data. |
24 | */ | 24 | */ |
... | @@ -230,6 +230,11 @@ public enum ParsableDataType { | ... | @@ -230,6 +230,11 @@ public enum ParsableDataType { |
230 | POSITION_DATA, | 230 | POSITION_DATA, |
231 | 231 | ||
232 | /** | 232 | /** |
233 | + * Identifies the YANG data definition statements. | ||
234 | + */ | ||
235 | + DATA_DEF_DATA, | ||
236 | + | ||
237 | + /** | ||
233 | * Identifies the derived data type. | 238 | * Identifies the derived data type. |
234 | */ | 239 | */ |
235 | DERIVED; | 240 | DERIVED; |
... | @@ -237,12 +242,12 @@ public enum ParsableDataType { | ... | @@ -237,12 +242,12 @@ public enum ParsableDataType { |
237 | /** | 242 | /** |
238 | * Returns the YANG construct keyword corresponding to enum values. | 243 | * Returns the YANG construct keyword corresponding to enum values. |
239 | * | 244 | * |
240 | - * @param parsableDataType enum value for parsable data type. | 245 | + * @param yangConstructType enum value for parsable data type |
241 | - * @return YANG construct keyword. | 246 | + * @return YANG construct keyword |
242 | */ | 247 | */ |
243 | - public static String getParsableDataType(ParsableDataType parsableDataType) { | 248 | + public static String getYangConstructType(YangConstructType yangConstructType) { |
244 | 249 | ||
245 | - switch (parsableDataType) { | 250 | + switch (yangConstructType) { |
246 | case MODULE_DATA: | 251 | case MODULE_DATA: |
247 | return "module"; | 252 | return "module"; |
248 | case SUB_MODULE_DATA: | 253 | case SUB_MODULE_DATA: |
... | @@ -327,6 +332,8 @@ public enum ParsableDataType { | ... | @@ -327,6 +332,8 @@ public enum ParsableDataType { |
327 | return "position"; | 332 | return "position"; |
328 | case DEFAULT_DATA: | 333 | case DEFAULT_DATA: |
329 | return "default"; | 334 | return "default"; |
335 | + case DATA_DEF_DATA: | ||
336 | + return "data-def-substatements"; | ||
330 | case DERIVED: | 337 | case DERIVED: |
331 | return "derived"; | 338 | return "derived"; |
332 | default: | 339 | default: | ... | ... |
... | @@ -69,6 +69,42 @@ public class ContainerListenerTest { | ... | @@ -69,6 +69,42 @@ public class ContainerListenerTest { |
69 | } | 69 | } |
70 | 70 | ||
71 | /** | 71 | /** |
72 | + * Checks if container identifier in module is duplicate. | ||
73 | + */ | ||
74 | + @Test(expected = ParserException.class) | ||
75 | + public void processModuleDuplicateContainer() throws IOException, ParserException { | ||
76 | + | ||
77 | + YangNode node = manager.getDataModel("src/test/resources/ModuleDuplicateContainer.yang"); | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * Checks if container identifier in container is duplicate. | ||
82 | + */ | ||
83 | + @Test(expected = ParserException.class) | ||
84 | + public void processContainerDuplicateContainer() throws IOException, ParserException { | ||
85 | + | ||
86 | + YangNode node = manager.getDataModel("src/test/resources/ContainerDuplicateContainer.yang"); | ||
87 | + } | ||
88 | + | ||
89 | + /** | ||
90 | + * Checks if container identifier in list is duplicate. | ||
91 | + */ | ||
92 | + @Test(expected = ParserException.class) | ||
93 | + public void processListDuplicateContainer() throws IOException, ParserException { | ||
94 | + | ||
95 | + YangNode node = manager.getDataModel("src/test/resources/ListDuplicateContainer.yang"); | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * Checks if container identifier collides with list at same level. | ||
100 | + */ | ||
101 | + @Test(expected = ParserException.class) | ||
102 | + public void processDuplicateContainerAndList() throws IOException, ParserException { | ||
103 | + | ||
104 | + YangNode node = manager.getDataModel("src/test/resources/DuplicateContainerAndList.yang"); | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
72 | * Checks container statement as sub-statement of container. | 108 | * Checks container statement as sub-statement of container. |
73 | */ | 109 | */ |
74 | @Test | 110 | @Test |
... | @@ -170,7 +206,7 @@ public class ContainerListenerTest { | ... | @@ -170,7 +206,7 @@ public class ContainerListenerTest { |
170 | @Test | 206 | @Test |
171 | public void processContainerSubStatementCardinality() throws IOException, ParserException { | 207 | public void processContainerSubStatementCardinality() throws IOException, ParserException { |
172 | thrown.expect(ParserException.class); | 208 | thrown.expect(ParserException.class); |
173 | - thrown.expectMessage("Internal parser error detected: Invalid cardinality in reference before processing."); | 209 | + thrown.expectMessage("YANG file error: Invalid cardinality of reference in container \"valid\"."); |
174 | YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementCardinality.yang"); | 210 | YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementCardinality.yang"); |
175 | } | 211 | } |
176 | 212 | ||
... | @@ -193,4 +229,4 @@ public class ContainerListenerTest { | ... | @@ -193,4 +229,4 @@ public class ContainerListenerTest { |
193 | thrown.expectMessage("mismatched input '1valid' expecting IDENTIFIER"); | 229 | thrown.expectMessage("mismatched input '1valid' expecting IDENTIFIER"); |
194 | YangNode node = manager.getDataModel("src/test/resources/ContainerInvalidIdentifier.yang"); | 230 | YangNode node = manager.getDataModel("src/test/resources/ContainerInvalidIdentifier.yang"); |
195 | } | 231 | } |
196 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
232 | +} | ... | ... |
... | @@ -120,7 +120,7 @@ public class LeafListListenerTest { | ... | @@ -120,7 +120,7 @@ public class LeafListListenerTest { |
120 | @Test | 120 | @Test |
121 | public void processLeafListConfigInvalidCardinality() throws IOException, ParserException { | 121 | public void processLeafListConfigInvalidCardinality() throws IOException, ParserException { |
122 | thrown.expect(ParserException.class); | 122 | thrown.expect(ParserException.class); |
123 | - thrown.expectMessage("Internal parser error detected: Invalid cardinality in config before processing."); | 123 | + thrown.expectMessage("YANG file error: Invalid cardinality of config in leaf-list \"invalid-interval\"."); |
124 | YangNode node = manager.getDataModel("src/test/resources/LeafListConfigInvalidCardinality.yang"); | 124 | YangNode node = manager.getDataModel("src/test/resources/LeafListConfigInvalidCardinality.yang"); |
125 | } | 125 | } |
126 | 126 | ||
... | @@ -131,7 +131,7 @@ public class LeafListListenerTest { | ... | @@ -131,7 +131,7 @@ public class LeafListListenerTest { |
131 | @Test | 131 | @Test |
132 | public void processLeafListUnitsInvalidCardinality() throws IOException, ParserException { | 132 | public void processLeafListUnitsInvalidCardinality() throws IOException, ParserException { |
133 | thrown.expect(ParserException.class); | 133 | thrown.expect(ParserException.class); |
134 | - thrown.expectMessage("Internal parser error detected: Invalid cardinality in units before processing."); | 134 | + thrown.expectMessage("YANG file error: Invalid cardinality of units in leaf-list \"invalid-interval\"."); |
135 | YangNode node = manager.getDataModel("src/test/resources/LeafListUnitsInvalidCardinality.yang"); | 135 | YangNode node = manager.getDataModel("src/test/resources/LeafListUnitsInvalidCardinality.yang"); |
136 | } | 136 | } |
137 | 137 | ... | ... |
... | @@ -120,7 +120,7 @@ public class LeafListenerTest { | ... | @@ -120,7 +120,7 @@ public class LeafListenerTest { |
120 | @Test | 120 | @Test |
121 | public void processLeafConfigInvalidCardinality() throws IOException, ParserException { | 121 | public void processLeafConfigInvalidCardinality() throws IOException, ParserException { |
122 | thrown.expect(ParserException.class); | 122 | thrown.expect(ParserException.class); |
123 | - thrown.expectMessage("Internal parser error detected: Invalid cardinality in config before processing."); | 123 | + thrown.expectMessage("YANG file error: Invalid cardinality of config in leaf \"invalid-interval\"."); |
124 | YangNode node = manager.getDataModel("src/test/resources/LeafConfigInvalidCardinality.yang"); | 124 | YangNode node = manager.getDataModel("src/test/resources/LeafConfigInvalidCardinality.yang"); |
125 | } | 125 | } |
126 | 126 | ||
... | @@ -131,7 +131,7 @@ public class LeafListenerTest { | ... | @@ -131,7 +131,7 @@ public class LeafListenerTest { |
131 | @Test | 131 | @Test |
132 | public void processLeafMandatoryInvalidCardinality() throws IOException, ParserException { | 132 | public void processLeafMandatoryInvalidCardinality() throws IOException, ParserException { |
133 | thrown.expect(ParserException.class); | 133 | thrown.expect(ParserException.class); |
134 | - thrown.expectMessage("Internal parser error detected: Invalid cardinality in mandatory before processing."); | 134 | + thrown.expectMessage("YANG file error: Invalid cardinality of mandatory in leaf \"invalid-interval\"."); |
135 | YangNode node = manager.getDataModel("src/test/resources/LeafMandatoryInvalidCardinality.yang"); | 135 | YangNode node = manager.getDataModel("src/test/resources/LeafMandatoryInvalidCardinality.yang"); |
136 | } | 136 | } |
137 | 137 | ||
... | @@ -173,6 +173,33 @@ public class LeafListenerTest { | ... | @@ -173,6 +173,33 @@ public class LeafListenerTest { |
173 | } | 173 | } |
174 | 174 | ||
175 | /** | 175 | /** |
176 | + * Checks duplicate leaf statement as sub-statement of module. | ||
177 | + */ | ||
178 | + @Test(expected = ParserException.class) | ||
179 | + public void processModuleWithDuplicateLeaf() throws IOException, ParserException { | ||
180 | + | ||
181 | + YangNode node = manager.getDataModel("src/test/resources/ModuleWithDuplicateLeaf.yang"); | ||
182 | + } | ||
183 | + | ||
184 | + /** | ||
185 | + * Checks duplicate leaf statement as sub-statement of container. | ||
186 | + */ | ||
187 | + @Test(expected = ParserException.class) | ||
188 | + public void processContainerWithDuplicateLeaf() throws IOException, ParserException { | ||
189 | + | ||
190 | + YangNode node = manager.getDataModel("src/test/resources/ContainerWithDuplicateLeaf.yang"); | ||
191 | + } | ||
192 | + | ||
193 | + /** | ||
194 | + * Checks duplicate leaf statement as sub-statement of list. | ||
195 | + */ | ||
196 | + @Test(expected = ParserException.class) | ||
197 | + public void processListWithDuplicateLeaf() throws IOException, ParserException { | ||
198 | + | ||
199 | + YangNode node = manager.getDataModel("src/test/resources/ListWithDuplicateLeaf.yang"); | ||
200 | + } | ||
201 | + | ||
202 | + /** | ||
176 | * Checks leaf statement as sub-statement of list. | 203 | * Checks leaf statement as sub-statement of list. |
177 | */ | 204 | */ |
178 | @Test | 205 | @Test |
... | @@ -207,4 +234,4 @@ public class LeafListenerTest { | ... | @@ -207,4 +234,4 @@ public class LeafListenerTest { |
207 | assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT)); | 234 | assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT)); |
208 | assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | 235 | assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); |
209 | } | 236 | } |
210 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
237 | +} | ... | ... |
... | @@ -175,7 +175,7 @@ public class ListListenerTest { | ... | @@ -175,7 +175,7 @@ public class ListListenerTest { |
175 | @Test | 175 | @Test |
176 | public void processListSubStatementsCardinality() throws IOException, ParserException { | 176 | public void processListSubStatementsCardinality() throws IOException, ParserException { |
177 | thrown.expect(ParserException.class); | 177 | thrown.expect(ParserException.class); |
178 | - thrown.expectMessage("Internal parser error detected: Invalid cardinality in reference before processing."); | 178 | + thrown.expectMessage("YANG file error: Invalid cardinality of reference in list \"valid\"."); |
179 | YangNode node = manager.getDataModel("src/test/resources/ListSubStatementsCardinality.yang"); | 179 | YangNode node = manager.getDataModel("src/test/resources/ListSubStatementsCardinality.yang"); |
180 | } | 180 | } |
181 | 181 | ||
... | @@ -185,7 +185,7 @@ public class ListListenerTest { | ... | @@ -185,7 +185,7 @@ public class ListListenerTest { |
185 | @Test | 185 | @Test |
186 | public void processListStatementWithoutChild() throws IOException, ParserException { | 186 | public void processListStatementWithoutChild() throws IOException, ParserException { |
187 | thrown.expect(ParserException.class); | 187 | thrown.expect(ParserException.class); |
188 | - thrown.expectMessage("Internal parser error detected: Invalid cardinality in list before processing."); | 188 | + thrown.expectMessage("YANG file error: Invalid cardinality of data-def-substatements in list \"valid\"."); |
189 | YangNode node = manager.getDataModel("src/test/resources/ListStatementWithoutChild.yang"); | 189 | YangNode node = manager.getDataModel("src/test/resources/ListStatementWithoutChild.yang"); |
190 | } | 190 | } |
191 | 191 | ... | ... |
... | @@ -122,7 +122,7 @@ public class MaxElementsListenerTest { | ... | @@ -122,7 +122,7 @@ public class MaxElementsListenerTest { |
122 | @Test | 122 | @Test |
123 | public void processMaxElementsCardinality() throws IOException, ParserException { | 123 | public void processMaxElementsCardinality() throws IOException, ParserException { |
124 | thrown.expect(ParserException.class); | 124 | thrown.expect(ParserException.class); |
125 | - thrown.expectMessage("Internal parser error detected: Invalid cardinality in max-elements before processing."); | 125 | + thrown.expectMessage("YANG file error: Invalid cardinality of max-elements in leaf-list \"invalid-interval\"."); |
126 | YangNode node = manager.getDataModel("src/test/resources/MaxElementsCardinality.yang"); | 126 | YangNode node = manager.getDataModel("src/test/resources/MaxElementsCardinality.yang"); |
127 | } | 127 | } |
128 | 128 | ... | ... |
... | @@ -133,8 +133,7 @@ public class MinElementsListenerTest { | ... | @@ -133,8 +133,7 @@ public class MinElementsListenerTest { |
133 | @Test | 133 | @Test |
134 | public void processMinElementsInvalidCardinality() throws IOException, ParserException { | 134 | public void processMinElementsInvalidCardinality() throws IOException, ParserException { |
135 | thrown.expect(ParserException.class); | 135 | thrown.expect(ParserException.class); |
136 | - thrown.expectMessage( | 136 | + thrown.expectMessage("YANG file error: Invalid cardinality of min-elements in leaf-list \"invalid-interval\"."); |
137 | - "Internal parser error detected: Invalid cardinality in" + " min-elements before processing."); | ||
138 | YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidCardinality.yang"); | 137 | YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidCardinality.yang"); |
139 | } | 138 | } |
140 | 139 | ... | ... |
utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
... | @@ -157,7 +157,7 @@ public class UnitsListenerTest { | ... | @@ -157,7 +157,7 @@ public class UnitsListenerTest { |
157 | @Test | 157 | @Test |
158 | public void processUnitsStatementCardinality() throws IOException, ParserException { | 158 | public void processUnitsStatementCardinality() throws IOException, ParserException { |
159 | thrown.expect(ParserException.class); | 159 | thrown.expect(ParserException.class); |
160 | - thrown.expectMessage("Internal parser error detected: Invalid cardinality in units before processing."); | 160 | + thrown.expectMessage("YANG file error: Invalid cardinality of units in leaf \"invalid-interval\"."); |
161 | YangNode node = manager.getDataModel("src/test/resources/UnitsStatementCardinality.yang"); | 161 | YangNode node = manager.getDataModel("src/test/resources/UnitsStatementCardinality.yang"); |
162 | } | 162 | } |
163 | 163 | ... | ... |
... | @@ -64,7 +64,7 @@ public class VersionListenerTest { | ... | @@ -64,7 +64,7 @@ public class VersionListenerTest { |
64 | YangNode node = manager.getDataModel("src/test/resources/VersionNotPresent.yang"); | 64 | YangNode node = manager.getDataModel("src/test/resources/VersionNotPresent.yang"); |
65 | 65 | ||
66 | // Checks for the version value in data model tree. | 66 | // Checks for the version value in data model tree. |
67 | - assertThat(((YangModule) node).getVersion(), is((byte) 0)); | 67 | + assertThat(((YangModule) node).getVersion(), is((byte) 1)); |
68 | } | 68 | } |
69 | 69 | ||
70 | /** | 70 | /** | ... | ... |
... | @@ -20,7 +20,7 @@ import org.junit.Test; | ... | @@ -20,7 +20,7 @@ import org.junit.Test; |
20 | 20 | ||
21 | import static org.hamcrest.core.Is.is; | 21 | import static org.hamcrest.core.Is.is; |
22 | import static org.junit.Assert.assertThat; | 22 | import static org.junit.Assert.assertThat; |
23 | -import static org.onosproject.yangutils.parser.ParsableDataType.CONTACT_DATA; | 23 | +import static org.onosproject.yangutils.utils.YangConstructType.CONTACT_DATA; |
24 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 24 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
25 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; | 25 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; |
26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.datamodel.YangRevision; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.datamodel.YangRevision; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | -import static org.onosproject.yangutils.parser.ParsableDataType.YANGBASE_DATA; | 26 | +import static org.onosproject.yangutils.utils.YangConstructType.YANGBASE_DATA; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ... | ... |
1 | +module Test { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix Ant; | ||
5 | + container ospf { | ||
6 | + container valid { | ||
7 | + leaf invalid-interval { | ||
8 | + type "uint16"; | ||
9 | + units "seconds"; | ||
10 | + status current; | ||
11 | + reference "RFC 6020"; | ||
12 | + } | ||
13 | + } | ||
14 | + container valid { | ||
15 | + leaf invalid-interval { | ||
16 | + type "uint16"; | ||
17 | + units "seconds"; | ||
18 | + status current; | ||
19 | + reference "RFC 6020"; | ||
20 | + } | ||
21 | + } | ||
22 | + } | ||
23 | +} |
1 | +module Test { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix Ant; | ||
5 | + container valid { | ||
6 | + leaf invalid-interval { | ||
7 | + type "uint16"; | ||
8 | + units "seconds"; | ||
9 | + description "Interval before a route is declared invalid"; | ||
10 | + config true; | ||
11 | + mandatory true; | ||
12 | + status current; | ||
13 | + reference "RFC 6020"; | ||
14 | + } | ||
15 | + leaf valid-interval { | ||
16 | + type "uint16"; | ||
17 | + units "seconds"; | ||
18 | + description "Interval before a route is declared invalid"; | ||
19 | + config true; | ||
20 | + mandatory true; | ||
21 | + status current; | ||
22 | + reference "RFC 6020"; | ||
23 | + } | ||
24 | + leaf valid-interval { | ||
25 | + type "uint16"; | ||
26 | + units "seconds"; | ||
27 | + description "Interval before a route is declared invalid"; | ||
28 | + config true; | ||
29 | + mandatory true; | ||
30 | + status current; | ||
31 | + reference "RFC 6020"; | ||
32 | + } | ||
33 | + } | ||
34 | +} |
1 | +module Test { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix Ant; | ||
5 | + container ospf { | ||
6 | + container valid { | ||
7 | + leaf invalid-interval { | ||
8 | + type "uint16"; | ||
9 | + units "seconds"; | ||
10 | + status current; | ||
11 | + reference "RFC 6020"; | ||
12 | + } | ||
13 | + } | ||
14 | + list valid { | ||
15 | + key "process-id"; | ||
16 | + container interface { | ||
17 | + leaf invalid-interval { | ||
18 | + type "uint16"; | ||
19 | + units "seconds"; | ||
20 | + status current; | ||
21 | + reference "RFC 6020"; | ||
22 | + } | ||
23 | + } | ||
24 | + leaf process-id { | ||
25 | + type "string"; | ||
26 | + } | ||
27 | + } | ||
28 | + } | ||
29 | +} |
1 | +module Test { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix Ant; | ||
5 | + list ospf { | ||
6 | + key "process-id"; | ||
7 | + container interface { | ||
8 | + leaf invalid-interval { | ||
9 | + type "uint16"; | ||
10 | + units "seconds"; | ||
11 | + status current; | ||
12 | + reference "RFC 6020"; | ||
13 | + } | ||
14 | + } | ||
15 | + leaf process-id { | ||
16 | + type "string"; | ||
17 | + } | ||
18 | + container interface { | ||
19 | + leaf invalid-interval { | ||
20 | + type "uint16"; | ||
21 | + units "seconds"; | ||
22 | + status current; | ||
23 | + reference "RFC 6020"; | ||
24 | + } | ||
25 | + } | ||
26 | + } | ||
27 | +} |
1 | +module Test { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix Ant; | ||
5 | + list valid { | ||
6 | + key "invalid-interval"; | ||
7 | + leaf invalid-interval { | ||
8 | + type "uint16"; | ||
9 | + units "seconds"; | ||
10 | + description "Interval before a route is declared invalid"; | ||
11 | + config true; | ||
12 | + mandatory true; | ||
13 | + status current; | ||
14 | + reference "RFC 6020"; | ||
15 | + } | ||
16 | + leaf invalid-interval { | ||
17 | + type "uint16"; | ||
18 | + units "seconds"; | ||
19 | + description "Interval before a route is declared invalid"; | ||
20 | + config true; | ||
21 | + mandatory true; | ||
22 | + status current; | ||
23 | + reference "RFC 6020"; | ||
24 | + } | ||
25 | + } | ||
26 | +} |
1 | +module Test { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix Ant; | ||
5 | + container valid { | ||
6 | + leaf invalid-interval { | ||
7 | + type "uint16"; | ||
8 | + units "seconds"; | ||
9 | + status current; | ||
10 | + reference "RFC 6020"; | ||
11 | + } | ||
12 | + } | ||
13 | + container invalid { | ||
14 | + leaf invalid-interval { | ||
15 | + type "uint16"; | ||
16 | + units "seconds"; | ||
17 | + status current; | ||
18 | + reference "RFC 6020"; | ||
19 | + } | ||
20 | + } | ||
21 | + container valid { | ||
22 | + leaf invalid-interval { | ||
23 | + type "uint16"; | ||
24 | + units "seconds"; | ||
25 | + status current; | ||
26 | + reference "RFC 6020"; | ||
27 | + } | ||
28 | + } | ||
29 | +} |
1 | +module Test { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix Ant; | ||
5 | + leaf invalid-interval { | ||
6 | + type "uint16"; | ||
7 | + units "seconds"; | ||
8 | + description "Interval before a route is declared invalid"; | ||
9 | + config true; | ||
10 | + mandatory true; | ||
11 | + status current; | ||
12 | + reference "RFC 6020"; | ||
13 | + } | ||
14 | + leaf valid-interval { | ||
15 | + type "uint16"; | ||
16 | + units "seconds"; | ||
17 | + description "Interval before a route is declared invalid"; | ||
18 | + config true; | ||
19 | + mandatory true; | ||
20 | + status current; | ||
21 | + reference "RFC 6020"; | ||
22 | + } | ||
23 | + leaf invalid-interval { | ||
24 | + type "uint16"; | ||
25 | + units "seconds"; | ||
26 | + description "Interval before a route is declared invalid"; | ||
27 | + config true; | ||
28 | + mandatory true; | ||
29 | + status current; | ||
30 | + reference "RFC 6020"; | ||
31 | + } | ||
32 | +} |
-
Please register or login to post a comment