blob: 57ef9ddbe23a68b9c06df915a884d5b4f9619d6e [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;
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 */
54public 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}