blob: 163599af7a90762c6015a31c28aece7cbcd1574f [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;
24
25/*
26 * Reference RFC 6020.
27 *
28 * While the primary unit in YANG is a module, a YANG module can itself
29 * be constructed out of several submodules. Submodules allow a module
30 * designer to split a complex model into several pieces where all the
31 * submodules contribute to a single namespace, which is defined by the
32 * module that includes the submodules.
33 *
34 * The "submodule" statement defines the submodule's name, and groups
35 * all statements that belong to the submodule together. The
36 * "submodule" statement's argument is the name of the submodule,
37 * followed by a block of sub-statements that hold detailed submodule
38 * information.
39 *
40 * The submodule's sub-statements
41 *
42 * +--------------+---------+-------------+------------------+
43 * | substatement | section | cardinality |data model mapping|
44 * +--------------+---------+-------------+------------------+
45 * | anyxml | 7.10 | 0..n | - not supported |
46 * | augment | 7.15 | 0..n | - child nodes |
47 * | belongs-to | 7.2.2 | 1 | - YangBelongsTo |
48 * | choice | 7.9 | 0..n | - child nodes |
49 * | contact | 7.1.8 | 0..1 | - string |
50 * | container | 7.5 | 0..n | - child nodes |
51 * | description | 7.19.3 | 0..1 | - string |
52 * | deviation | 7.18.3 | 0..n | - TODO |
53 * | extension | 7.17 | 0..n | - TODO |
54 * | feature | 7.18.1 | 0..n | - TODO |
55 * | grouping | 7.11 | 0..n | - child nodes |
56 * | identity | 7.16 | 0..n | - TODO |
57 * | import | 7.1.5 | 0..n | - YangImport |
58 * | include | 7.1.6 | 0..n | - YangInclude |
59 * | leaf | 7.6 | 0..n | - YangLeaf |
60 * | leaf-list | 7.7 | 0..n | - YangLeafList |
61 * | list | 7.8 | 0..n | - child nodes |
62 * | notification | 7.14 | 0..n | - TODO |
63 * | organization | 7.1.7 | 0..1 | - string |
64 * | reference | 7.19.4 | 0..1 | - string |
65 * | revision | 7.1.9 | 0..n | - string |
66 * | rpc | 7.13 | 0..n | - TODO |
67 * | typedef | 7.3 | 0..n | - child nodes |
68 * | uses | 7.12 | 0..n | - child nodes |
69 * | YANG-version | 7.1.2 | 0..1 | - int |
70 * +--------------+---------+-------------+------------------+
71 */
72/**
73 * Data model node to maintain information defined in YANG sub-module.
74 */
75public class YangSubModule extends YangNode
76 implements YangLeavesHolder, YangDesc, YangReference, Parsable {
77
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 */
117 @SuppressWarnings("rawtypes")
118 private List<YangLeaf> listOfLeaf;
119
120 /**
121 * List of leaf-lists at root level in the sub-module.
122 */
123 @SuppressWarnings("rawtypes")
124 private List<YangLeafList> listOfLeafList;
125
126 /**
127 * organization owner of the sub-module.
128 */
129 private String organization;
130
131 /**
132 * reference of the sub-module.
133 */
134 private String reference;
135
136 /**
137 * revision info of the sub-module.
138 */
139 private YangRevision revision;
140
141 /**
142 * YANG version.
143 */
144 private byte version;
145
146 /**
147 * Create a sub module node.
148 */
149 public YangSubModule() {
150 super(YangNodeType.SUB_MODULE_NODE);
151 }
152
153 /* (non-Javadoc)
154 * @see org.onosproject.yangutils.datamodel.YangNode#getName()
155 */
156 @Override
157 public String getName() {
158 return name;
159 }
160
161 /* (non-Javadoc)
162 * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
163 */
164 @Override
165 public void setName(String subModuleName) {
166 name = subModuleName;
167 }
168
169 /**
170 * Get the module info.
171 *
172 * @return the belongs to info
173 */
174 public YangBelongsTo getBelongsTo() {
175 return belongsTo;
176 }
177
178 /**
179 * Set the module info.
180 *
181 * @param belongsTo module info to set.
182 */
183 public void setBelongsTo(YangBelongsTo belongsTo) {
184 this.belongsTo = belongsTo;
185 }
186
187 /**
188 * Get the contact.
189 *
190 * @return the contact.
191 */
192 public String getContact() {
193 return contact;
194 }
195
196 /**
197 * Set the contact.
198 *
199 * @param contact the contact to set
200 */
201 public void setContact(String contact) {
202 this.contact = contact;
203 }
204
205 /**
206 * Get the description.
207 *
208 * @return the description.
209 */
210 public String getDescription() {
211 return description;
212 }
213
214 /**
215 * Set the description.
216 *
217 * @param description set the description.
218 */
219 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 */
295 @SuppressWarnings("rawtypes")
296 public List<YangLeaf> getListOfLeaf() {
297 return listOfLeaf;
298 }
299
300 /**
301 * Set the list of leaves.
302 *
303 * @param leafsList the list of leaf to set.
304 */
305 @SuppressWarnings("rawtypes")
306 private void setListOfLeaf(List<YangLeaf> leafsList) {
307 listOfLeaf = leafsList;
308 }
309
310 /**
311 * Add a leaf.
312 *
313 * @param leaf the leaf to be added.
314 */
315 @SuppressWarnings("rawtypes")
316 public void addLeaf(YangLeaf<?> leaf) {
317 if (getListOfLeaf() == null) {
318 setListOfLeaf(new LinkedList<YangLeaf>());
319 }
320
321 getListOfLeaf().add(leaf);
322 }
323
324 /**
325 * Get the list of leaf-list.
326 *
327 * @return the list of leaf-list.
328 */
329 @SuppressWarnings("rawtypes")
330 public List<YangLeafList> getListOfLeafList() {
331 return listOfLeafList;
332 }
333
334 /**
335 * Set the list of leaf-list.
336 *
337 * @param listOfLeafList the list of leaf-list to set.
338 */
339 @SuppressWarnings("rawtypes")
340 private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
341 this.listOfLeafList = listOfLeafList;
342 }
343
344 /**
345 * Add a leaf-list.
346 *
347 * @param leafList the leaf-list to be added.
348 */
349 @SuppressWarnings("rawtypes")
350 public void addLeafList(YangLeafList<?> leafList) {
351 if (getListOfLeafList() == null) {
352 setListOfLeafList(new LinkedList<YangLeafList>());
353 }
354
355 getListOfLeafList().add(leafList);
356 }
357
358 /**
359 * Get the sub-modules organization.
360 *
361 * @return the organization.
362 */
363 public String getOrganization() {
364 return organization;
365 }
366
367 /**
368 * Set the sub-modules organization.
369 *
370 * @param org the organization to set.
371 */
372 public void setOrganization(String org) {
373 organization = org;
374 }
375
376 /**
377 * Get the textual reference.
378 *
379 * @return the reference.
380 */
381 public String getReference() {
382 return reference;
383 }
384
385 /**
386 * Set the textual reference.
387 *
388 * @param reference the reference to set.
389 */
390 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 */
435 public ParsableDataType getParsableDataType() {
436 return ParsableDataType.SUB_MODULE_DATA;
437 }
438
439 /**
440 * Validate the data on entering the corresponding parse tree node.
441 *
442 * @throws DataModelException a violation of data model rules.
443 */
444 public void validateDataOnEntry() throws DataModelException {
445 // TODO auto-generated method stub, to be implemented by parser
446 }
447
448 /**
449 * Validate the data on exiting the corresponding parse tree node.
450 *
451 * @throws DataModelException a violation of data model rules.
452 */
453 public void validateDataOnExit() throws DataModelException {
454 // TODO auto-generated method stub, to be implemented by parser
455 }
456
457 /* (non-Javadoc)
458 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
459 */
460 public void generateJavaCodeEntry() {
461 // TODO Auto-generated method stub
462
463 }
464
465 /* (non-Javadoc)
466 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
467 */
468 public void generateJavaCodeExit() {
469 // TODO Auto-generated method stub
470
471 }
472
473 /* (non-Javadoc)
474 * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
475 */
476 @Override
477 public String getPackage() {
478 // TODO Auto-generated method stub
479 return null;
480 }
481
482 /* (non-Javadoc)
483 * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
484 */
485 @Override
486 public void setPackage(String pkg) {
487 // TODO Auto-generated method stub
488
489 }
490}