blob: 04b7cfbbb8ea3250dc3ee4c66abd29720e9a9a75 [file] [log] [blame]
Vinod Kumar S67e7be62016-02-11 20:13:28 +05301/*
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 */
16package org.onosproject.yangutils.datamodel;
17
18import java.util.LinkedList;
19import java.util.List;
20
21import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22import org.onosproject.yangutils.parser.Parsable;
23import org.onosproject.yangutils.parser.ParsableDataType;
Bharat saraswal594bc6d2016-02-22 22:15:21 +053024import org.onosproject.yangutils.translator.CachedFileHandle;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053025
26/*
27 * Reference RFC 6020.
28 *
29 * While the primary unit in YANG is a module, a YANG module can itself
30 * be constructed out of several submodules. Submodules allow a module
31 * designer to split a complex model into several pieces where all the
32 * submodules contribute to a single namespace, which is defined by the
33 * module that includes the submodules.
34 *
35 * The "submodule" statement defines the submodule's name, and groups
36 * all statements that belong to the submodule together. The
37 * "submodule" statement's argument is the name of the submodule,
38 * followed by a block of sub-statements that hold detailed submodule
39 * information.
40 *
41 * The submodule's sub-statements
42 *
43 * +--------------+---------+-------------+------------------+
44 * | substatement | section | cardinality |data model mapping|
45 * +--------------+---------+-------------+------------------+
46 * | anyxml | 7.10 | 0..n | - not supported |
47 * | augment | 7.15 | 0..n | - child nodes |
48 * | belongs-to | 7.2.2 | 1 | - YangBelongsTo |
49 * | choice | 7.9 | 0..n | - child nodes |
50 * | contact | 7.1.8 | 0..1 | - string |
51 * | container | 7.5 | 0..n | - child nodes |
52 * | description | 7.19.3 | 0..1 | - string |
53 * | deviation | 7.18.3 | 0..n | - TODO |
54 * | extension | 7.17 | 0..n | - TODO |
55 * | feature | 7.18.1 | 0..n | - TODO |
56 * | grouping | 7.11 | 0..n | - child nodes |
57 * | identity | 7.16 | 0..n | - TODO |
58 * | import | 7.1.5 | 0..n | - YangImport |
59 * | include | 7.1.6 | 0..n | - YangInclude |
60 * | leaf | 7.6 | 0..n | - YangLeaf |
61 * | leaf-list | 7.7 | 0..n | - YangLeafList |
62 * | list | 7.8 | 0..n | - child nodes |
63 * | notification | 7.14 | 0..n | - TODO |
64 * | organization | 7.1.7 | 0..1 | - string |
65 * | reference | 7.19.4 | 0..1 | - string |
66 * | revision | 7.1.9 | 0..n | - string |
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/**
74 * Data model node to maintain information defined in YANG sub-module.
75 */
Bharat saraswal870c56f2016-02-20 21:57:16 +053076public class YangSubModule extends YangNode implements YangLeavesHolder, YangDesc, YangReference, Parsable {
Vinod Kumar S67e7be62016-02-11 20:13:28 +053077
78 /**
79 * Name of sub module.
80 */
81 private String name;
82
83 /**
84 * Module to which it belongs to.
85 */
86 private YangBelongsTo belongsTo;
87
88 /**
89 * Reference RFC 6020.
90 *
91 * The "contact" statement provides contact information for the module. The
92 * argument is a string that is used to specify contact information for the
93 * person or persons to whom technical queries concerning this module should
94 * be sent, such as their name, postal address, telephone number, and
95 * electronic mail address.
96 */
97 private String contact;
98
99 /**
100 * Description.
101 */
102 private String description;
103
104 /**
105 * List of YANG modules imported.
106 */
107 private List<YangImport> importList;
108
109 /**
110 * List of YANG sub-modules included.
111 */
112 private List<YangInclude> includeList;
113
114 /**
115 * List of leaves at root level in the sub-module.
116 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530117 private List<YangLeaf<?>> listOfLeaf;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530118
119 /**
120 * List of leaf-lists at root level in the sub-module.
121 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530122 private List<YangLeafList<?>> listOfLeafList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530123
124 /**
125 * organization owner of the sub-module.
126 */
127 private String organization;
128
129 /**
130 * reference of the sub-module.
131 */
132 private String reference;
133
134 /**
135 * revision info of the sub-module.
136 */
137 private YangRevision revision;
138
139 /**
140 * YANG version.
141 */
142 private byte version;
143
144 /**
145 * Create a sub module node.
146 */
147 public YangSubModule() {
148 super(YangNodeType.SUB_MODULE_NODE);
149 }
150
151 /* (non-Javadoc)
152 * @see org.onosproject.yangutils.datamodel.YangNode#getName()
153 */
154 @Override
155 public String getName() {
156 return name;
157 }
158
159 /* (non-Javadoc)
160 * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
161 */
162 @Override
163 public void setName(String subModuleName) {
164 name = subModuleName;
165 }
166
167 /**
168 * Get the module info.
169 *
170 * @return the belongs to info
171 */
172 public YangBelongsTo getBelongsTo() {
173 return belongsTo;
174 }
175
176 /**
177 * Set the module info.
178 *
179 * @param belongsTo module info to set.
180 */
181 public void setBelongsTo(YangBelongsTo belongsTo) {
182 this.belongsTo = belongsTo;
183 }
184
185 /**
186 * Get the contact.
187 *
188 * @return the contact.
189 */
190 public String getContact() {
191 return contact;
192 }
193
194 /**
195 * Set the contact.
196 *
197 * @param contact the contact to set
198 */
199 public void setContact(String contact) {
200 this.contact = contact;
201 }
202
203 /**
204 * Get the description.
205 *
206 * @return the description.
207 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530208 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530209 public String getDescription() {
210 return description;
211 }
212
213 /**
214 * Set the description.
215 *
216 * @param description set the description.
217 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530218 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530219 public void setDescription(String description) {
220 this.description = description;
221 }
222
223 /**
224 * Get the list of imported modules.
225 *
226 * @return the list of imported modules.
227 */
228 public List<YangImport> getImportList() {
229 return importList;
230 }
231
232 /**
233 * prevent setting the import list from outside.
234 *
235 * @param importList the import list to set.
236 */
237 private void setImportList(List<YangImport> importList) {
238 this.importList = importList;
239 }
240
241 /**
242 * Add the imported module information to the import list.
243 *
244 * @param importedModule module being imported.
245 */
246 public void addImportedInfo(YangImport importedModule) {
247
248 if (getImportList() == null) {
249 setImportList(new LinkedList<YangImport>());
250 }
251
252 getImportList().add(importedModule);
253
254 return;
255 }
256
257 /**
258 * Get the list of included sub modules.
259 *
260 * @return the included list of sub modules.
261 */
262 public List<YangInclude> getIncludeList() {
263 return includeList;
264 }
265
266 /**
267 * Set the list of included sub modules.
268 *
269 * @param includeList the included list to set.
270 */
271 private void setIncludeList(List<YangInclude> includeList) {
272 this.includeList = includeList;
273 }
274
275 /**
276 * Add the included sub module information to the include list.
277 *
278 * @param includeModule submodule being included.
279 */
280 public void addIncludedInfo(YangInclude includeModule) {
281
282 if (getIncludeList() == null) {
283 setIncludeList(new LinkedList<YangInclude>());
284 }
285
286 getIncludeList().add(includeModule);
287 return;
288 }
289
290 /**
291 * Get the list of leaves.
292 *
293 * @return the list of leaves.
294 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530295 @Override
296 public List<YangLeaf<?>> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530297 return listOfLeaf;
298 }
299
300 /**
301 * Set the list of leaves.
302 *
303 * @param leafsList the list of leaf to set.
304 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530305 private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530306 listOfLeaf = leafsList;
307 }
308
309 /**
310 * Add a leaf.
311 *
312 * @param leaf the leaf to be added.
313 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530314 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530315 public void addLeaf(YangLeaf<?> leaf) {
316 if (getListOfLeaf() == null) {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530317 setListOfLeaf(new LinkedList<YangLeaf<?>>());
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530318 }
319
320 getListOfLeaf().add(leaf);
321 }
322
323 /**
324 * Get the list of leaf-list.
325 *
326 * @return the list of leaf-list.
327 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530328 @Override
329 public List<YangLeafList<?>> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530330 return listOfLeafList;
331 }
332
333 /**
334 * Set the list of leaf-list.
335 *
336 * @param listOfLeafList the list of leaf-list to set.
337 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530338 private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530339 this.listOfLeafList = listOfLeafList;
340 }
341
342 /**
343 * Add a leaf-list.
344 *
345 * @param leafList the leaf-list to be added.
346 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530347 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530348 public void addLeafList(YangLeafList<?> leafList) {
349 if (getListOfLeafList() == null) {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530350 setListOfLeafList(new LinkedList<YangLeafList<?>>());
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530351 }
352
353 getListOfLeafList().add(leafList);
354 }
355
356 /**
357 * Get the sub-modules organization.
358 *
359 * @return the organization.
360 */
361 public String getOrganization() {
362 return organization;
363 }
364
365 /**
366 * Set the sub-modules organization.
367 *
368 * @param org the organization to set.
369 */
370 public void setOrganization(String org) {
371 organization = org;
372 }
373
374 /**
375 * Get the textual reference.
376 *
377 * @return the reference.
378 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530379 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530380 public String getReference() {
381 return reference;
382 }
383
384 /**
385 * Set the textual reference.
386 *
387 * @param reference the reference to set.
388 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530389 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530390 public void setReference(String reference) {
391 this.reference = reference;
392 }
393
394 /**
395 * Get the revision.
396 *
397 * @return the revision.
398 */
399 public YangRevision getRevision() {
400 return revision;
401 }
402
403 /**
404 * Set the revision.
405 *
406 * @param revision the revision to set.
407 */
408 public void setRevision(YangRevision revision) {
409 this.revision = revision;
410 }
411
412 /**
413 * Get the version.
414 *
415 * @return the version.
416 */
417 public byte getVersion() {
418 return version;
419 }
420
421 /**
422 * Set the version.
423 *
424 * @param version the version to set.
425 */
426 public void setVersion(byte version) {
427 this.version = version;
428 }
429
430 /**
431 * Returns the type of the parsed data.
432 *
433 * @return returns SUB_MODULE_DATA.
434 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530435 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530436 public ParsableDataType getParsableDataType() {
437 return ParsableDataType.SUB_MODULE_DATA;
438 }
439
440 /**
441 * Validate the data on entering the corresponding parse tree node.
442 *
443 * @throws DataModelException a violation of data model rules.
444 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530445 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530446 public void validateDataOnEntry() throws DataModelException {
447 // TODO auto-generated method stub, to be implemented by parser
448 }
449
450 /**
451 * Validate the data on exiting the corresponding parse tree node.
452 *
453 * @throws DataModelException a violation of data model rules.
454 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530455 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530456 public void validateDataOnExit() throws DataModelException {
457 // TODO auto-generated method stub, to be implemented by parser
458 }
459
460 /* (non-Javadoc)
461 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
462 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530463 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530464 public void generateJavaCodeEntry() {
465 // TODO Auto-generated method stub
466
467 }
468
469 /* (non-Javadoc)
470 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
471 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530472 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530473 public void generateJavaCodeExit() {
474 // TODO Auto-generated method stub
475
476 }
477
478 /* (non-Javadoc)
479 * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
480 */
481 @Override
482 public String getPackage() {
483 // TODO Auto-generated method stub
484 return null;
485 }
486
487 /* (non-Javadoc)
488 * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
489 */
490 @Override
491 public void setPackage(String pkg) {
492 // TODO Auto-generated method stub
493
494 }
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530495
496 @Override
497 public CachedFileHandle getFileHandle() {
498 // TODO Auto-generated method stub
499 return null;
500 }
501
502 @Override
503 public void setFileHandle(CachedFileHandle fileHandle) {
504 // TODO Auto-generated method stub
505
506 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530507}