blob: 22b9700228c31c97defe7c7cf74f3c7cfbb3b501 [file] [log] [blame]
Vinod Kumar S2ff139c2016-02-16 01:37:16 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S2ff139c2016-02-16 01:37:16 +05303 *
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 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053051
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053052/**
Bharat saraswald9822e92016-04-05 15:13:44 +053053 * Represents data model node to maintain information defined in YANG uses.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053054 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053055public class YangUses
56 extends YangNode
57 implements YangCommonInfo, Parsable, Resolvable {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053058
59 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053060 * YANG node identifier.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053061 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053062 private YangNodeIdentifier nodeIdentifier;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053063
64 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +053065 * Referred group.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053066 */
67 private YangGrouping refGroup;
68
69 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +053070 * Description of YANG uses.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053071 */
72 private String description;
73
74 /**
75 * YANG reference.
76 */
77 private String reference;
78
79 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +053080 * Status of YANG uses.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053081 */
82 private YangStatusType status;
83
84 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053085 * Status of resolution. If completely resolved enum value is "RESOLVED",
86 * if not enum value is "UNRESOLVED", in case reference of grouping/typedef
87 * is added to uses/type but it's not resolved value of enum should be
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053088 * "INTRA_FILE_RESOLVED".
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053089 */
90 private ResolvableStatus resolvableStatus;
91
92 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053093 * Creates an YANG uses node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053094 */
95 public YangUses() {
96 super(YangNodeType.USES_NODE);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053097 nodeIdentifier = new YangNodeIdentifier();
98 resolvableStatus = ResolvableStatus.UNRESOLVED;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053099 }
100
101 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530102 * Returns the referred group.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530103 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530104 * @return the referred group
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530105 */
106 public YangGrouping getRefGroup() {
107 return refGroup;
108 }
109
110 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530111 * Sets the referred group.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530112 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530113 * @param refGroup the referred group
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530114 */
115 public void setRefGroup(YangGrouping refGroup) {
116 this.refGroup = refGroup;
117 }
118
119 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530120 * Returns the description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530121 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530122 * @return the description
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530123 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530124 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530125 public String getDescription() {
126 return description;
127 }
128
129 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530130 * Sets the description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530131 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530132 * @param description set the description
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530133 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530134 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530135 public void setDescription(String description) {
136 this.description = description;
137 }
138
139 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530140 * Returns the textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530141 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530142 * @return the reference
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530143 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530144 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530145 public String getReference() {
146 return reference;
147 }
148
149 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530150 * Sets the textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530151 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530152 * @param reference the reference to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530153 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530154 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530155 public void setReference(String reference) {
156 this.reference = reference;
157 }
158
159 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530160 * Returns the status.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530161 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530162 * @return the status
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530163 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530164 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530165 public YangStatusType getStatus() {
166 return status;
167 }
168
169 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530170 * Sets the status.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530171 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530172 * @param status the status to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530173 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530174 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530175 public void setStatus(YangStatusType status) {
176 this.status = status;
177 }
178
179 /**
180 * Returns the type of the data.
181 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530182 * @return returns USES_DATA
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530183 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530184 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530185 public YangConstructType getYangConstructType() {
186 return YangConstructType.USES_DATA;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530187 }
188
189 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530190 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530191 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530192 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530193 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530194 @Override
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530195 public void validateDataOnEntry()
196 throws DataModelException {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530197 // TODO auto-generated method stub, to be implemented by parser
198 }
199
200 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530201 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530202 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530203 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530204 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530205 @Override
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530206 public void validateDataOnExit()
207 throws DataModelException {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530208 // TODO auto-generated method stub, to be implemented by parser
209 }
210
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530211 @Override
212 public String getName() {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530213 return nodeIdentifier.getName();
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530214 }
215
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530216 @Override
217 public void setName(String name) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530218 nodeIdentifier.setName(name);
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530219 }
220
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530221 /**
222 * Returns node identifier.
223 *
224 * @return node identifier
225 */
226 public YangNodeIdentifier getNodeIdentifier() {
227 return nodeIdentifier;
228 }
229
230 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530231 * Sets node identifier.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530232 *
233 * @param nodeIdentifier the node identifier
234 */
235 public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) {
236 this.nodeIdentifier = nodeIdentifier;
237 }
238
239 /**
240 * Returns prefix associated with uses.
241 *
242 * @return prefix associated with uses
243 */
244 public String getPrefix() {
245 return nodeIdentifier.getPrefix();
246 }
247
248 /**
249 * Get prefix associated with uses.
250 *
251 * @param prefix prefix associated with uses
252 */
253 public void setPrefix(String prefix) {
254 nodeIdentifier.setPrefix(prefix);
255 }
256
257 @Override
258 public void resolve() {
259 //TODO: implement the method.
260 }
261
262 @Override
263 public ResolvableStatus getResolvableStatus() {
264 return resolvableStatus;
265 }
266
267 @Override
268 public void setResolvableStatus(ResolvableStatus resolvableStatus) {
269 this.resolvableStatus = resolvableStatus;
270 }
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530271}