blob: 26df1f5eeeb32f37103d4cab65b2371496b89d52 [file] [log] [blame]
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +05303 *
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 */
16package org.onosproject.yangutils.datamodel;
17
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053018import java.util.Iterator;
Bharat saraswal2f00b4b2016-03-04 20:08:09 +053019import java.util.LinkedList;
20import java.util.List;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053021import java.util.Set;
Bharat saraswal2f00b4b2016-03-04 20:08:09 +053022import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053023import org.onosproject.yangutils.linker.exceptions.LinkerException;
24import org.onosproject.yangutils.linker.impl.YangReferenceResolver;
25import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053026import org.onosproject.yangutils.parser.Parsable;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053027import org.onosproject.yangutils.plugin.manager.YangFileInfo;
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053028import org.onosproject.yangutils.utils.YangConstructType;
Vinod Kumar S38046502016-03-23 15:30:27 +053029
30import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053031import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.linkInterFileReferences;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053032import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053033
34/*-
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053035 * Reference:RFC 6020.
36 * The "module" statement defines the module's name,
37 * and groups all statements that belong to the module together. The "module"
38 * statement's argument is the name of the module, followed by a block of
39 * sub statements that hold detailed module information.
40 * The module's sub statements
41 *
42 * +--------------+---------+-------------+-----------------------+
43 * |sub statement | section | cardinality | data model mapping |
44 * +--------------+---------+-------------+-----------------------+
45 * | anyxml | 7.10 | 0..n | not supported |
46 * | augment | 7.15 | 0..n | child nodes |
47 * | choice | 7.9 | 0..n | child nodes |
48 * | contact | 7.1.8 | 0..1 | string |
49 * | container | 7.5 | 0..n | child nodes |
50 * | description | 7.19.3 | 0..1 | string |
51 * | deviation | 7.18.3 | 0..n | TODO |
52 * | extension | 7.17 | 0..n | TODO |
53 * | feature | 7.18.1 | 0..n | TODO |
54 * | grouping | 7.11 | 0..n | child nodes |
55 * | identity | 7.16 | 0..n | TODO |
56 * | import | 7.1.5 | 0..n | list of import info |
57 * | include | 7.1.6 | 0..n | list of include info |
58 * | leaf | 7.6 | 0..n | list of leaf info |
59 * | leaf-list | 7.7 | 0..n | list of leaf-list info|
60 * | list | 7.8 | 0..n | child nodes |
61 * | namespace | 7.1.3 | 1 | string/uri |
62 * | notification | 7.14 | 0..n | TODO |
63 * | organization | 7.1.7 | 0..1 | string |
64 * | prefix | 7.1.4 | 1 | string |
65 * | reference | 7.19.4 | 0..1 | string |
66 * | revision | 7.1.9 | 0..n | revision |
67 * | rpc | 7.13 | 0..n | TODO |
68 * | typedef | 7.3 | 0..n | child nodes |
69 * | uses | 7.12 | 0..n | child nodes |
70 * | YANG-version | 7.1.2 | 0..1 | int |
71 * +--------------+---------+-------------+-----------------------+
72 */
73
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053074/**
Bharat saraswald9822e92016-04-05 15:13:44 +053075 * Represents data model node to maintain information defined in YANG module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053076 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053077public class YangModule extends YangNode
Vinod Kumar Se4b9b0c2016-04-30 21:09:15 +053078 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
79 RpcNotificationContainer {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053080
81 /**
82 * Name of the module.
83 */
84 private String name;
85
86 /**
87 * Reference:RFC 6020.
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053088 * <p>
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053089 * The "contact" statement provides contact information for the module. The
90 * argument is a string that is used to specify contact information for the
91 * person or persons to whom technical queries concerning this module should
92 * be sent, such as their name, postal address, telephone number, and
93 * electronic mail address.
94 */
95 private String contact;
96
97 /**
98 * Reference:RFC 6020.
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053099 * <p>
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530100 * The "description" statement takes as an argument a string that contains a
101 * human-readable textual description of this definition. The text is
102 * provided in a language (or languages) chosen by the module developer; for
103 * the sake of interoperability.
104 */
105 private String description;
106
107 /**
108 * List of YANG modules imported.
109 */
110 private List<YangImport> importList;
111
112 /**
113 * List of YANG sub-modules included.
114 */
115 private List<YangInclude> includeList;
116
117 /**
118 * List of leaves at root level in the module.
119 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530120 private List<YangLeaf> listOfLeaf;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530121
122 /**
123 * List of leaf-lists at root level in the module.
124 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530125 private List<YangLeafList> listOfLeafList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530126
127 /**
128 * Name space of the module.
129 */
130 private YangNameSpace nameSpace;
131
132 /**
133 * Reference:RFC 6020.
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530134 * <p>
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530135 * The "organization" statement defines the party responsible for this
136 * module. The argument is a string that is used to specify a textual
137 * description of the organization(s) under whose auspices this module was
138 * developed.
139 */
140 private String organization;
141
142 /**
143 * Prefix to refer to the objects in module.
144 */
145 private String prefix;
146
147 /**
148 * Reference of the module.
149 */
150 private String reference;
151
152 /**
153 * Revision info of the module.
154 */
155 private YangRevision revision;
156
157 /**
158 * YANG version.
159 */
160 private byte version;
161
Vinod Kumar S71cba682016-02-25 15:52:16 +0530162 /*-
Vinod Kumar Sc4216002016-03-03 19:55:30 +0530163 * Reference RFC 6020.
164 *
Vinod Kumar S71cba682016-02-25 15:52:16 +0530165 * Nested typedefs and groupings.
166 * Typedefs and groupings may appear nested under many YANG statements,
167 * allowing these to be lexically scoped by the hierarchy under which
168 * they appear. This allows types and groupings to be defined near
169 * where they are used, rather than placing them at the top level of the
170 * hierarchy. The close proximity increases readability.
171 *
172 * Scoping also allows types to be defined without concern for naming
173 * conflicts between types in different submodules. Type names can be
174 * specified without adding leading strings designed to prevent name
175 * collisions within large modules.
176 *
177 * Finally, scoping allows the module author to keep types and groupings
178 * private to their module or submodule, preventing their reuse. Since
179 * only top-level types and groupings (i.e., those appearing as
180 * sub-statements to a module or submodule statement) can be used outside
181 * the module or submodule, the developer has more control over what
182 * pieces of their module are presented to the outside world, supporting
183 * the need to hide internal information and maintaining a boundary
184 * between what is shared with the outside world and what is kept
185 * private.
186 *
187 * Scoped definitions MUST NOT shadow definitions at a higher scope. A
188 * type or grouping cannot be defined if a higher level in the schema
189 * hierarchy has a definition with a matching identifier.
190 *
191 * A reference to an unprefixed type or grouping, or one which uses the
192 * prefix of the current module, is resolved by locating the closest
193 * matching "typedef" or "grouping" statement among the immediate
194 * sub-statements of each ancestor statement.
195 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530196 private List<YangResolutionInfo> unresolvedResolutionList;
Vinod Kumar S71cba682016-02-25 15:52:16 +0530197
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530198 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530199 * Creates a YANG node of module type.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530200 */
201 public YangModule() {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530202
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530203 super(YangNodeType.MODULE_NODE);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530204 unresolvedResolutionList = new LinkedList<YangResolutionInfo>();
205 importList = new LinkedList<YangImport>();
206 includeList = new LinkedList<YangInclude>();
207 listOfLeaf = new LinkedList<YangLeaf>();
208 listOfLeafList = new LinkedList<YangLeafList>();
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530209 }
210
Vinod Kumar S71cba682016-02-25 15:52:16 +0530211 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530212 * Returns name of the module.
Vinod Kumar S71cba682016-02-25 15:52:16 +0530213 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530214 * @return module name
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530215 */
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530216 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530217 public String getName() {
218 return name;
219 }
220
Vinod Kumar S71cba682016-02-25 15:52:16 +0530221 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530222 * Sets module name.
Vinod Kumar S71cba682016-02-25 15:52:16 +0530223 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530224 * @param moduleName module name
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530225 */
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530226 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530227 public void setName(String moduleName) {
228 name = moduleName;
229 }
230
231 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530232 * Returns the contact details of the module owner.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530233 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530234 * @return the contact details of YANG owner
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530235 */
236 public String getContact() {
237 return contact;
238 }
239
240 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530241 * Sets the contact details of the module owner.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530242 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530243 * @param contact the contact details of YANG owner
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530244 */
245 public void setContact(String contact) {
246 this.contact = contact;
247 }
248
249 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530250 * Returns the description of module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530251 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530252 * @return the description of YANG module
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530253 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530254 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530255 public String getDescription() {
256 return description;
257 }
258
259 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530260 * Sets the description of module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530261 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530262 * @param description set the description of YANG module
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530263 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530264 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530265 public void setDescription(String description) {
266 this.description = description;
267 }
268
269 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530270 * Returns the list of imported modules.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530271 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530272 * @return the list of imported modules
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530273 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530274 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530275 public List<YangImport> getImportList() {
276 return importList;
277 }
278
279 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530280 * Adds the imported module information to the import list.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530281 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530282 * @param importedModule module being imported
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530283 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530284 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530285 public void addToImportList(YangImport importedModule) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530286 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530287 }
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530288
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530289 @Override
290 public void setImportList(List<YangImport> importList) {
291 this.importList = importList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530292 }
293
294 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530295 * Returns the list of included sub modules.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530296 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530297 * @return the included list of sub modules
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530298 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530299 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530300 public List<YangInclude> getIncludeList() {
301 return includeList;
302 }
303
304 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530305 * Adds the included sub module information to the include list.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530306 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530307 * @param includeModule submodule being included
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530308 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530309 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530310 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530311 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530312 }
313
314 @Override
315 public void setIncludeList(List<YangInclude> includeList) {
316 this.includeList = includeList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530317 }
318
319 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530320 * Returns the list of leaves in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530321 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530322 * @return the list of leaves
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530323 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530324 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530325 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530326 return listOfLeaf;
327 }
328
329 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530330 * Adds a leaf in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530331 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530332 * @param leaf the leaf to be added
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530333 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530334 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530335 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530336 getListOfLeaf().add(leaf);
337 }
338
339 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530340 * Returns the list of leaf-list from module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530341 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530342 * @return the list of leaf-list
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530343 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530344 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530345 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530346 return listOfLeafList;
347 }
348
349 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530350 * Adds a leaf-list in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530351 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530352 * @param leafList the leaf-list to be added
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530353 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530354 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530355 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530356 getListOfLeafList().add(leafList);
357 }
358
359 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530360 * Returns the name space of module elements.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530361 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530362 * @return the nameSpace
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530363 */
364 public YangNameSpace getNameSpace() {
365 return nameSpace;
366 }
367
368 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530369 * Sets the name space of module elements.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530370 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530371 * @param nameSpace the nameSpace to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530372 */
373 public void setNameSpace(YangNameSpace nameSpace) {
374 this.nameSpace = nameSpace;
375 }
376
377 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530378 * Returns the modules organization.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530379 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530380 * @return the organization
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530381 */
382 public String getOrganization() {
383 return organization;
384 }
385
386 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530387 * Sets the modules organization.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530388 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530389 * @param org the organization to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530390 */
391 public void setOrganization(String org) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530392 organization = org;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530393 }
394
395 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530396 * Returns the prefix.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530397 *
398 * @return the prefix
399 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530400 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530401 public String getPrefix() {
402 return prefix;
403 }
404
405 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530406 * Sets the prefix.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530407 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530408 * @param prefix the prefix to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530409 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530410 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530411 public void setPrefix(String prefix) {
412 this.prefix = prefix;
413 }
414
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530415 @Override
416 public void resolveSelfFileLinking() throws DataModelException {
417 // Get the list to be resolved.
418 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
419 // Resolve linking for a resolution list.
420 resolveLinkingForResolutionList(resolutionList, this);
421 }
422
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530423 @Override
424 public void resolveInterFileLinking() throws DataModelException {
425 // Get the list to be resolved.
426 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
427 // Resolve linking for a resolution list.
428 linkInterFileReferences(resolutionList, this);
429 }
430
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530431 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530432 * Returns the textual reference.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530433 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530434 * @return the reference
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530435 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530436 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530437 public String getReference() {
438 return reference;
439 }
440
441 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530442 * Sets the textual reference.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530443 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530444 * @param reference the reference to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530445 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530446 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530447 public void setReference(String reference) {
448 this.reference = reference;
449 }
450
451 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530452 * Returns the revision.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530453 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530454 * @return the revision
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530455 */
456 public YangRevision getRevision() {
457 return revision;
458 }
459
460 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530461 * Sets the revision.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530462 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530463 * @param revision the revision to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530464 */
465 public void setRevision(YangRevision revision) {
466 this.revision = revision;
467 }
468
469 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530470 * Returns the version.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530471 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530472 * @return the version
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530473 */
474 public byte getVersion() {
475 return version;
476 }
477
478 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530479 * Sets the version.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530480 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530481 * @param version the version to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530482 */
483 public void setVersion(byte version) {
484 this.version = version;
485 }
486
487 /**
488 * Returns the type of the parsed data.
489 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530490 * @return returns MODULE_DATA
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530491 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530492 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530493 public YangConstructType getYangConstructType() {
494 return YangConstructType.MODULE_DATA;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530495 }
496
497 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530498 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530499 *
500 * @throws DataModelException a violation of data model rules
501 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530502 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530503 public void validateDataOnEntry() throws DataModelException {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530504 /*
505 * Module is root in the data model tree, hence there is no entry
506 * validation
507 */
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530508 }
509
510 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530511 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530512 *
513 * @throws DataModelException a violation of data model rules
514 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530515 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530516 public void validateDataOnExit() throws DataModelException {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530517 /*
518 * TODO: perform symbol linking for the imported or included YANG info.
519 * TODO: perform symbol resolution for referred YANG entities.
520 */
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530521 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530522
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530523 @Override
524 public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
525 // Asks helper to detect colliding child.
526 detectCollidingChildUtil(identifierName, dataType, this);
527 }
528
529 @Override
530 public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
531 // Not required as module doesn't have any parent.
532 }
Vinod Kumar S38046502016-03-23 15:30:27 +0530533
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530534 @Override
535 public List<YangResolutionInfo> getUnresolvedResolutionList() {
536 return unresolvedResolutionList;
537 }
538
539 @Override
540 public void addToResolutionList(YangResolutionInfo resolutionInfo) {
541 unresolvedResolutionList.add(resolutionInfo);
542 }
543
544 @Override
545 public void setResolutionList(List<YangResolutionInfo> resolutionList) {
546 unresolvedResolutionList = resolutionList;
547 }
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530548
549 @Override
550 public void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet)
551 throws LinkerException {
552 Iterator<YangImport> importInfoIterator = getImportList().iterator();
553 // Run through the imported list to add references.
554 while (importInfoIterator.hasNext()) {
555 YangImport yangImport = importInfoIterator.next();
556 try {
557 yangImport.addReferenceToImport(yangFileInfoSet);
558 } catch (DataModelException e) {
559 throw new LinkerException(e.getMessage());
560 }
561 }
562 }
563
564 @Override
565 public void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet)
566 throws LinkerException {
567 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
568 // Run through the included list to add references.
569 while (includeInfoIterator.hasNext()) {
570 YangInclude yangInclude = includeInfoIterator.next();
571 YangSubModule subModule = null;
572 try {
573 subModule = yangInclude.addReferenceToInclude(yangFileInfoSet);
574 } catch (DataModelException e) {
575 throw new LinkerException(e.getMessage());
576 }
577 // Check if the referred sub-modules parent is self
578 if (!(subModule.getBelongsTo().getModuleNode() == this)) {
579 try {
580 yangInclude.reportIncludeError();
581 } catch (DataModelException e) {
582 throw new LinkerException(e.getMessage());
583 }
584 }
585 }
586 }
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530587}