Committed by
Gerrit Code Review
[ONOS-3905, ONOS-3901, ONOS-3900] choice, grouping and augment data model support.
Change-Id: Iaee5175e4e06249f5b56192f4744e9297289194c
Showing
11 changed files
with
2359 additions
and
0 deletions
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +import java.util.LinkedList; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
22 | +import org.onosproject.yangutils.parser.Parsable; | ||
23 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
24 | + | ||
25 | +/*- | ||
26 | + * Reference RFC 6020. | ||
27 | + * | ||
28 | + * The "augment" statement allows a module or submodule to add to the | ||
29 | + * schema tree defined in an external module, or the current module and | ||
30 | + * its submodules, and to add to the nodes from a grouping in a "uses" | ||
31 | + * statement. The argument is a string that identifies a node in the | ||
32 | + * schema tree. This node is called the augment's target node. The | ||
33 | + * target node MUST be either a container, list, choice, case, input, | ||
34 | + * output, or notification node. It is augmented with the nodes defined | ||
35 | + * in the sub-statements that follow the "augment" statement. | ||
36 | + * | ||
37 | + * The argument string is a schema node identifier. | ||
38 | + * If the "augment" statement is on the top level in a module or | ||
39 | + * submodule, the absolute form of a schema node identifier | ||
40 | + * MUST be used. If the "augment" statement is a sub-statement to the | ||
41 | + * "uses" statement, the descendant form MUST be used. | ||
42 | + * | ||
43 | + * If the target node is a container, list, case, input, output, or | ||
44 | + * notification node, the "container", "leaf", "list", "leaf-list", | ||
45 | + * "uses", and "choice" statements can be used within the "augment" | ||
46 | + * statement. | ||
47 | + * | ||
48 | + * If the target node is a choice node, the "case" statement, or a case | ||
49 | + * shorthand statement can be used within the "augment" statement. | ||
50 | + * | ||
51 | + * If the target node is in another module, then nodes added by the | ||
52 | + * augmentation MUST NOT be mandatory nodes. | ||
53 | + * | ||
54 | + * The "augment" statement MUST NOT add multiple nodes with the same | ||
55 | + * name from the same module to the target node. | ||
56 | + * The augment's sub-statements | ||
57 | + * | ||
58 | + * +--------------+---------+-------------+------------------+ | ||
59 | + * | substatement | section | cardinality |data model mapping| | ||
60 | + * +--------------+---------+-------------+------------------+ | ||
61 | + * | anyxml | 7.10 | 0..n |-not supported | | ||
62 | + * | case | 7.9.2 | 0..n |-child nodes | | ||
63 | + * | choice | 7.9 | 0..n |-child nodes | | ||
64 | + * | container | 7.5 | 0..n |-child nodes | | ||
65 | + * | description | 7.19.3 | 0..1 |-string | | ||
66 | + * | if-feature | 7.18.2 | 0..n |-TODO | | ||
67 | + * | leaf | 7.6 | 0..n |-YangLeaf | | ||
68 | + * | leaf-list | 7.7 | 0..n |-YangLeafList | | ||
69 | + * | list | 7.8 | 0..n |-child nodes | | ||
70 | + * | reference | 7.19.4 | 0..1 |-String | | ||
71 | + * | status | 7.19.2 | 0..1 |-YangStatus | | ||
72 | + * | uses | 7.12 | 0..n |-child nodes | | ||
73 | + * | when | 7.19.5 | 0..1 |-TODO | | ||
74 | + * +--------------+---------+-------------+------------------+ | ||
75 | + */ | ||
76 | +/** | ||
77 | + * Data model node to maintain information defined in YANG augment. | ||
78 | + */ | ||
79 | +public class YangAugment extends YangNode | ||
80 | + implements YangLeavesHolder, YangCommonInfo, Parsable { | ||
81 | + | ||
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 | + */ | ||
95 | + @SuppressWarnings("rawtypes") | ||
96 | + private List<YangLeaf> listOfLeaf; | ||
97 | + | ||
98 | + /** | ||
99 | + * List of leaf-lists. | ||
100 | + */ | ||
101 | + @SuppressWarnings("rawtypes") | ||
102 | + private List<YangLeafList> listOfLeafList; | ||
103 | + | ||
104 | + /** | ||
105 | + * reference. | ||
106 | + */ | ||
107 | + private String reference; | ||
108 | + | ||
109 | + /** | ||
110 | + * Status of the node. | ||
111 | + */ | ||
112 | + private YangStatusType status; | ||
113 | + | ||
114 | + /** | ||
115 | + * Create a YANG augment node. | ||
116 | + */ | ||
117 | + public YangAugment() { | ||
118 | + super(YangNodeType.AUGMENT_NODE); | ||
119 | + } | ||
120 | + | ||
121 | + /** | ||
122 | + * Get the augmented node. | ||
123 | + * | ||
124 | + * @return the augmented node. | ||
125 | + */ | ||
126 | + public String getTargetNode() { | ||
127 | + return targetNode; | ||
128 | + } | ||
129 | + | ||
130 | + /** | ||
131 | + * Set the augmented node. | ||
132 | + * | ||
133 | + * @param targetNode the augmented node. | ||
134 | + */ | ||
135 | + public void setTargetNode(String targetNode) { | ||
136 | + this.targetNode = targetNode; | ||
137 | + } | ||
138 | + | ||
139 | + /** | ||
140 | + * Get the description. | ||
141 | + * | ||
142 | + * @return the description. | ||
143 | + */ | ||
144 | + public String getDescription() { | ||
145 | + return description; | ||
146 | + } | ||
147 | + | ||
148 | + /** | ||
149 | + * Set the description. | ||
150 | + * | ||
151 | + * @param description set the description. | ||
152 | + */ | ||
153 | + public void setDescription(String description) { | ||
154 | + this.description = description; | ||
155 | + } | ||
156 | + | ||
157 | + /** | ||
158 | + * Get the list of leaves. | ||
159 | + * | ||
160 | + * @return the list of leaves. | ||
161 | + */ | ||
162 | + @SuppressWarnings("rawtypes") | ||
163 | + public List<YangLeaf> getListOfLeaf() { | ||
164 | + return listOfLeaf; | ||
165 | + } | ||
166 | + | ||
167 | + /** | ||
168 | + * Set the list of leaves. | ||
169 | + * | ||
170 | + * @param leafsList the list of leaf to set. | ||
171 | + */ | ||
172 | + @SuppressWarnings("rawtypes") | ||
173 | + private void setListOfLeaf(List<YangLeaf> leafsList) { | ||
174 | + listOfLeaf = leafsList; | ||
175 | + } | ||
176 | + | ||
177 | + /** | ||
178 | + * Add a leaf. | ||
179 | + * | ||
180 | + * @param leaf the leaf to be added. | ||
181 | + */ | ||
182 | + @SuppressWarnings("rawtypes") | ||
183 | + public void addLeaf(YangLeaf<?> leaf) { | ||
184 | + if (getListOfLeaf() == null) { | ||
185 | + setListOfLeaf(new LinkedList<YangLeaf>()); | ||
186 | + } | ||
187 | + | ||
188 | + getListOfLeaf().add(leaf); | ||
189 | + } | ||
190 | + | ||
191 | + /** | ||
192 | + * Get the list of leaf-list. | ||
193 | + * | ||
194 | + * @return the list of leaf-list. | ||
195 | + */ | ||
196 | + @SuppressWarnings("rawtypes") | ||
197 | + public List<YangLeafList> getListOfLeafList() { | ||
198 | + return listOfLeafList; | ||
199 | + } | ||
200 | + | ||
201 | + /** | ||
202 | + * Set the list of leaf-list. | ||
203 | + * | ||
204 | + * @param listOfLeafList the list of leaf-list to set. | ||
205 | + */ | ||
206 | + @SuppressWarnings("rawtypes") | ||
207 | + private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | ||
208 | + this.listOfLeafList = listOfLeafList; | ||
209 | + } | ||
210 | + | ||
211 | + /** | ||
212 | + * Add a leaf-list. | ||
213 | + * | ||
214 | + * @param leafList the leaf-list to be added. | ||
215 | + */ | ||
216 | + @SuppressWarnings("rawtypes") | ||
217 | + public void addLeafList(YangLeafList<?> leafList) { | ||
218 | + if (getListOfLeafList() == null) { | ||
219 | + setListOfLeafList(new LinkedList<YangLeafList>()); | ||
220 | + } | ||
221 | + | ||
222 | + getListOfLeafList().add(leafList); | ||
223 | + } | ||
224 | + | ||
225 | + /** | ||
226 | + * Get the textual reference. | ||
227 | + * | ||
228 | + * @return the reference. | ||
229 | + */ | ||
230 | + public String getReference() { | ||
231 | + return reference; | ||
232 | + } | ||
233 | + | ||
234 | + /** | ||
235 | + * Set the textual reference. | ||
236 | + * | ||
237 | + * @param reference the reference to set. | ||
238 | + */ | ||
239 | + public void setReference(String reference) { | ||
240 | + this.reference = reference; | ||
241 | + } | ||
242 | + | ||
243 | + /** | ||
244 | + * Get the status. | ||
245 | + * | ||
246 | + * @return the status. | ||
247 | + */ | ||
248 | + public YangStatusType getStatus() { | ||
249 | + return status; | ||
250 | + } | ||
251 | + | ||
252 | + /** | ||
253 | + * Set the status. | ||
254 | + * | ||
255 | + * @param status the status to set. | ||
256 | + */ | ||
257 | + public void setStatus(YangStatusType status) { | ||
258 | + this.status = status; | ||
259 | + } | ||
260 | + | ||
261 | + /** | ||
262 | + * Returns the type of the data as belongs-to. | ||
263 | + * | ||
264 | + * @return returns AUGMENT_DATA. | ||
265 | + */ | ||
266 | + public ParsableDataType getParsableDataType() { | ||
267 | + return ParsableDataType.AUGMENT_DATA; | ||
268 | + } | ||
269 | + | ||
270 | + /** | ||
271 | + * Validate the data on entering the corresponding parse tree node. | ||
272 | + * | ||
273 | + * @throws DataModelException a violation of data model rules. | ||
274 | + */ | ||
275 | + public void validateDataOnEntry() throws DataModelException { | ||
276 | + // TODO auto-generated method stub, to be implemented by parser | ||
277 | + } | ||
278 | + | ||
279 | + /** | ||
280 | + * Validate the data on exiting the corresponding parse tree node. | ||
281 | + * | ||
282 | + * @throws DataModelException a violation of data model rules. | ||
283 | + */ | ||
284 | + public void validateDataOnExit() throws DataModelException { | ||
285 | + // TODO auto-generated method stub, to be implemented by parser | ||
286 | + } | ||
287 | + | ||
288 | + /* (non-Javadoc) | ||
289 | + * @see org.onosproject.yangutils.datamodel.YangNode#getName() | ||
290 | + */ | ||
291 | + @Override | ||
292 | + public String getName() { | ||
293 | + // TODO Auto-generated method stub | ||
294 | + return null; | ||
295 | + } | ||
296 | + | ||
297 | + /* (non-Javadoc) | ||
298 | + * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String) | ||
299 | + */ | ||
300 | + @Override | ||
301 | + public void setName(String name) { | ||
302 | + // TODO Auto-generated method stub | ||
303 | + | ||
304 | + } | ||
305 | + | ||
306 | + /* (non-Javadoc) | ||
307 | + * @see org.onosproject.yangutils.datamodel.YangNode#getPackage() | ||
308 | + */ | ||
309 | + @Override | ||
310 | + public String getPackage() { | ||
311 | + // TODO Auto-generated method stub | ||
312 | + return null; | ||
313 | + } | ||
314 | + | ||
315 | + /* (non-Javadoc) | ||
316 | + * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String) | ||
317 | + */ | ||
318 | + @Override | ||
319 | + public void setPackage(String pkg) { | ||
320 | + // TODO Auto-generated method stub | ||
321 | + | ||
322 | + } | ||
323 | + | ||
324 | + /* (non-Javadoc) | ||
325 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | ||
326 | + */ | ||
327 | + public void generateJavaCodeEntry() { | ||
328 | + // TODO Auto-generated method stub | ||
329 | + | ||
330 | + } | ||
331 | + | ||
332 | + /* (non-Javadoc) | ||
333 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | ||
334 | + */ | ||
335 | + public void generateJavaCodeExit() { | ||
336 | + // TODO Auto-generated method stub | ||
337 | + | ||
338 | + } | ||
339 | +} |
1 | +/* | ||
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 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.datamodel; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
20 | +import org.onosproject.yangutils.parser.Parsable; | ||
21 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
22 | + | ||
23 | +/*- | ||
24 | + * The "bit" statement, which is a sub-statement to the "type" statement, | ||
25 | + * MUST be present if the type is "bits". It is repeatedly used to | ||
26 | + * specify each assigned named bit of a bits type. It takes as an | ||
27 | + * argument a string that is the assigned name of the bit. It is | ||
28 | + * followed by a block of sub-statements that holds detailed bit | ||
29 | + * information. | ||
30 | + * All assigned names in a bits type MUST be unique. | ||
31 | + * | ||
32 | + * The bit's sub-statements | ||
33 | + * | ||
34 | + * +--------------+---------+-------------+------------------+ | ||
35 | + * | substatement | section | cardinality |data model mapping| | ||
36 | + * +--------------+---------+-------------+------------------+ | ||
37 | + * | description | 7.19.3 | 0..1 | - string | | ||
38 | + * | reference | 7.19.4 | 0..1 | - string | | ||
39 | + * | status | 7.19.2 | 0..1 | - YangStatus | | ||
40 | + * | position | 9.7.4.2 | 0..1 | - int | | ||
41 | + * +--------------+---------+-------------+------------------+ | ||
42 | + */ | ||
43 | + | ||
44 | +/** | ||
45 | + * Maintains the bit data type information. | ||
46 | + */ | ||
47 | +public class YangBit implements YangCommonInfo, Parsable { | ||
48 | + | ||
49 | + /** | ||
50 | + * Name of the bit. | ||
51 | + */ | ||
52 | + private String bitName; | ||
53 | + | ||
54 | + /** | ||
55 | + * Description of the bit field. | ||
56 | + */ | ||
57 | + private String description; | ||
58 | + | ||
59 | + /** | ||
60 | + * reference info of the bit field. | ||
61 | + */ | ||
62 | + private String reference; | ||
63 | + | ||
64 | + /** | ||
65 | + * Status of the bit field. | ||
66 | + */ | ||
67 | + private YangStatusType status; | ||
68 | + | ||
69 | + /** | ||
70 | + * position of the bit whose name bit is described. | ||
71 | + */ | ||
72 | + private int position; | ||
73 | + | ||
74 | + /** | ||
75 | + * Create a YANG bit type object. | ||
76 | + */ | ||
77 | + public YangBit() { | ||
78 | + | ||
79 | + } | ||
80 | + | ||
81 | + /** | ||
82 | + * Get the bit name. | ||
83 | + * | ||
84 | + * @return the bit name. | ||
85 | + */ | ||
86 | + public String getBitName() { | ||
87 | + return bitName; | ||
88 | + } | ||
89 | + | ||
90 | + /** | ||
91 | + * Set the bit name. | ||
92 | + * | ||
93 | + * @param bitName the bit name to set. | ||
94 | + */ | ||
95 | + public void setBitName(String bitName) { | ||
96 | + this.bitName = bitName; | ||
97 | + } | ||
98 | + | ||
99 | + /** | ||
100 | + * Get the description. | ||
101 | + * | ||
102 | + * @return the description. | ||
103 | + */ | ||
104 | + public String getDescription() { | ||
105 | + return description; | ||
106 | + } | ||
107 | + | ||
108 | + /** | ||
109 | + * Set the description. | ||
110 | + * | ||
111 | + * @param description set the description. | ||
112 | + */ | ||
113 | + public void setDescription(String description) { | ||
114 | + this.description = description; | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Get the textual reference. | ||
119 | + * | ||
120 | + * @return the reference. | ||
121 | + */ | ||
122 | + public String getReference() { | ||
123 | + return reference; | ||
124 | + } | ||
125 | + | ||
126 | + /** | ||
127 | + * Set the textual reference. | ||
128 | + * | ||
129 | + * @param reference the reference to set. | ||
130 | + */ | ||
131 | + public void setReference(String reference) { | ||
132 | + this.reference = reference; | ||
133 | + } | ||
134 | + | ||
135 | + /** | ||
136 | + * Get the status. | ||
137 | + * | ||
138 | + * @return the status. | ||
139 | + */ | ||
140 | + public YangStatusType getStatus() { | ||
141 | + return status; | ||
142 | + } | ||
143 | + | ||
144 | + /** | ||
145 | + * Set the status. | ||
146 | + * | ||
147 | + * @param status the status to set. | ||
148 | + */ | ||
149 | + public void setStatus(YangStatusType status) { | ||
150 | + this.status = status; | ||
151 | + } | ||
152 | + | ||
153 | + /** | ||
154 | + * Get the bit position. | ||
155 | + * | ||
156 | + * @return the position | ||
157 | + */ | ||
158 | + public int getPosition() { | ||
159 | + return position; | ||
160 | + } | ||
161 | + | ||
162 | + /** | ||
163 | + * Set the bit position. | ||
164 | + * | ||
165 | + * @param position the position to set. | ||
166 | + */ | ||
167 | + public void setPosition(int position) { | ||
168 | + this.position = position; | ||
169 | + } | ||
170 | + | ||
171 | + /** | ||
172 | + * Returns the type of the data. | ||
173 | + * | ||
174 | + * @return ParsedDataType returns BIT_DATA | ||
175 | + */ | ||
176 | + public ParsableDataType getParsableDataType() { | ||
177 | + return ParsableDataType.BIT_DATA; | ||
178 | + } | ||
179 | + | ||
180 | + /** | ||
181 | + * Validate the data on entering the corresponding parse tree node. | ||
182 | + * | ||
183 | + * @throws DataModelException a violation of data model rules. | ||
184 | + */ | ||
185 | + public void validateDataOnEntry() throws DataModelException { | ||
186 | + // TODO auto-generated method stub, to be implemented by parser | ||
187 | + } | ||
188 | + | ||
189 | + /** | ||
190 | + * Validate the data on exiting the corresponding parse tree node. | ||
191 | + * | ||
192 | + * @throws DataModelException a violation of data model rules. | ||
193 | + */ | ||
194 | + public void validateDataOnExit() throws DataModelException { | ||
195 | + // TODO auto-generated method stub, to be implemented by parser | ||
196 | + } | ||
197 | +} |
1 | +/* | ||
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 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.datamodel; | ||
18 | + | ||
19 | +import java.util.HashSet; | ||
20 | +import java.util.Set; | ||
21 | + | ||
22 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
23 | +import org.onosproject.yangutils.parser.Parsable; | ||
24 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
25 | + | ||
26 | +/* | ||
27 | + * Reference RFC 6020. | ||
28 | + * | ||
29 | + * The bits built-in type represents a bit set. That is, a bits value | ||
30 | + * is a set of flags identified by small integer position numbers | ||
31 | + * starting at 0. Each bit number has an assigned name. | ||
32 | + */ | ||
33 | + | ||
34 | +/** | ||
35 | + * Maintains the bits data type information. | ||
36 | + */ | ||
37 | +public class YangBits implements Parsable { | ||
38 | + | ||
39 | + private Set<YangBit> bitSet; | ||
40 | + | ||
41 | + /** | ||
42 | + * Create a YANG bits type object. | ||
43 | + */ | ||
44 | + public YangBits() { | ||
45 | + setBitSet(new HashSet<YangBit>()); | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Get the bit set. | ||
50 | + * | ||
51 | + * @return the bit set | ||
52 | + */ | ||
53 | + public Set<YangBit> getBitSet() { | ||
54 | + return bitSet; | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * set the bit set. | ||
59 | + * | ||
60 | + * @param bitSet the bit set | ||
61 | + */ | ||
62 | + private void setBitSet(Set<YangBit> bitSet) { | ||
63 | + this.bitSet = bitSet; | ||
64 | + } | ||
65 | + | ||
66 | + /** | ||
67 | + * Add bit info. | ||
68 | + * | ||
69 | + * @param bitInfo the bit Info to add. | ||
70 | + */ | ||
71 | + public void addBitInfo(YangBit bitInfo) { | ||
72 | + getBitSet().add(bitInfo); | ||
73 | + } | ||
74 | + | ||
75 | + /** | ||
76 | + * Returns the type of the data. | ||
77 | + * | ||
78 | + * @return ParsedDataType returns BITS_DATA | ||
79 | + */ | ||
80 | + public ParsableDataType getParsableDataType() { | ||
81 | + return ParsableDataType.BITS_DATA; | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * Validate the data on entering the corresponding parse tree node. | ||
86 | + * | ||
87 | + * @throws DataModelException a violation of data model rules. | ||
88 | + */ | ||
89 | + public void validateDataOnEntry() throws DataModelException { | ||
90 | + // TODO auto-generated method stub, to be implemented by parser | ||
91 | + } | ||
92 | + | ||
93 | + /** | ||
94 | + * Validate the data on exiting the corresponding parse tree node. | ||
95 | + * | ||
96 | + * @throws DataModelException a violation of data model rules. | ||
97 | + */ | ||
98 | + public void validateDataOnExit() throws DataModelException { | ||
99 | + // TODO auto-generated method stub, to be implemented by parser | ||
100 | + } | ||
101 | +} |
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +import java.util.LinkedList; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
22 | +import org.onosproject.yangutils.parser.Parsable; | ||
23 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
24 | + | ||
25 | +/*- | ||
26 | + * Reference RFC 6020. | ||
27 | + * | ||
28 | + * The "case" statement is used to define branches of the choice. It takes as an | ||
29 | + * argument an identifier, followed by a block of sub-statements that holds | ||
30 | + * detailed case information. | ||
31 | + * | ||
32 | + * The identifier is used to identify the case node in the schema tree. A case | ||
33 | + * node does not exist in the data tree. | ||
34 | + * | ||
35 | + * Within a "case" statement, the "anyxml", "choice", "container", "leaf", | ||
36 | + * "list", "leaf-list", and "uses" statements can be used to define child nodes | ||
37 | + * to the case node. The identifiers of all these child nodes MUST be unique | ||
38 | + * within all cases in a choice. For example, the following is illegal: | ||
39 | + * | ||
40 | + * choice interface-type { // This example is illegal YANG | ||
41 | + * case a { | ||
42 | + * leaf ethernet { ... } | ||
43 | + * } | ||
44 | + * case b { | ||
45 | + * container ethernet { ...} | ||
46 | + * } | ||
47 | + * } | ||
48 | + * | ||
49 | + * As a shorthand, the "case" statement can be omitted if the branch | ||
50 | + * contains a single "anyxml", "container", "leaf", "list", or | ||
51 | + * "leaf-list" statement. In this case, the identifier of the case node | ||
52 | + * is the same as the identifier in the branch statement. The following | ||
53 | + * example: | ||
54 | + * | ||
55 | + * choice interface-type { | ||
56 | + * container ethernet { ... } | ||
57 | + * } | ||
58 | + * | ||
59 | + * is equivalent to: | ||
60 | + * | ||
61 | + * choice interface-type { | ||
62 | + * case ethernet { | ||
63 | + * container ethernet { ... } | ||
64 | + * } | ||
65 | + * } | ||
66 | + * | ||
67 | + * The case identifier MUST be unique within a choice. | ||
68 | + * | ||
69 | + * The case's sub-statements | ||
70 | + * | ||
71 | + * +--------------+---------+-------------+------------------+ | ||
72 | + * | substatement | section | cardinality |data model mapping| | ||
73 | + * +--------------+---------+-------------+------------------+ | ||
74 | + * | anyxml | 7.10 | 0..n |-not supported | | ||
75 | + * | choice | 7.9 | 0..n |-child nodes | | ||
76 | + * | container | 7.5 | 0..n |-child nodes | | ||
77 | + * | description | 7.19.3 | 0..1 |-string | | ||
78 | + * | if-feature | 7.18.2 | 0..n |-TODO | | ||
79 | + * | leaf | 7.6 | 0..n |-YangLeaf | | ||
80 | + * | leaf-list | 7.7 | 0..n |-YangLeafList | | ||
81 | + * | list | 7.8 | 0..n |-child nodes | | ||
82 | + * | reference | 7.19.4 | 0..1 |-string | | ||
83 | + * | status | 7.19.2 | 0..1 |-YangStatus | | ||
84 | + * | uses | 7.12 | 0..n |-child node | | ||
85 | + * | when | 7.19.5 | 0..1 |-TODO | | ||
86 | + * +--------------+---------+-------------+------------------+ | ||
87 | + */ | ||
88 | +/** | ||
89 | + * Data model node to maintain information defined in YANG case. | ||
90 | + */ | ||
91 | +public class YangCase extends YangNode | ||
92 | + implements YangLeavesHolder, YangCommonInfo, Parsable { | ||
93 | + | ||
94 | + /** | ||
95 | + * Case name. | ||
96 | + */ | ||
97 | + private String name; | ||
98 | + | ||
99 | + // TODO: default field identification for the case | ||
100 | + | ||
101 | + /** | ||
102 | + * Description of container. | ||
103 | + */ | ||
104 | + private String description; | ||
105 | + | ||
106 | + /** | ||
107 | + * List of leaves. | ||
108 | + */ | ||
109 | + @SuppressWarnings("rawtypes") | ||
110 | + private List<YangLeaf> listOfLeaf; | ||
111 | + | ||
112 | + /** | ||
113 | + * List of leaf lists. | ||
114 | + */ | ||
115 | + @SuppressWarnings("rawtypes") | ||
116 | + private List<YangLeafList> listOfLeafList; | ||
117 | + | ||
118 | + /** | ||
119 | + * Reference of the module. | ||
120 | + */ | ||
121 | + private String reference; | ||
122 | + | ||
123 | + /** | ||
124 | + * Status of the node. | ||
125 | + */ | ||
126 | + private YangStatusType status; | ||
127 | + | ||
128 | + /** | ||
129 | + * Create a choice node. | ||
130 | + */ | ||
131 | + public YangCase() { | ||
132 | + super(YangNodeType.CASE_NODE); | ||
133 | + } | ||
134 | + | ||
135 | + /* (non-Javadoc) | ||
136 | + * @see org.onosproject.yangutils.datamodel.YangNode#getName() | ||
137 | + */ | ||
138 | + @Override | ||
139 | + public String getName() { | ||
140 | + return name; | ||
141 | + } | ||
142 | + | ||
143 | + /* (non-Javadoc) | ||
144 | + * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String) | ||
145 | + */ | ||
146 | + @Override | ||
147 | + public void setName(String name) { | ||
148 | + this.name = name; | ||
149 | + } | ||
150 | + | ||
151 | + /** | ||
152 | + * Get the description. | ||
153 | + * | ||
154 | + * @return the description. | ||
155 | + */ | ||
156 | + public String getDescription() { | ||
157 | + return description; | ||
158 | + } | ||
159 | + | ||
160 | + /** | ||
161 | + * Set the description. | ||
162 | + * | ||
163 | + * @param description set the description. | ||
164 | + */ | ||
165 | + public void setDescription(String description) { | ||
166 | + this.description = description; | ||
167 | + } | ||
168 | + | ||
169 | + /** | ||
170 | + * Get the list of leaves. | ||
171 | + * | ||
172 | + * @return the list of leaves. | ||
173 | + */ | ||
174 | + @SuppressWarnings("rawtypes") | ||
175 | + public List<YangLeaf> getListOfLeaf() { | ||
176 | + return listOfLeaf; | ||
177 | + } | ||
178 | + | ||
179 | + /** | ||
180 | + * Set the list of leaves. | ||
181 | + * | ||
182 | + * @param leafsList the list of leaf to set. | ||
183 | + */ | ||
184 | + @SuppressWarnings("rawtypes") | ||
185 | + private void setListOfLeaf(List<YangLeaf> leafsList) { | ||
186 | + listOfLeaf = leafsList; | ||
187 | + } | ||
188 | + | ||
189 | + /** | ||
190 | + * Add a leaf. | ||
191 | + * | ||
192 | + * @param leaf the leaf to be added. | ||
193 | + */ | ||
194 | + @SuppressWarnings("rawtypes") | ||
195 | + public void addLeaf(YangLeaf<?> leaf) { | ||
196 | + if (getListOfLeaf() == null) { | ||
197 | + setListOfLeaf(new LinkedList<YangLeaf>()); | ||
198 | + } | ||
199 | + | ||
200 | + getListOfLeaf().add(leaf); | ||
201 | + } | ||
202 | + | ||
203 | + /** | ||
204 | + * Get the list of leaf-list. | ||
205 | + * | ||
206 | + * @return the list of leaf-list. | ||
207 | + */ | ||
208 | + @SuppressWarnings("rawtypes") | ||
209 | + public List<YangLeafList> getListOfLeafList() { | ||
210 | + return listOfLeafList; | ||
211 | + } | ||
212 | + | ||
213 | + /** | ||
214 | + * Set the list of leaf-list. | ||
215 | + * | ||
216 | + * @param listOfLeafList the list of leaf-list to set. | ||
217 | + */ | ||
218 | + @SuppressWarnings("rawtypes") | ||
219 | + private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | ||
220 | + this.listOfLeafList = listOfLeafList; | ||
221 | + } | ||
222 | + | ||
223 | + /** | ||
224 | + * Add a leaf-list. | ||
225 | + * | ||
226 | + * @param leafList the leaf-list to be added. | ||
227 | + */ | ||
228 | + @SuppressWarnings("rawtypes") | ||
229 | + public void addLeafList(YangLeafList<?> leafList) { | ||
230 | + if (getListOfLeafList() == null) { | ||
231 | + setListOfLeafList(new LinkedList<YangLeafList>()); | ||
232 | + } | ||
233 | + | ||
234 | + getListOfLeafList().add(leafList); | ||
235 | + } | ||
236 | + | ||
237 | + /** | ||
238 | + * Get the textual reference. | ||
239 | + * | ||
240 | + * @return the reference. | ||
241 | + */ | ||
242 | + public String getReference() { | ||
243 | + return reference; | ||
244 | + } | ||
245 | + | ||
246 | + /** | ||
247 | + * Set the textual reference. | ||
248 | + * | ||
249 | + * @param reference the reference to set. | ||
250 | + */ | ||
251 | + public void setReference(String reference) { | ||
252 | + this.reference = reference; | ||
253 | + } | ||
254 | + | ||
255 | + /** | ||
256 | + * Get the status. | ||
257 | + * | ||
258 | + * @return the status. | ||
259 | + */ | ||
260 | + public YangStatusType getStatus() { | ||
261 | + return status; | ||
262 | + } | ||
263 | + | ||
264 | + /** | ||
265 | + * Set the status. | ||
266 | + * | ||
267 | + * @param status the status to set. | ||
268 | + */ | ||
269 | + public void setStatus(YangStatusType status) { | ||
270 | + this.status = status; | ||
271 | + } | ||
272 | + | ||
273 | + /** | ||
274 | + * Returns the type of the data. | ||
275 | + * | ||
276 | + * @return returns CASE_DATA | ||
277 | + */ | ||
278 | + public ParsableDataType getParsableDataType() { | ||
279 | + return ParsableDataType.CASE_DATA; | ||
280 | + } | ||
281 | + | ||
282 | + /** | ||
283 | + * Validate the data on entering the corresponding parse tree node. | ||
284 | + * | ||
285 | + * @throws DataModelException a violation of data model rules. | ||
286 | + */ | ||
287 | + public void validateDataOnEntry() throws DataModelException { | ||
288 | + // TODO auto-generated method stub, to be implemented by parser | ||
289 | + } | ||
290 | + | ||
291 | + /** | ||
292 | + * Validate the data on exiting the corresponding parse tree node. | ||
293 | + * | ||
294 | + * @throws DataModelException a violation of data model rules. | ||
295 | + */ | ||
296 | + public void validateDataOnExit() throws DataModelException { | ||
297 | + // TODO auto-generated method stub, to be implemented by parser | ||
298 | + } | ||
299 | + | ||
300 | + /* (non-Javadoc) | ||
301 | + * @see org.onosproject.yangutils.datamodel.YangNode#getPackage() | ||
302 | + */ | ||
303 | + @Override | ||
304 | + public String getPackage() { | ||
305 | + // TODO Auto-generated method stub | ||
306 | + return null; | ||
307 | + } | ||
308 | + | ||
309 | + /* (non-Javadoc) | ||
310 | + * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String) | ||
311 | + */ | ||
312 | + @Override | ||
313 | + public void setPackage(String pkg) { | ||
314 | + // TODO Auto-generated method stub | ||
315 | + | ||
316 | + } | ||
317 | + | ||
318 | + /* (non-Javadoc) | ||
319 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | ||
320 | + */ | ||
321 | + public void generateJavaCodeEntry() { | ||
322 | + // TODO Auto-generated method stub | ||
323 | + | ||
324 | + } | ||
325 | + | ||
326 | + /* (non-Javadoc) | ||
327 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | ||
328 | + */ | ||
329 | + public void generateJavaCodeExit() { | ||
330 | + // TODO Auto-generated method stub | ||
331 | + | ||
332 | + } | ||
333 | +} |
This diff is collapsed. Click to expand it.
1 | +/* | ||
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 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.datamodel; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
20 | +import org.onosproject.yangutils.parser.Parsable; | ||
21 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
22 | + | ||
23 | +/*- | ||
24 | + * The "ENUM" statement, which is a sub-statement to the "type" | ||
25 | + * statement, MUST be present if the type is "enumeration". It is | ||
26 | + * repeatedly used to specify each assigned name of an enumeration type. | ||
27 | + * It takes as an argument a string which is the assigned name. The | ||
28 | + * string MUST NOT be empty and MUST NOT have any leading or trailing | ||
29 | + * whitespace characters. The use of Unicode control codes SHOULD be | ||
30 | + * avoided. | ||
31 | + * | ||
32 | + * The statement is optionally followed by a block of sub-statements that | ||
33 | + * holds detailed ENUM information. | ||
34 | + * All assigned names in an enumeration MUST be unique. | ||
35 | + * | ||
36 | + * The ENUM's sub-statements | ||
37 | + * | ||
38 | + * +--------------+---------+-------------+------------------+ | ||
39 | + * | substatement | section | cardinality |data model mapping| | ||
40 | + * +--------------+---------+-------------+------------------+ | ||
41 | + * | description | 7.19.3 | 0..1 | - string | | ||
42 | + * | reference | 7.19.4 | 0..1 | - string | | ||
43 | + * | status | 7.19.2 | 0..1 | - YangStatus | | ||
44 | + * | value | 9.6.4.2 | 0..1 | - int | | ||
45 | + * +--------------+---------+-------------+------------------+ | ||
46 | + */ | ||
47 | + | ||
48 | +/** | ||
49 | + * Maintains the ENUM data type information. | ||
50 | + */ | ||
51 | +public class YangEnum implements YangCommonInfo, Parsable { | ||
52 | + | ||
53 | + /** | ||
54 | + * Named value for the ENUM. | ||
55 | + */ | ||
56 | + private String namedValue; | ||
57 | + | ||
58 | + /** | ||
59 | + * Description of the ENUM value. | ||
60 | + */ | ||
61 | + private String description; | ||
62 | + | ||
63 | + /** | ||
64 | + * Reference info of the ENUM value. | ||
65 | + */ | ||
66 | + private String reference; | ||
67 | + | ||
68 | + /** | ||
69 | + * Status of the ENUM value. | ||
70 | + */ | ||
71 | + private YangStatusType status; | ||
72 | + | ||
73 | + /** | ||
74 | + * value of ENUM. | ||
75 | + */ | ||
76 | + private int value; | ||
77 | + | ||
78 | + /** | ||
79 | + * Create a YANG ENUM. | ||
80 | + */ | ||
81 | + public YangEnum() { | ||
82 | + | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Get the named value. | ||
87 | + * | ||
88 | + * @return the named value. | ||
89 | + */ | ||
90 | + public String getNamedValue() { | ||
91 | + return namedValue; | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Set the named value. | ||
96 | + * | ||
97 | + * @param namedValue the named value to set. | ||
98 | + */ | ||
99 | + public void setNamedValue(String namedValue) { | ||
100 | + this.namedValue = namedValue; | ||
101 | + } | ||
102 | + | ||
103 | + /** | ||
104 | + * Get the description. | ||
105 | + * | ||
106 | + * @return the description. | ||
107 | + */ | ||
108 | + public String getDescription() { | ||
109 | + return description; | ||
110 | + } | ||
111 | + | ||
112 | + /** | ||
113 | + * Set the description. | ||
114 | + * | ||
115 | + * @param description set the description. | ||
116 | + */ | ||
117 | + public void setDescription(String description) { | ||
118 | + this.description = description; | ||
119 | + } | ||
120 | + | ||
121 | + /** | ||
122 | + * Get the textual reference. | ||
123 | + * | ||
124 | + * @return the reference. | ||
125 | + */ | ||
126 | + public String getReference() { | ||
127 | + return reference; | ||
128 | + } | ||
129 | + | ||
130 | + /** | ||
131 | + * Set the textual reference. | ||
132 | + * | ||
133 | + * @param reference the reference to set. | ||
134 | + */ | ||
135 | + public void setReference(String reference) { | ||
136 | + this.reference = reference; | ||
137 | + } | ||
138 | + | ||
139 | + /** | ||
140 | + * Get the status. | ||
141 | + * | ||
142 | + * @return the status. | ||
143 | + */ | ||
144 | + public YangStatusType getStatus() { | ||
145 | + return status; | ||
146 | + } | ||
147 | + | ||
148 | + /** | ||
149 | + * Set the status. | ||
150 | + * | ||
151 | + * @param status the status to set. | ||
152 | + */ | ||
153 | + public void setStatus(YangStatusType status) { | ||
154 | + this.status = status; | ||
155 | + } | ||
156 | + | ||
157 | + /** | ||
158 | + * Get the value. | ||
159 | + * | ||
160 | + * @return the value. | ||
161 | + */ | ||
162 | + public int getValue() { | ||
163 | + return value; | ||
164 | + } | ||
165 | + | ||
166 | + /** | ||
167 | + * Set the value. | ||
168 | + * | ||
169 | + * @param value the value to set. | ||
170 | + */ | ||
171 | + public void setValue(int value) { | ||
172 | + this.value = value; | ||
173 | + } | ||
174 | + | ||
175 | + /** | ||
176 | + * Returns the type of the data. | ||
177 | + * | ||
178 | + * @return ParsedDataType returns ENUM_DATA | ||
179 | + */ | ||
180 | + public ParsableDataType getParsableDataType() { | ||
181 | + return ParsableDataType.ENUM_DATA; | ||
182 | + } | ||
183 | + | ||
184 | + /** | ||
185 | + * Validate the data on entering the corresponding parse tree node. | ||
186 | + * | ||
187 | + * @throws DataModelException a violation of data model rules. | ||
188 | + */ | ||
189 | + public void validateDataOnEntry() throws DataModelException { | ||
190 | + // TODO auto-generated method stub, to be implemented by parser | ||
191 | + } | ||
192 | + | ||
193 | + /** | ||
194 | + * Validate the data on exiting the corresponding parse tree node. | ||
195 | + * | ||
196 | + * @throws DataModelException a violation of data model rules. | ||
197 | + */ | ||
198 | + public void validateDataOnExit() throws DataModelException { | ||
199 | + // TODO auto-generated method stub, to be implemented by parser | ||
200 | + } | ||
201 | +} |
1 | +/* | ||
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 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.datamodel; | ||
18 | + | ||
19 | +import java.util.HashSet; | ||
20 | +import java.util.Set; | ||
21 | + | ||
22 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
23 | +import org.onosproject.yangutils.parser.Parsable; | ||
24 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
25 | + | ||
26 | +/* | ||
27 | + * The enumeration built-in type represents values from a set of | ||
28 | + * assigned names. | ||
29 | + */ | ||
30 | + | ||
31 | +/** | ||
32 | + * Maintains the enumeration data type information. | ||
33 | + */ | ||
34 | +public class YangEnumeration extends YangNode implements Parsable { | ||
35 | + | ||
36 | + /** | ||
37 | + * Enumeration info set. | ||
38 | + */ | ||
39 | + private Set<YangEnum> enumSet; | ||
40 | + | ||
41 | + /** | ||
42 | + * Create an enumeration object. | ||
43 | + */ | ||
44 | + public YangEnumeration() { | ||
45 | + super(YangNodeType.ENUMERATION_NODE); | ||
46 | + setEnumSet(new HashSet<YangEnum>()); | ||
47 | + | ||
48 | + } | ||
49 | + | ||
50 | + /** | ||
51 | + * Get the ENUM set. | ||
52 | + * | ||
53 | + * @return the ENUM set | ||
54 | + */ | ||
55 | + public Set<YangEnum> getEnumSet() { | ||
56 | + return enumSet; | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * Set the ENUM set. | ||
61 | + * | ||
62 | + * @param enumSet the ENUM set to set | ||
63 | + */ | ||
64 | + private void setEnumSet(Set<YangEnum> enumSet) { | ||
65 | + this.enumSet = enumSet; | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * Add ENUM value. | ||
70 | + * | ||
71 | + * @param enumInfo the ENUM value of string | ||
72 | + */ | ||
73 | + public void addEnumInfo(YangEnum enumInfo) { | ||
74 | + | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * Returns the type of the data. | ||
79 | + * | ||
80 | + * @return returns ENUMERATION_DATA | ||
81 | + */ | ||
82 | + public ParsableDataType getParsableDataType() { | ||
83 | + return ParsableDataType.ENUMERATION_DATA; | ||
84 | + } | ||
85 | + | ||
86 | + /** | ||
87 | + * Validate the data on entering the corresponding parse tree node. | ||
88 | + * | ||
89 | + * @throws DataModelException a violation of data model rules. | ||
90 | + */ | ||
91 | + public void validateDataOnEntry() throws DataModelException { | ||
92 | + // TODO auto-generated method stub, to be implemented by parser | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * Validate the data on exiting the corresponding parse tree node. | ||
97 | + * | ||
98 | + * @throws DataModelException a violation of data model rules. | ||
99 | + */ | ||
100 | + public void validateDataOnExit() throws DataModelException { | ||
101 | + // TODO auto-generated method stub, to be implemented by parser | ||
102 | + } | ||
103 | + | ||
104 | + /* (non-Javadoc) | ||
105 | + * @see org.onosproject.yangutils.datamodel.YangNode#getName() | ||
106 | + */ | ||
107 | + @Override | ||
108 | + public String getName() { | ||
109 | + // TODO Auto-generated method stub | ||
110 | + return null; | ||
111 | + } | ||
112 | + | ||
113 | + /* (non-Javadoc) | ||
114 | + * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String) | ||
115 | + */ | ||
116 | + @Override | ||
117 | + public void setName(String name) { | ||
118 | + // TODO Auto-generated method stub | ||
119 | + | ||
120 | + } | ||
121 | + | ||
122 | + /* (non-Javadoc) | ||
123 | + * @see org.onosproject.yangutils.datamodel.YangNode#getPackage() | ||
124 | + */ | ||
125 | + @Override | ||
126 | + public String getPackage() { | ||
127 | + // TODO Auto-generated method stub | ||
128 | + return null; | ||
129 | + } | ||
130 | + | ||
131 | + /* (non-Javadoc) | ||
132 | + * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String) | ||
133 | + */ | ||
134 | + @Override | ||
135 | + public void setPackage(String pkg) { | ||
136 | + // TODO Auto-generated method stub | ||
137 | + | ||
138 | + } | ||
139 | + | ||
140 | + /* (non-Javadoc) | ||
141 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | ||
142 | + */ | ||
143 | + public void generateJavaCodeEntry() { | ||
144 | + // TODO Auto-generated method stub | ||
145 | + | ||
146 | + } | ||
147 | + | ||
148 | + /* (non-Javadoc) | ||
149 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | ||
150 | + */ | ||
151 | + public void generateJavaCodeExit() { | ||
152 | + // TODO Auto-generated method stub | ||
153 | + | ||
154 | + } | ||
155 | +} |
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +import java.util.LinkedList; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
22 | +import org.onosproject.yangutils.parser.Parsable; | ||
23 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
24 | + | ||
25 | +/*- | ||
26 | + * Reference RFC 6020. | ||
27 | + * | ||
28 | + * The "grouping" statement is used to define a reusable block of nodes, | ||
29 | + * which may be used locally in the module, in modules that include it, | ||
30 | + * and by other modules that import from it. It takes one argument, | ||
31 | + * which is an identifier, followed by a block of sub-statements that | ||
32 | + * holds detailed grouping information. | ||
33 | + * | ||
34 | + * The "grouping" statement is not a data definition statement and, as | ||
35 | + * such, does not define any nodes in the schema tree. | ||
36 | + * | ||
37 | + * A grouping is like a "structure" or a "record" in conventional | ||
38 | + * programming languages. | ||
39 | + * Once a grouping is defined, it can be referenced in a "uses" | ||
40 | + * statement. A grouping MUST NOT reference itself, | ||
41 | + * neither directly nor indirectly through a chain of other groupings. | ||
42 | + * | ||
43 | + * If the grouping is defined at the top level of a YANG module or | ||
44 | + * submodule, the grouping's identifier MUST be unique within the | ||
45 | + * module. | ||
46 | + * | ||
47 | + * A grouping is more than just a mechanism for textual substitution, | ||
48 | + * but defines a collection of nodes. Identifiers appearing inside the | ||
49 | + * grouping are resolved relative to the scope in which the grouping is | ||
50 | + * defined, not where it is used. Prefix mappings, type names, grouping | ||
51 | + * names, and extension usage are evaluated in the hierarchy where the | ||
52 | + * "grouping" statement appears. For extensions, this means that | ||
53 | + * extensions are applied to the grouping node, not the uses node. | ||
54 | + * | ||
55 | + * The grouping's sub-statements | ||
56 | + * | ||
57 | + * +--------------+---------+-------------+------------------+ | ||
58 | + * | substatement | section | cardinality |data model mapping| | ||
59 | + * +--------------+---------+-------------+------------------+ | ||
60 | + * | anyxml | 7.10 | 0..n |-not supported | | ||
61 | + * | choice | 7.9 | 0..n |-child nodes | | ||
62 | + * | container | 7.5 | 0..n |-child nodes | | ||
63 | + * | description | 7.19.3 | 0..1 |-string | | ||
64 | + * | grouping | 7.11 | 0..n |-child nodes | | ||
65 | + * | leaf | 7.6 | 0..n |-YangLeaf | | ||
66 | + * | leaf-list | 7.7 | 0..n |-YangLeafList | | ||
67 | + * | list | 7.8 | 0..n |-child nodes | | ||
68 | + * | reference | 7.19.4 | 0..1 |-string | | ||
69 | + * | status | 7.19.2 | 0..1 |-YangStatus | | ||
70 | + * | typedef | 7.3 | 0..n |-child nodes | | ||
71 | + * | uses | 7.12 | 0..n |-child nodes | | ||
72 | + * +--------------+---------+-------------+------------------+ | ||
73 | + */ | ||
74 | + | ||
75 | +/** | ||
76 | + * Data model node to maintain information defined in YANG grouping. | ||
77 | + */ | ||
78 | +public class YangGrouping extends YangNode | ||
79 | + implements YangLeavesHolder, YangCommonInfo, Parsable { | ||
80 | + | ||
81 | + /** | ||
82 | + * Name of the grouping. | ||
83 | + */ | ||
84 | + private String name; | ||
85 | + | ||
86 | + /** | ||
87 | + * Description. | ||
88 | + */ | ||
89 | + private String description; | ||
90 | + | ||
91 | + /** | ||
92 | + * List of leaves. | ||
93 | + */ | ||
94 | + @SuppressWarnings("rawtypes") | ||
95 | + private List<YangLeaf> listOfLeaf; | ||
96 | + | ||
97 | + /** | ||
98 | + * List of leaf lists. | ||
99 | + */ | ||
100 | + @SuppressWarnings("rawtypes") | ||
101 | + private List<YangLeafList> listOfLeafList; | ||
102 | + | ||
103 | + /** | ||
104 | + * Reference of the module. | ||
105 | + */ | ||
106 | + private String reference; | ||
107 | + | ||
108 | + /** | ||
109 | + * Status of the node. | ||
110 | + */ | ||
111 | + private YangStatusType status; | ||
112 | + | ||
113 | + /** | ||
114 | + * Creates the grouping node. | ||
115 | + */ | ||
116 | + public YangGrouping() { | ||
117 | + super(YangNodeType.GROUPING_NODE); | ||
118 | + } | ||
119 | + | ||
120 | + /* (non-Javadoc) | ||
121 | + * @see org.onosproject.yangutils.datamodel.YangNode#getName() | ||
122 | + */ | ||
123 | + @Override | ||
124 | + public String getName() { | ||
125 | + return name; | ||
126 | + } | ||
127 | + | ||
128 | + /* (non-Javadoc) | ||
129 | + * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String) | ||
130 | + */ | ||
131 | + @Override | ||
132 | + public void setName(String name) { | ||
133 | + this.name = name; | ||
134 | + } | ||
135 | + | ||
136 | + /** | ||
137 | + * Get the description. | ||
138 | + * | ||
139 | + * @return the description. | ||
140 | + */ | ||
141 | + public String getDescription() { | ||
142 | + return description; | ||
143 | + } | ||
144 | + | ||
145 | + /** | ||
146 | + * Set the description. | ||
147 | + * | ||
148 | + * @param description set the description. | ||
149 | + */ | ||
150 | + public void setDescription(String description) { | ||
151 | + this.description = description; | ||
152 | + } | ||
153 | + | ||
154 | + /** | ||
155 | + * Get the list of leaves. | ||
156 | + * | ||
157 | + * @return the list of leaves. | ||
158 | + */ | ||
159 | + @SuppressWarnings("rawtypes") | ||
160 | + public List<YangLeaf> getListOfLeaf() { | ||
161 | + return listOfLeaf; | ||
162 | + } | ||
163 | + | ||
164 | + /** | ||
165 | + * Set the list of leaves. | ||
166 | + * | ||
167 | + * @param leafsList the list of leaf to set. | ||
168 | + */ | ||
169 | + @SuppressWarnings("rawtypes") | ||
170 | + private void setListOfLeaf(List<YangLeaf> leafsList) { | ||
171 | + listOfLeaf = leafsList; | ||
172 | + } | ||
173 | + | ||
174 | + /** | ||
175 | + * Add a leaf. | ||
176 | + * | ||
177 | + * @param leaf the leaf to be added. | ||
178 | + */ | ||
179 | + @SuppressWarnings("rawtypes") | ||
180 | + public void addLeaf(YangLeaf<?> leaf) { | ||
181 | + if (getListOfLeaf() == null) { | ||
182 | + setListOfLeaf(new LinkedList<YangLeaf>()); | ||
183 | + } | ||
184 | + | ||
185 | + getListOfLeaf().add(leaf); | ||
186 | + } | ||
187 | + | ||
188 | + /** | ||
189 | + * Get the list of leaf-list. | ||
190 | + * | ||
191 | + * @return the list of leaf-list. | ||
192 | + */ | ||
193 | + @SuppressWarnings("rawtypes") | ||
194 | + public List<YangLeafList> getListOfLeafList() { | ||
195 | + return listOfLeafList; | ||
196 | + } | ||
197 | + | ||
198 | + /** | ||
199 | + * Set the list of leaf-list. | ||
200 | + * | ||
201 | + * @param listOfLeafList the list of leaf-list to set. | ||
202 | + */ | ||
203 | + @SuppressWarnings("rawtypes") | ||
204 | + private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | ||
205 | + this.listOfLeafList = listOfLeafList; | ||
206 | + } | ||
207 | + | ||
208 | + /** | ||
209 | + * Add a leaf-list. | ||
210 | + * | ||
211 | + * @param leafList the leaf-list to be added. | ||
212 | + */ | ||
213 | + @SuppressWarnings("rawtypes") | ||
214 | + public void addLeafList(YangLeafList<?> leafList) { | ||
215 | + if (getListOfLeafList() == null) { | ||
216 | + setListOfLeafList(new LinkedList<YangLeafList>()); | ||
217 | + } | ||
218 | + | ||
219 | + getListOfLeafList().add(leafList); | ||
220 | + } | ||
221 | + | ||
222 | + /** | ||
223 | + * Get the textual reference. | ||
224 | + * | ||
225 | + * @return the reference. | ||
226 | + */ | ||
227 | + public String getReference() { | ||
228 | + return reference; | ||
229 | + } | ||
230 | + | ||
231 | + /** | ||
232 | + * Set the textual reference. | ||
233 | + * | ||
234 | + * @param reference the reference to set. | ||
235 | + */ | ||
236 | + public void setReference(String reference) { | ||
237 | + this.reference = reference; | ||
238 | + } | ||
239 | + | ||
240 | + /** | ||
241 | + * Get the status. | ||
242 | + * | ||
243 | + * @return the status. | ||
244 | + */ | ||
245 | + public YangStatusType getStatus() { | ||
246 | + return status; | ||
247 | + } | ||
248 | + | ||
249 | + /** | ||
250 | + * Set the status. | ||
251 | + * | ||
252 | + * @param status the status to set. | ||
253 | + */ | ||
254 | + public void setStatus(YangStatusType status) { | ||
255 | + this.status = status; | ||
256 | + } | ||
257 | + | ||
258 | + /** | ||
259 | + * Returns the type of the data. | ||
260 | + * | ||
261 | + * @return returns GROUPING_DATA. | ||
262 | + */ | ||
263 | + public ParsableDataType getParsableDataType() { | ||
264 | + return ParsableDataType.GROUPING_DATA; | ||
265 | + } | ||
266 | + | ||
267 | + /** | ||
268 | + * Validate the data on entering the corresponding parse tree node. | ||
269 | + * | ||
270 | + * @throws DataModelException a violation of data model rules. | ||
271 | + */ | ||
272 | + public void validateDataOnEntry() throws DataModelException { | ||
273 | + // TODO auto-generated method stub, to be implemented by parser | ||
274 | + } | ||
275 | + | ||
276 | + /** | ||
277 | + * Validate the data on exiting the corresponding parse tree node. | ||
278 | + * | ||
279 | + * @throws DataModelException a violation of data model rules. | ||
280 | + */ | ||
281 | + public void validateDataOnExit() throws DataModelException { | ||
282 | + // TODO auto-generated method stub, to be implemented by parser | ||
283 | + } | ||
284 | + | ||
285 | + /* (non-Javadoc) | ||
286 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | ||
287 | + */ | ||
288 | + public void generateJavaCodeEntry() { | ||
289 | + // TODO Auto-generated method stub | ||
290 | + | ||
291 | + } | ||
292 | + | ||
293 | + /* (non-Javadoc) | ||
294 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | ||
295 | + */ | ||
296 | + public void generateJavaCodeExit() { | ||
297 | + // TODO Auto-generated method stub | ||
298 | + | ||
299 | + } | ||
300 | + | ||
301 | + /* (non-Javadoc) | ||
302 | + * @see org.onosproject.yangutils.datamodel.YangNode#getPackage() | ||
303 | + */ | ||
304 | + @Override | ||
305 | + public String getPackage() { | ||
306 | + // TODO Auto-generated method stub | ||
307 | + return null; | ||
308 | + } | ||
309 | + | ||
310 | + /* (non-Javadoc) | ||
311 | + * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String) | ||
312 | + */ | ||
313 | + @Override | ||
314 | + public void setPackage(String pkg) { | ||
315 | + // TODO Auto-generated method stub | ||
316 | + | ||
317 | + } | ||
318 | +} |
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
19 | +import org.onosproject.yangutils.parser.Parsable; | ||
20 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
21 | + | ||
22 | +/*- | ||
23 | + * The "must" statement, which is optional, takes as an argument a string that | ||
24 | + * contains an XPath expression. It is used to formally declare a constraint | ||
25 | + * on valid data. | ||
26 | + * | ||
27 | + * When a datastore is validated, all "must" constraints are conceptually | ||
28 | + * evaluated once for each data node in the data tree, and for all leafs with | ||
29 | + * default values in use. If a data node does not exist in the data tree, and | ||
30 | + * it does not have a default value, its "must" statements are not evaluated. | ||
31 | + * | ||
32 | + * All such constraints MUST evaluate to true for the data to be valid. | ||
33 | + * | ||
34 | + * The must's sub-statements | ||
35 | + * | ||
36 | + * +---------------+---------+-------------+------------------+ | ||
37 | + * | substatement | section | cardinality |data model mapping| | ||
38 | + * +---------------+---------+-------------+------------------+ | ||
39 | + * | description | 7.19.3 | 0..1 | -string | | ||
40 | + * | error-app-tag | 7.5.4.2 | 0..1 | -not supported | | ||
41 | + * | error-message | 7.5.4.1 | 0..1 | -not supported | | ||
42 | + * | reference | 7.19.4 | 0..1 | -string | | ||
43 | + * +---------------+---------+-------------+------------------+ | ||
44 | + */ | ||
45 | + | ||
46 | +/** | ||
47 | + * Maintain information defined in YANG must. | ||
48 | + */ | ||
49 | +public class YangMust implements YangDesc, YangReference, Parsable { | ||
50 | + | ||
51 | + /** | ||
52 | + * Constraint info. | ||
53 | + */ | ||
54 | + private String constratint; | ||
55 | + | ||
56 | + /** | ||
57 | + * Description string. | ||
58 | + */ | ||
59 | + private String description; | ||
60 | + | ||
61 | + /** | ||
62 | + * reference string. | ||
63 | + */ | ||
64 | + private String reference; | ||
65 | + | ||
66 | + /** | ||
67 | + * Create a YANG must restriction. | ||
68 | + */ | ||
69 | + public YangMust() { | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * Get the constraint. | ||
74 | + * | ||
75 | + * @return the constraint. | ||
76 | + */ | ||
77 | + public String getConstratint() { | ||
78 | + return constratint; | ||
79 | + } | ||
80 | + | ||
81 | + /** | ||
82 | + * Set the constraint. | ||
83 | + * | ||
84 | + * @param constratint the constraint to set | ||
85 | + */ | ||
86 | + public void setConstratint(String constratint) { | ||
87 | + this.constratint = constratint; | ||
88 | + } | ||
89 | + | ||
90 | + /** | ||
91 | + * Get the description. | ||
92 | + * | ||
93 | + * @return the description. | ||
94 | + */ | ||
95 | + public String getDescription() { | ||
96 | + return description; | ||
97 | + } | ||
98 | + | ||
99 | + /** | ||
100 | + * Set the description. | ||
101 | + * | ||
102 | + * @param description set the description. | ||
103 | + */ | ||
104 | + public void setDescription(String description) { | ||
105 | + this.description = description; | ||
106 | + } | ||
107 | + | ||
108 | + /** | ||
109 | + * Get the textual reference. | ||
110 | + * | ||
111 | + * @return the reference. | ||
112 | + */ | ||
113 | + public String getReference() { | ||
114 | + return reference; | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Set the textual reference. | ||
119 | + * | ||
120 | + * @param reference the reference to set. | ||
121 | + */ | ||
122 | + public void setReference(String reference) { | ||
123 | + this.reference = reference; | ||
124 | + } | ||
125 | + | ||
126 | + /** | ||
127 | + * Returns the type of the parsed data. | ||
128 | + * | ||
129 | + * @return returns MUST_DATA | ||
130 | + */ | ||
131 | + public ParsableDataType getParsableDataType() { | ||
132 | + return ParsableDataType.MUST_DATA; | ||
133 | + } | ||
134 | + | ||
135 | + /** | ||
136 | + * Validate the data on entering the corresponding parse tree node. | ||
137 | + * | ||
138 | + * @throws DataModelException a violation of data model rules. | ||
139 | + */ | ||
140 | + public void validateDataOnEntry() throws DataModelException { | ||
141 | + // TODO auto-generated method stub, to be implemented by parser | ||
142 | + } | ||
143 | + | ||
144 | + /** | ||
145 | + * Validate the data on exiting the corresponding parse tree node. | ||
146 | + * | ||
147 | + * @throws DataModelException a violation of data model rules. | ||
148 | + */ | ||
149 | + public void validateDataOnExit() throws DataModelException { | ||
150 | + // TODO auto-generated method stub, to be implemented by parser | ||
151 | + } | ||
152 | +} |
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
19 | +import org.onosproject.yangutils.parser.Parsable; | ||
20 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
21 | + | ||
22 | +/*- | ||
23 | + * Reference RFC 6020. | ||
24 | + * | ||
25 | + * The "typedef" statement defines a new type that may be used locally in the | ||
26 | + * module, in modules or submodules which include it, and by other modules that | ||
27 | + * import from it. The new type is called the "derived type", and the type from | ||
28 | + * which it was derived is called the "base type". All derived types can be | ||
29 | + * traced back to a YANG built-in type. | ||
30 | + * | ||
31 | + * The "typedef" statement's argument is an identifier that is the name of the | ||
32 | + * type to be defined, and MUST be followed by a block of sub-statements that | ||
33 | + * holds detailed typedef information. | ||
34 | + * | ||
35 | + * The name of the type MUST NOT be one of the YANG built-in types. If the | ||
36 | + * typedef is defined at the top level of a YANG module or submodule, the name | ||
37 | + * of the type to be defined MUST be unique within the module. | ||
38 | + * The typedef's sub-statements | ||
39 | + * | ||
40 | + * +--------------+---------+-------------+------------------+ | ||
41 | + * | substatement | section | cardinality |data model mapping| | ||
42 | + * +--------------+---------+-------------+------------------+ | ||
43 | + * | default | 7.3.4 | 0..1 |-string | | ||
44 | + * | description | 7.19.3 | 0..1 |-string | | ||
45 | + * | reference | 7.19.4 | 0..1 |-string | | ||
46 | + * | status | 7.19.2 | 0..1 |-YangStatus | | ||
47 | + * | type | 7.3.2 | 1 |-yangType | | ||
48 | + * | units | 7.3.3 | 0..1 |-string | | ||
49 | + * +--------------+---------+-------------+------------------+ | ||
50 | + */ | ||
51 | +/** | ||
52 | + * Data model node to maintain information defined in YANG typedef. | ||
53 | + */ | ||
54 | +public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ||
55 | + | ||
56 | + /** | ||
57 | + * Name of derived data type. | ||
58 | + */ | ||
59 | + private String derivedName; | ||
60 | + | ||
61 | + /** | ||
62 | + * Default value in string, needs to be converted to the target object, | ||
63 | + * based on the type. | ||
64 | + */ | ||
65 | + private String defaultValueInString; | ||
66 | + | ||
67 | + /** | ||
68 | + * Description of new type. | ||
69 | + */ | ||
70 | + private String description; | ||
71 | + | ||
72 | + /** | ||
73 | + * reference string. | ||
74 | + */ | ||
75 | + private String reference; | ||
76 | + | ||
77 | + /** | ||
78 | + * Status of the data type. | ||
79 | + */ | ||
80 | + private YangStatusType status; | ||
81 | + | ||
82 | + /** | ||
83 | + * Derived data type. | ||
84 | + */ | ||
85 | + @SuppressWarnings("rawtypes") | ||
86 | + private YangType derivedType; | ||
87 | + | ||
88 | + /** | ||
89 | + * Units of the data type. | ||
90 | + */ | ||
91 | + private String units; | ||
92 | + | ||
93 | + /** | ||
94 | + * Create a typedef node. | ||
95 | + */ | ||
96 | + public YangTypeDef() { | ||
97 | + super(YangNodeType.TYPEDEF_NODE); | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * Get the data type name. | ||
102 | + * | ||
103 | + * @return the data type name. | ||
104 | + */ | ||
105 | + public String getDerivedName() { | ||
106 | + return derivedName; | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
110 | + * Set the data type name. | ||
111 | + * | ||
112 | + * @param derrivedName data type name. | ||
113 | + */ | ||
114 | + public void setDerivedName(String derrivedName) { | ||
115 | + derivedName = derrivedName; | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * Get the default value. | ||
120 | + * | ||
121 | + * @return the default value. | ||
122 | + */ | ||
123 | + public String getDefaultValueInString() { | ||
124 | + return defaultValueInString; | ||
125 | + } | ||
126 | + | ||
127 | + /** | ||
128 | + * Set the default value. | ||
129 | + * | ||
130 | + * @param defaultValueInString the default value. | ||
131 | + */ | ||
132 | + public void setDefaultValueInString(String defaultValueInString) { | ||
133 | + this.defaultValueInString = defaultValueInString; | ||
134 | + } | ||
135 | + | ||
136 | + /** | ||
137 | + * Get the description. | ||
138 | + * | ||
139 | + * @return the description. | ||
140 | + */ | ||
141 | + public String getDescription() { | ||
142 | + return description; | ||
143 | + } | ||
144 | + | ||
145 | + /** | ||
146 | + * Set the description. | ||
147 | + * | ||
148 | + * @param description set the description. | ||
149 | + */ | ||
150 | + public void setDescription(String description) { | ||
151 | + this.description = description; | ||
152 | + } | ||
153 | + | ||
154 | + /** | ||
155 | + * Get the textual reference. | ||
156 | + * | ||
157 | + * @return the reference. | ||
158 | + */ | ||
159 | + public String getReference() { | ||
160 | + return reference; | ||
161 | + } | ||
162 | + | ||
163 | + /** | ||
164 | + * Set the textual reference. | ||
165 | + * | ||
166 | + * @param reference the reference to set. | ||
167 | + */ | ||
168 | + public void setReference(String reference) { | ||
169 | + this.reference = reference; | ||
170 | + } | ||
171 | + | ||
172 | + /** | ||
173 | + * Get the status. | ||
174 | + * | ||
175 | + * @return the status. | ||
176 | + */ | ||
177 | + public YangStatusType getStatus() { | ||
178 | + return status; | ||
179 | + } | ||
180 | + | ||
181 | + /** | ||
182 | + * Set the status. | ||
183 | + * | ||
184 | + * @param status the status to set. | ||
185 | + */ | ||
186 | + public void setStatus(YangStatusType status) { | ||
187 | + this.status = status; | ||
188 | + } | ||
189 | + | ||
190 | + /** | ||
191 | + * Get the referenced type. | ||
192 | + * | ||
193 | + * @return the referenced type. | ||
194 | + */ | ||
195 | + @SuppressWarnings("rawtypes") | ||
196 | + public YangType getDerivedType() { | ||
197 | + return derivedType; | ||
198 | + } | ||
199 | + | ||
200 | + /** | ||
201 | + * Get the referenced type. | ||
202 | + * | ||
203 | + * @param derivedType the referenced type. | ||
204 | + */ | ||
205 | + @SuppressWarnings("rawtypes") | ||
206 | + public void setDerivedType(YangType derivedType) { | ||
207 | + this.derivedType = derivedType; | ||
208 | + } | ||
209 | + | ||
210 | + /** | ||
211 | + * Get the unit. | ||
212 | + * | ||
213 | + * @return the units | ||
214 | + */ | ||
215 | + public String getUnits() { | ||
216 | + return units; | ||
217 | + } | ||
218 | + | ||
219 | + /** | ||
220 | + * Set the unit. | ||
221 | + * | ||
222 | + * @param units the units to set | ||
223 | + */ | ||
224 | + public void setUnits(String units) { | ||
225 | + this.units = units; | ||
226 | + } | ||
227 | + | ||
228 | + /** | ||
229 | + * Returns the type of the data. | ||
230 | + * | ||
231 | + * @return returns TYPEDEF_DATA | ||
232 | + */ | ||
233 | + public ParsableDataType getParsableDataType() { | ||
234 | + return ParsableDataType.TYPEDEF_DATA; | ||
235 | + } | ||
236 | + | ||
237 | + /** | ||
238 | + * Validate the data on entering the corresponding parse tree node. | ||
239 | + * | ||
240 | + * @throws DataModelException a violation of data model rules. | ||
241 | + */ | ||
242 | + public void validateDataOnEntry() throws DataModelException { | ||
243 | + // TODO auto-generated method stub, to be implemented by parser | ||
244 | + } | ||
245 | + | ||
246 | + /** | ||
247 | + * Validate the data on exiting the corresponding parse tree node. | ||
248 | + * | ||
249 | + * @throws DataModelException a violation of data model rules. | ||
250 | + */ | ||
251 | + public void validateDataOnExit() throws DataModelException { | ||
252 | + // TODO auto-generated method stub, to be implemented by parser | ||
253 | + } | ||
254 | + | ||
255 | + /* (non-Javadoc) | ||
256 | + * @see org.onosproject.yangutils.datamodel.YangNode#getName() | ||
257 | + */ | ||
258 | + @Override | ||
259 | + public String getName() { | ||
260 | + // TODO Auto-generated method stub | ||
261 | + return null; | ||
262 | + } | ||
263 | + | ||
264 | + /* (non-Javadoc) | ||
265 | + * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String) | ||
266 | + */ | ||
267 | + @Override | ||
268 | + public void setName(String name) { | ||
269 | + // TODO Auto-generated method stub | ||
270 | + | ||
271 | + } | ||
272 | + | ||
273 | + /* (non-Javadoc) | ||
274 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | ||
275 | + */ | ||
276 | + public void generateJavaCodeEntry() { | ||
277 | + // TODO Auto-generated method stub | ||
278 | + | ||
279 | + } | ||
280 | + | ||
281 | + /* (non-Javadoc) | ||
282 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | ||
283 | + */ | ||
284 | + public void generateJavaCodeExit() { | ||
285 | + // TODO Auto-generated method stub | ||
286 | + | ||
287 | + } | ||
288 | + | ||
289 | + /* (non-Javadoc) | ||
290 | + * @see org.onosproject.yangutils.datamodel.YangNode#getPackage() | ||
291 | + */ | ||
292 | + @Override | ||
293 | + public String getPackage() { | ||
294 | + // TODO Auto-generated method stub | ||
295 | + return null; | ||
296 | + } | ||
297 | + | ||
298 | + /* (non-Javadoc) | ||
299 | + * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String) | ||
300 | + */ | ||
301 | + @Override | ||
302 | + public void setPackage(String pkg) { | ||
303 | + // TODO Auto-generated method stub | ||
304 | + | ||
305 | + } | ||
306 | +} |
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
19 | +import org.onosproject.yangutils.parser.Parsable; | ||
20 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
21 | + | ||
22 | +/*- | ||
23 | + * Reference RFC 6020. | ||
24 | + * | ||
25 | + * The "uses" statement is used to reference a "grouping" definition. It takes | ||
26 | + * one argument, which is the name of the grouping. | ||
27 | + * | ||
28 | + * The effect of a "uses" reference to a grouping is that the nodes defined by | ||
29 | + * the grouping are copied into the current schema tree, and then updated | ||
30 | + * according to the "refine" and "augment" statements. | ||
31 | + * | ||
32 | + * The identifiers defined in the grouping are not bound to a namespace until | ||
33 | + * the contents of the grouping are added to the schema tree via a "uses" | ||
34 | + * statement that does not appear inside a "grouping" statement, at which point | ||
35 | + * they are bound to the namespace of the current module. | ||
36 | + * | ||
37 | + * The uses's sub-statements | ||
38 | + * | ||
39 | + * +--------------+---------+-------------+------------------+ | ||
40 | + * | substatement | section | cardinality |data model mapping| | ||
41 | + * +--------------+---------+-------------+------------------+ | ||
42 | + * | augment | 7.15 | 0..1 | -child nodes | | ||
43 | + * | description | 7.19.3 | 0..1 | -string | | ||
44 | + * | if-feature | 7.18.2 | 0..n | -TODO | | ||
45 | + * | refine | 7.12.2 | 0..1 | -TODO | | ||
46 | + * | reference | 7.19.4 | 0..1 | -string | | ||
47 | + * | status | 7.19.2 | 0..1 | -YangStatus | | ||
48 | + * | when | 7.19.5 | 0..1 | -TODO | | ||
49 | + * +--------------+---------+-------------+------------------+ | ||
50 | + */ | ||
51 | +/** | ||
52 | + * Data model node to maintain information defined in YANG uses. | ||
53 | + * | ||
54 | + */ | ||
55 | +public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ||
56 | + | ||
57 | + /** | ||
58 | + * Name. | ||
59 | + */ | ||
60 | + private String name; | ||
61 | + | ||
62 | + /** | ||
63 | + * referred group. | ||
64 | + */ | ||
65 | + private YangGrouping refGroup; | ||
66 | + | ||
67 | + /** | ||
68 | + * description. | ||
69 | + */ | ||
70 | + private String description; | ||
71 | + | ||
72 | + /** | ||
73 | + * YANG reference. | ||
74 | + */ | ||
75 | + private String reference; | ||
76 | + | ||
77 | + /** | ||
78 | + * Status. | ||
79 | + */ | ||
80 | + private YangStatusType status; | ||
81 | + | ||
82 | + /** | ||
83 | + * Create an YANG uses node. | ||
84 | + */ | ||
85 | + public YangUses() { | ||
86 | + super(YangNodeType.USES_NODE); | ||
87 | + } | ||
88 | + | ||
89 | + /** | ||
90 | + * Get the name. | ||
91 | + * | ||
92 | + * @return the name. | ||
93 | + */ | ||
94 | + public String getRefGroupingName() { | ||
95 | + return name; | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * Set the name. | ||
100 | + * | ||
101 | + * @param refGroupingName the referred grouping name to set | ||
102 | + */ | ||
103 | + public void setRefGroupingName(String refGroupingName) { | ||
104 | + name = refGroupingName; | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
108 | + * Get the referred group. | ||
109 | + * | ||
110 | + * @return the referred group. | ||
111 | + */ | ||
112 | + public YangGrouping getRefGroup() { | ||
113 | + return refGroup; | ||
114 | + } | ||
115 | + | ||
116 | + /** | ||
117 | + * Set the referred group. | ||
118 | + * | ||
119 | + * @param refGroup the referred group. | ||
120 | + */ | ||
121 | + public void setRefGroup(YangGrouping refGroup) { | ||
122 | + this.refGroup = refGroup; | ||
123 | + } | ||
124 | + | ||
125 | + /** | ||
126 | + * Get the description. | ||
127 | + * | ||
128 | + * @return the description. | ||
129 | + */ | ||
130 | + public String getDescription() { | ||
131 | + return description; | ||
132 | + } | ||
133 | + | ||
134 | + /** | ||
135 | + * Set the description. | ||
136 | + * | ||
137 | + * @param description set the description. | ||
138 | + */ | ||
139 | + public void setDescription(String description) { | ||
140 | + this.description = description; | ||
141 | + } | ||
142 | + | ||
143 | + /** | ||
144 | + * Get the textual reference. | ||
145 | + * | ||
146 | + * @return the reference. | ||
147 | + */ | ||
148 | + public String getReference() { | ||
149 | + return reference; | ||
150 | + } | ||
151 | + | ||
152 | + /** | ||
153 | + * Set the textual reference. | ||
154 | + * | ||
155 | + * @param reference the reference to set. | ||
156 | + */ | ||
157 | + public void setReference(String reference) { | ||
158 | + this.reference = reference; | ||
159 | + } | ||
160 | + | ||
161 | + /** | ||
162 | + * Get the status. | ||
163 | + * | ||
164 | + * @return the status. | ||
165 | + */ | ||
166 | + public YangStatusType getStatus() { | ||
167 | + return status; | ||
168 | + } | ||
169 | + | ||
170 | + /** | ||
171 | + * Set the status. | ||
172 | + * | ||
173 | + * @param status the status to set. | ||
174 | + */ | ||
175 | + public void setStatus(YangStatusType status) { | ||
176 | + this.status = status; | ||
177 | + } | ||
178 | + | ||
179 | + /** | ||
180 | + * Returns the type of the data. | ||
181 | + * | ||
182 | + * @return returns USES_DATA. | ||
183 | + */ | ||
184 | + public ParsableDataType getParsableDataType() { | ||
185 | + return ParsableDataType.USES_DATA; | ||
186 | + } | ||
187 | + | ||
188 | + /** | ||
189 | + * Validate the data on entering the corresponding parse tree node. | ||
190 | + * | ||
191 | + * @throws DataModelException a violation of data model rules. | ||
192 | + */ | ||
193 | + public void validateDataOnEntry() throws DataModelException { | ||
194 | + // TODO auto-generated method stub, to be implemented by parser | ||
195 | + } | ||
196 | + | ||
197 | + /** | ||
198 | + * Validate the data on exiting the corresponding parse tree node. | ||
199 | + * | ||
200 | + * @throws DataModelException a violation of data model rules. | ||
201 | + */ | ||
202 | + public void validateDataOnExit() throws DataModelException { | ||
203 | + // TODO auto-generated method stub, to be implemented by parser | ||
204 | + } | ||
205 | + | ||
206 | + /* (non-Javadoc) | ||
207 | + * @see org.onosproject.yangutils.datamodel.YangNode#getName() | ||
208 | + */ | ||
209 | + @Override | ||
210 | + public String getName() { | ||
211 | + // TODO Auto-generated method stub | ||
212 | + return null; | ||
213 | + } | ||
214 | + | ||
215 | + /* (non-Javadoc) | ||
216 | + * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String) | ||
217 | + */ | ||
218 | + @Override | ||
219 | + public void setName(String name) { | ||
220 | + // TODO Auto-generated method stub | ||
221 | + | ||
222 | + } | ||
223 | + | ||
224 | + /* (non-Javadoc) | ||
225 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | ||
226 | + */ | ||
227 | + public void generateJavaCodeEntry() { | ||
228 | + // TODO Auto-generated method stub | ||
229 | + | ||
230 | + } | ||
231 | + | ||
232 | + /* (non-Javadoc) | ||
233 | + * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | ||
234 | + */ | ||
235 | + public void generateJavaCodeExit() { | ||
236 | + // TODO Auto-generated method stub | ||
237 | + | ||
238 | + } | ||
239 | + | ||
240 | + /* (non-Javadoc) | ||
241 | + * @see org.onosproject.yangutils.datamodel.YangNode#getPackage() | ||
242 | + */ | ||
243 | + @Override | ||
244 | + public String getPackage() { | ||
245 | + // TODO Auto-generated method stub | ||
246 | + return null; | ||
247 | + } | ||
248 | + | ||
249 | + /* (non-Javadoc) | ||
250 | + * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String) | ||
251 | + */ | ||
252 | + @Override | ||
253 | + public void setPackage(String pkg) { | ||
254 | + // TODO Auto-generated method stub | ||
255 | + | ||
256 | + } | ||
257 | +} |
-
Please register or login to post a comment