blob: 490b562e1e1b4ee8cd8e77b07047f22f82a990cc [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 org.onosproject.yangutils.datamodel.exceptions.DataModelException;
19import org.onosproject.yangutils.parser.Parsable;
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053020import org.onosproject.yangutils.utils.YangConstructType;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053021
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 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053055public class YangUses extends YangNode implements YangCommonInfo, Parsable, Resolvable {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053056
57 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053058 * YANG node identifier.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053059 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053060 private YangNodeIdentifier nodeIdentifier;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053061
62 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +053063 * Referred group.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053064 */
65 private YangGrouping refGroup;
66
67 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +053068 * Description of YANG uses.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053069 */
70 private String description;
71
72 /**
73 * YANG reference.
74 */
75 private String reference;
76
77 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +053078 * Status of YANG uses.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053079 */
80 private YangStatusType status;
81
82 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053083 * Status of resolution. If completely resolved enum value is "RESOLVED",
84 * if not enum value is "UNRESOLVED", in case reference of grouping/typedef
85 * is added to uses/type but it's not resolved value of enum should be
86 * "PARTIALLY_RESOLVED".
87 */
88 private ResolvableStatus resolvableStatus;
89
90 /**
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053091 * Create an YANG uses node.
92 */
93 public YangUses() {
94 super(YangNodeType.USES_NODE);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053095 nodeIdentifier = new YangNodeIdentifier();
96 resolvableStatus = ResolvableStatus.UNRESOLVED;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053097 }
98
99 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530100 * Returns the referred group.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530101 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530102 * @return the referred group
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530103 */
104 public YangGrouping getRefGroup() {
105 return refGroup;
106 }
107
108 /**
109 * Set the referred group.
110 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530111 * @param refGroup the referred group
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530112 */
113 public void setRefGroup(YangGrouping refGroup) {
114 this.refGroup = refGroup;
115 }
116
117 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530118 * Returns the description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530119 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530120 * @return the description
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530121 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530122 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530123 public String getDescription() {
124 return description;
125 }
126
127 /**
128 * Set the description.
129 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530130 * @param description set the description
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530131 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530132 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530133 public void setDescription(String description) {
134 this.description = description;
135 }
136
137 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530138 * Returns the textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530139 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530140 * @return the reference
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530141 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530142 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530143 public String getReference() {
144 return reference;
145 }
146
147 /**
148 * Set the textual reference.
149 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530150 * @param reference the reference to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530151 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530152 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530153 public void setReference(String reference) {
154 this.reference = reference;
155 }
156
157 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530158 * Returns the status.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530159 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530160 * @return the status
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530161 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530162 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530163 public YangStatusType getStatus() {
164 return status;
165 }
166
167 /**
168 * Set the status.
169 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530170 * @param status the status to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530171 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530172 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530173 public void setStatus(YangStatusType status) {
174 this.status = status;
175 }
176
177 /**
178 * Returns the type of the data.
179 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530180 * @return returns USES_DATA
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530181 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530182 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530183 public YangConstructType getYangConstructType() {
184 return YangConstructType.USES_DATA;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530185 }
186
187 /**
188 * Validate the data on entering the corresponding parse tree node.
189 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530190 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530191 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530192 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530193 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 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530200 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530201 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530202 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530203 public void validateDataOnExit() throws DataModelException {
204 // TODO auto-generated method stub, to be implemented by parser
205 }
206
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530207 @Override
208 public String getName() {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530209 return nodeIdentifier.getName();
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530210 }
211
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530212 @Override
213 public void setName(String name) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530214 nodeIdentifier.setName(name);
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530215 }
216
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530217 /**
218 * Returns node identifier.
219 *
220 * @return node identifier
221 */
222 public YangNodeIdentifier getNodeIdentifier() {
223 return nodeIdentifier;
224 }
225
226 /**
227 * Set node identifier.
228 *
229 * @param nodeIdentifier the node identifier
230 */
231 public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) {
232 this.nodeIdentifier = nodeIdentifier;
233 }
234
235 /**
236 * Returns prefix associated with uses.
237 *
238 * @return prefix associated with uses
239 */
240 public String getPrefix() {
241 return nodeIdentifier.getPrefix();
242 }
243
244 /**
245 * Get prefix associated with uses.
246 *
247 * @param prefix prefix associated with uses
248 */
249 public void setPrefix(String prefix) {
250 nodeIdentifier.setPrefix(prefix);
251 }
252
253 @Override
254 public void resolve() {
255 //TODO: implement the method.
256 }
257
258 @Override
259 public ResolvableStatus getResolvableStatus() {
260 return resolvableStatus;
261 }
262
263 @Override
264 public void setResolvableStatus(ResolvableStatus resolvableStatus) {
265 this.resolvableStatus = resolvableStatus;
266 }
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530267}