Committed by
Gerrit Code Review
YANG construct collision detection framework added
Change-Id: I1458f9e3192641f3f90c444798c31a64536ffa5d
Showing
89 changed files
with
952 additions
and
786 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 | +} | ... | ... |
This diff is collapsed. Click to expand it.
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 | } | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListener.java
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment