blob: a1abb0d9d626e38f036acc50afb6779d9e962556 [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;
20import org.onosproject.yangutils.parser.ParsableDataType;
Bharat saraswal594bc6d2016-02-22 22:15:21 +053021import org.onosproject.yangutils.translator.CachedFileHandle;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053022
23/*-
24 * Reference RFC 6020.
25 *
26 * The "typedef" statement defines a new type that may be used locally in the
27 * module, in modules or submodules which include it, and by other modules that
28 * import from it. The new type is called the "derived type", and the type from
29 * which it was derived is called the "base type". All derived types can be
30 * traced back to a YANG built-in type.
31 *
32 * The "typedef" statement's argument is an identifier that is the name of the
33 * type to be defined, and MUST be followed by a block of sub-statements that
34 * holds detailed typedef information.
35 *
36 * The name of the type MUST NOT be one of the YANG built-in types. If the
37 * typedef is defined at the top level of a YANG module or submodule, the name
38 * of the type to be defined MUST be unique within the module.
39 * The typedef's sub-statements
40 *
41 * +--------------+---------+-------------+------------------+
42 * | substatement | section | cardinality |data model mapping|
43 * +--------------+---------+-------------+------------------+
44 * | default | 7.3.4 | 0..1 |-string |
45 * | description | 7.19.3 | 0..1 |-string |
46 * | reference | 7.19.4 | 0..1 |-string |
47 * | status | 7.19.2 | 0..1 |-YangStatus |
48 * | type | 7.3.2 | 1 |-yangType |
49 * | units | 7.3.3 | 0..1 |-string |
50 * +--------------+---------+-------------+------------------+
51 */
52/**
53 * Data model node to maintain information defined in YANG typedef.
54 */
55public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
56
57 /**
58 * Name of derived data type.
59 */
60 private String derivedName;
61
62 /**
63 * Default value in string, needs to be converted to the target object,
64 * based on the type.
65 */
66 private String defaultValueInString;
67
68 /**
69 * Description of new type.
70 */
71 private String description;
72
73 /**
74 * reference string.
75 */
76 private String reference;
77
78 /**
79 * Status of the data type.
80 */
81 private YangStatusType status;
82
83 /**
84 * Derived data type.
85 */
86 @SuppressWarnings("rawtypes")
87 private YangType derivedType;
88
89 /**
90 * Units of the data type.
91 */
92 private String units;
93
94 /**
95 * Create a typedef node.
96 */
97 public YangTypeDef() {
98 super(YangNodeType.TYPEDEF_NODE);
99 }
100
101 /**
102 * Get the data type name.
103 *
104 * @return the data type name.
105 */
106 public String getDerivedName() {
107 return derivedName;
108 }
109
110 /**
111 * Set the data type name.
112 *
113 * @param derrivedName data type name.
114 */
115 public void setDerivedName(String derrivedName) {
116 derivedName = derrivedName;
117 }
118
119 /**
120 * Get the default value.
121 *
122 * @return the default value.
123 */
124 public String getDefaultValueInString() {
125 return defaultValueInString;
126 }
127
128 /**
129 * Set the default value.
130 *
131 * @param defaultValueInString the default value.
132 */
133 public void setDefaultValueInString(String defaultValueInString) {
134 this.defaultValueInString = defaultValueInString;
135 }
136
137 /**
138 * Get the description.
139 *
140 * @return the description.
141 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530142 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530143 public String getDescription() {
144 return description;
145 }
146
147 /**
148 * Set the description.
149 *
150 * @param description set the description.
151 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530152 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530153 public void setDescription(String description) {
154 this.description = description;
155 }
156
157 /**
158 * Get the textual reference.
159 *
160 * @return the reference.
161 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530162 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530163 public String getReference() {
164 return reference;
165 }
166
167 /**
168 * Set the textual reference.
169 *
170 * @param reference the reference to set.
171 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530172 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530173 public void setReference(String reference) {
174 this.reference = reference;
175 }
176
177 /**
178 * Get the status.
179 *
180 * @return the status.
181 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530182 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530183 public YangStatusType getStatus() {
184 return status;
185 }
186
187 /**
188 * Set the status.
189 *
190 * @param status the status to set.
191 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530192 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530193 public void setStatus(YangStatusType status) {
194 this.status = status;
195 }
196
197 /**
198 * Get the referenced type.
199 *
200 * @return the referenced type.
201 */
202 @SuppressWarnings("rawtypes")
203 public YangType getDerivedType() {
204 return derivedType;
205 }
206
207 /**
208 * Get the referenced type.
209 *
210 * @param derivedType the referenced type.
211 */
212 @SuppressWarnings("rawtypes")
213 public void setDerivedType(YangType derivedType) {
214 this.derivedType = derivedType;
215 }
216
217 /**
218 * Get the unit.
219 *
220 * @return the units
221 */
222 public String getUnits() {
223 return units;
224 }
225
226 /**
227 * Set the unit.
228 *
229 * @param units the units to set
230 */
231 public void setUnits(String units) {
232 this.units = units;
233 }
234
235 /**
236 * Returns the type of the data.
237 *
238 * @return returns TYPEDEF_DATA
239 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530240 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530241 public ParsableDataType getParsableDataType() {
242 return ParsableDataType.TYPEDEF_DATA;
243 }
244
245 /**
246 * Validate the data on entering the corresponding parse tree node.
247 *
248 * @throws DataModelException a violation of data model rules.
249 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530250 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530251 public void validateDataOnEntry() throws DataModelException {
252 // TODO auto-generated method stub, to be implemented by parser
253 }
254
255 /**
256 * Validate the data on exiting the corresponding parse tree node.
257 *
258 * @throws DataModelException a violation of data model rules.
259 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530260 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530261 public void validateDataOnExit() throws DataModelException {
262 // TODO auto-generated method stub, to be implemented by parser
263 }
264
265 /* (non-Javadoc)
266 * @see org.onosproject.yangutils.datamodel.YangNode#getName()
267 */
268 @Override
269 public String getName() {
270 // TODO Auto-generated method stub
271 return null;
272 }
273
274 /* (non-Javadoc)
275 * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
276 */
277 @Override
278 public void setName(String name) {
279 // TODO Auto-generated method stub
280
281 }
282
283 /* (non-Javadoc)
284 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
285 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530286 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530287 public void generateJavaCodeEntry() {
288 // TODO Auto-generated method stub
289
290 }
291
292 /* (non-Javadoc)
293 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
294 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530295 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530296 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 }
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530318
319 @Override
320 public CachedFileHandle getFileHandle() {
321 // TODO Auto-generated method stub
322 return null;
323 }
324
325 @Override
326 public void setFileHandle(CachedFileHandle fileHandle) {
327 // TODO Auto-generated method stub
328
329 }
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530330}