blob: 378eaf454f9c7cca9c39aa2054714128c7884a69 [file] [log] [blame]
Vinod Kumar S2ff139c2016-02-16 01:37:16 +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 S2ff139c2016-02-16 01:37:16 +053025
26/*-
27 * Reference RFC 6020.
28 *
29 * The "augment" statement allows a module or submodule to add to the
30 * schema tree defined in an external module, or the current module and
31 * its submodules, and to add to the nodes from a grouping in a "uses"
32 * statement. The argument is a string that identifies a node in the
33 * schema tree. This node is called the augment's target node. The
34 * target node MUST be either a container, list, choice, case, input,
35 * output, or notification node. It is augmented with the nodes defined
36 * in the sub-statements that follow the "augment" statement.
37 *
38 * The argument string is a schema node identifier.
39 * If the "augment" statement is on the top level in a module or
40 * submodule, the absolute form of a schema node identifier
41 * MUST be used. If the "augment" statement is a sub-statement to the
42 * "uses" statement, the descendant form MUST be used.
43 *
44 * If the target node is a container, list, case, input, output, or
45 * notification node, the "container", "leaf", "list", "leaf-list",
46 * "uses", and "choice" statements can be used within the "augment"
47 * statement.
48 *
49 * If the target node is a choice node, the "case" statement, or a case
50 * shorthand statement can be used within the "augment" statement.
51 *
52 * If the target node is in another module, then nodes added by the
53 * augmentation MUST NOT be mandatory nodes.
54 *
55 * The "augment" statement MUST NOT add multiple nodes with the same
56 * name from the same module to the target node.
57 * The augment's sub-statements
58 *
59 * +--------------+---------+-------------+------------------+
60 * | substatement | section | cardinality |data model mapping|
61 * +--------------+---------+-------------+------------------+
62 * | anyxml | 7.10 | 0..n |-not supported |
63 * | case | 7.9.2 | 0..n |-child nodes |
64 * | choice | 7.9 | 0..n |-child nodes |
65 * | container | 7.5 | 0..n |-child nodes |
66 * | description | 7.19.3 | 0..1 |-string |
67 * | if-feature | 7.18.2 | 0..n |-TODO |
68 * | leaf | 7.6 | 0..n |-YangLeaf |
69 * | leaf-list | 7.7 | 0..n |-YangLeafList |
70 * | list | 7.8 | 0..n |-child nodes |
71 * | reference | 7.19.4 | 0..1 |-String |
72 * | status | 7.19.2 | 0..1 |-YangStatus |
73 * | uses | 7.12 | 0..n |-child nodes |
74 * | when | 7.19.5 | 0..1 |-TODO |
75 * +--------------+---------+-------------+------------------+
76 */
77/**
78 * Data model node to maintain information defined in YANG augment.
79 */
Bharat saraswal870c56f2016-02-20 21:57:16 +053080public class YangAugment extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053081
82 /**
83 * Augment target node.
84 */
85 private String targetNode;
86
87 /**
88 * description of augment.
89 */
90 private String description;
91
92 /**
93 * List of leaves.
94 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053095 private List<YangLeaf> listOfLeaf;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053096
97 /**
98 * List of leaf-lists.
99 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530100 private List<YangLeafList> listOfLeafList;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530101
102 /**
103 * reference.
104 */
105 private String reference;
106
107 /**
108 * Status of the node.
109 */
110 private YangStatusType status;
111
112 /**
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530113 * package of the generated java code.
114 */
115 private String pkg;
116
117 /**
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530118 * Create a YANG augment node.
119 */
120 public YangAugment() {
121 super(YangNodeType.AUGMENT_NODE);
122 }
123
124 /**
125 * Get the augmented node.
126 *
127 * @return the augmented node.
128 */
129 public String getTargetNode() {
130 return targetNode;
131 }
132
133 /**
134 * Set the augmented node.
135 *
136 * @param targetNode the augmented node.
137 */
138 public void setTargetNode(String targetNode) {
139 this.targetNode = targetNode;
140 }
141
142 /**
143 * Get the description.
144 *
145 * @return the description.
146 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530147 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530148 public String getDescription() {
149 return description;
150 }
151
152 /**
153 * Set the description.
154 *
155 * @param description set the description.
156 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530157 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530158 public void setDescription(String description) {
159 this.description = description;
160 }
161
162 /**
163 * Get the list of leaves.
164 *
165 * @return the list of leaves.
166 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530167 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530168 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530169 return listOfLeaf;
170 }
171
172 /**
173 * Set the list of leaves.
174 *
175 * @param leafsList the list of leaf to set.
176 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530177 private void setListOfLeaf(List<YangLeaf> leafsList) {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530178 listOfLeaf = leafsList;
179 }
180
181 /**
182 * Add a leaf.
183 *
184 * @param leaf the leaf to be added.
185 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530186 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530187 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530188 if (getListOfLeaf() == null) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530189 setListOfLeaf(new LinkedList<YangLeaf>());
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530190 }
191
192 getListOfLeaf().add(leaf);
193 }
194
195 /**
196 * Get the list of leaf-list.
197 *
198 * @return the list of leaf-list.
199 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530200 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530201 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530202 return listOfLeafList;
203 }
204
205 /**
206 * Set the list of leaf-list.
207 *
208 * @param listOfLeafList the list of leaf-list to set.
209 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530210 private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530211 this.listOfLeafList = listOfLeafList;
212 }
213
214 /**
215 * Add a leaf-list.
216 *
217 * @param leafList the leaf-list to be added.
218 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530219 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530220 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530221 if (getListOfLeafList() == null) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530222 setListOfLeafList(new LinkedList<YangLeafList>());
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530223 }
224
225 getListOfLeafList().add(leafList);
226 }
227
228 /**
229 * Get the textual reference.
230 *
231 * @return the reference.
232 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530233 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530234 public String getReference() {
235 return reference;
236 }
237
238 /**
239 * Set the textual reference.
240 *
241 * @param reference the reference to set.
242 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530243 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530244 public void setReference(String reference) {
245 this.reference = reference;
246 }
247
248 /**
249 * Get the status.
250 *
251 * @return the status.
252 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530253 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530254 public YangStatusType getStatus() {
255 return status;
256 }
257
258 /**
259 * Set the status.
260 *
261 * @param status the status to set.
262 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530263 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530264 public void setStatus(YangStatusType status) {
265 this.status = status;
266 }
267
268 /**
269 * Returns the type of the data as belongs-to.
270 *
271 * @return returns AUGMENT_DATA.
272 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530273 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530274 public ParsableDataType getParsableDataType() {
275 return ParsableDataType.AUGMENT_DATA;
276 }
277
278 /**
279 * Validate the data on entering the corresponding parse tree node.
280 *
281 * @throws DataModelException a violation of data model rules.
282 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530283 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530284 public void validateDataOnEntry() throws DataModelException {
285 // TODO auto-generated method stub, to be implemented by parser
286 }
287
288 /**
289 * Validate the data on exiting the corresponding parse tree node.
290 *
291 * @throws DataModelException a violation of data model rules.
292 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530293 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530294 public void validateDataOnExit() throws DataModelException {
295 // TODO auto-generated method stub, to be implemented by parser
296 }
297
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530298 /**
299 * Get the target nodes name where the augmentation is being done.
300 *
301 * @return target nodes name where the augmentation is being done.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530302 */
303 @Override
304 public String getName() {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530305 return targetNode;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530306 }
307
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530308 /**
309 * Set the target nodes name where the augmentation is being done.
310 *
311 * @param name target nodes name where the augmentation is being done.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530312 */
313 @Override
314 public void setName(String name) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530315 targetNode = name;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530316
317 }
318
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530319 /**
320 * Get the mapped java package.
321 *
322 * @return the java package
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530323 */
324 @Override
325 public String getPackage() {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530326 return pkg;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530327 }
328
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530329 /**
330 * Set the mapped java package.
331 *
332 * @param pakg the package to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530333 */
334 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530335 public void setPackage(String pakg) {
336 pkg = pakg;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530337
338 }
339
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530340 /**
341 * Prepare the information for java code generation corresponding to YANG
342 * grouping info.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530343 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530344 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530345 public void generateJavaCodeEntry() {
346 // TODO Auto-generated method stub
347
348 }
349
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530350 /**
351 * Create a java file using the YANG grouping info.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530352 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530353 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530354 public void generateJavaCodeExit() {
355 // TODO Auto-generated method stub
356
357 }
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530358
359 @Override
360 public CachedFileHandle getFileHandle() {
361 // TODO Auto-generated method stub
362 return null;
363 }
364
365 @Override
366 public void setFileHandle(CachedFileHandle fileHandle) {
367 // TODO Auto-generated method stub
368
369 }
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530370}