blob: 2fc88c0adfc4f6590734ad2a35769fc8467684ff [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 */
274 public List<YangImport> getImportList() {
275 return importList;
276 }
277
278 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530279 * Adds the imported module information to the import list.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530280 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530281 * @param importedModule module being imported
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530282 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530283 public void addToImportList(YangImport importedModule) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530284 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530285 }
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530286
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530287 @Override
288 public void setImportList(List<YangImport> importList) {
289 this.importList = importList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530290 }
291
292 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530293 * Returns the list of included sub modules.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530294 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530295 * @return the included list of sub modules
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530296 */
297 public List<YangInclude> getIncludeList() {
298 return includeList;
299 }
300
301 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530302 * Adds the included sub module information to the include list.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530303 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530304 * @param includeModule submodule being included
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530305 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530306 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530307 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530308 }
309
310 @Override
311 public void setIncludeList(List<YangInclude> includeList) {
312 this.includeList = includeList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530313 }
314
315 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530316 * Returns the list of leaves in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530317 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530318 * @return the list of leaves
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530319 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530320 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530321 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530322 return listOfLeaf;
323 }
324
325 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530326 * Adds a leaf in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530327 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530328 * @param leaf the leaf to be added
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530329 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530330 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530331 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530332 getListOfLeaf().add(leaf);
333 }
334
335 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530336 * Returns the list of leaf-list from module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530337 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530338 * @return the list of leaf-list
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530339 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530340 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530341 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530342 return listOfLeafList;
343 }
344
345 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530346 * Adds a leaf-list in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530347 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530348 * @param leafList the leaf-list to be added
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530349 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530350 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530351 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530352 getListOfLeafList().add(leafList);
353 }
354
355 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530356 * Returns the name space of module elements.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530357 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530358 * @return the nameSpace
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530359 */
360 public YangNameSpace getNameSpace() {
361 return nameSpace;
362 }
363
364 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530365 * Sets the name space of module elements.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530366 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530367 * @param nameSpace the nameSpace to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530368 */
369 public void setNameSpace(YangNameSpace nameSpace) {
370 this.nameSpace = nameSpace;
371 }
372
373 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530374 * Returns the modules organization.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530375 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530376 * @return the organization
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530377 */
378 public String getOrganization() {
379 return organization;
380 }
381
382 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530383 * Sets the modules organization.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530384 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530385 * @param org the organization to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530386 */
387 public void setOrganization(String org) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530388 organization = org;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530389 }
390
391 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530392 * Returns the prefix.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530393 *
394 * @return the prefix
395 */
396 public String getPrefix() {
397 return prefix;
398 }
399
400 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530401 * Sets the prefix.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530402 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530403 * @param prefix the prefix to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530404 */
405 public void setPrefix(String prefix) {
406 this.prefix = prefix;
407 }
408
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530409 @Override
410 public void resolveSelfFileLinking() throws DataModelException {
411 // Get the list to be resolved.
412 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
413 // Resolve linking for a resolution list.
414 resolveLinkingForResolutionList(resolutionList, this);
415 }
416
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530417 @Override
418 public void resolveInterFileLinking() throws DataModelException {
419 // Get the list to be resolved.
420 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
421 // Resolve linking for a resolution list.
422 linkInterFileReferences(resolutionList, this);
423 }
424
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530425 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530426 * Returns the textual reference.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530427 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530428 * @return the reference
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530429 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530430 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530431 public String getReference() {
432 return reference;
433 }
434
435 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530436 * Sets the textual reference.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530437 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530438 * @param reference the reference to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530439 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530440 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530441 public void setReference(String reference) {
442 this.reference = reference;
443 }
444
445 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530446 * Returns the revision.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530447 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530448 * @return the revision
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530449 */
450 public YangRevision getRevision() {
451 return revision;
452 }
453
454 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530455 * Sets the revision.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530456 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530457 * @param revision the revision to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530458 */
459 public void setRevision(YangRevision revision) {
460 this.revision = revision;
461 }
462
463 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530464 * Returns the version.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530465 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530466 * @return the version
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530467 */
468 public byte getVersion() {
469 return version;
470 }
471
472 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530473 * Sets the version.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530474 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530475 * @param version the version to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530476 */
477 public void setVersion(byte version) {
478 this.version = version;
479 }
480
481 /**
482 * Returns the type of the parsed data.
483 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530484 * @return returns MODULE_DATA
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530485 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530486 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530487 public YangConstructType getYangConstructType() {
488 return YangConstructType.MODULE_DATA;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530489 }
490
491 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530492 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530493 *
494 * @throws DataModelException a violation of data model rules
495 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530496 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530497 public void validateDataOnEntry() throws DataModelException {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530498 /*
499 * Module is root in the data model tree, hence there is no entry
500 * validation
501 */
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530502 }
503
504 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530505 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530506 *
507 * @throws DataModelException a violation of data model rules
508 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530509 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530510 public void validateDataOnExit() throws DataModelException {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530511 /*
512 * TODO: perform symbol linking for the imported or included YANG info.
513 * TODO: perform symbol resolution for referred YANG entities.
514 */
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530515 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530516
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530517 @Override
518 public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
519 // Asks helper to detect colliding child.
520 detectCollidingChildUtil(identifierName, dataType, this);
521 }
522
523 @Override
524 public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
525 // Not required as module doesn't have any parent.
526 }
Vinod Kumar S38046502016-03-23 15:30:27 +0530527
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530528 @Override
529 public List<YangResolutionInfo> getUnresolvedResolutionList() {
530 return unresolvedResolutionList;
531 }
532
533 @Override
534 public void addToResolutionList(YangResolutionInfo resolutionInfo) {
535 unresolvedResolutionList.add(resolutionInfo);
536 }
537
538 @Override
539 public void setResolutionList(List<YangResolutionInfo> resolutionList) {
540 unresolvedResolutionList = resolutionList;
541 }
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530542
543 @Override
544 public void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet)
545 throws LinkerException {
546 Iterator<YangImport> importInfoIterator = getImportList().iterator();
547 // Run through the imported list to add references.
548 while (importInfoIterator.hasNext()) {
549 YangImport yangImport = importInfoIterator.next();
550 try {
551 yangImport.addReferenceToImport(yangFileInfoSet);
552 } catch (DataModelException e) {
553 throw new LinkerException(e.getMessage());
554 }
555 }
556 }
557
558 @Override
559 public void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet)
560 throws LinkerException {
561 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
562 // Run through the included list to add references.
563 while (includeInfoIterator.hasNext()) {
564 YangInclude yangInclude = includeInfoIterator.next();
565 YangSubModule subModule = null;
566 try {
567 subModule = yangInclude.addReferenceToInclude(yangFileInfoSet);
568 } catch (DataModelException e) {
569 throw new LinkerException(e.getMessage());
570 }
571 // Check if the referred sub-modules parent is self
572 if (!(subModule.getBelongsTo().getModuleNode() == this)) {
573 try {
574 yangInclude.reportIncludeError();
575 } catch (DataModelException e) {
576 throw new LinkerException(e.getMessage());
577 }
578 }
579 }
580 }
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530581}