blob: 59da35464c60ab944bb2e09cfe43a33820bbc592 [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 */
16
17package org.onosproject.yangutils.datamodel;
18
19import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20import org.onosproject.yangutils.parser.Parsable;
21import 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 */
51public 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 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530108 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530109 public String getDescription() {
110 return description;
111 }
112
113 /**
114 * Set the description.
115 *
116 * @param description set the description.
117 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530118 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530119 public void setDescription(String description) {
120 this.description = description;
121 }
122
123 /**
124 * Get the textual reference.
125 *
126 * @return the reference.
127 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530128 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530129 public String getReference() {
130 return reference;
131 }
132
133 /**
134 * Set the textual reference.
135 *
136 * @param reference the reference to set.
137 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530138 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530139 public void setReference(String reference) {
140 this.reference = reference;
141 }
142
143 /**
144 * Get the status.
145 *
146 * @return the status.
147 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530148 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530149 public YangStatusType getStatus() {
150 return status;
151 }
152
153 /**
154 * Set the status.
155 *
156 * @param status the status to set.
157 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530158 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530159 public void setStatus(YangStatusType status) {
160 this.status = status;
161 }
162
163 /**
164 * Get the value.
165 *
166 * @return the value.
167 */
168 public int getValue() {
169 return value;
170 }
171
172 /**
173 * Set the value.
174 *
175 * @param value the value to set.
176 */
177 public void setValue(int value) {
178 this.value = value;
179 }
180
181 /**
182 * Returns the type of the data.
183 *
184 * @return ParsedDataType returns ENUM_DATA
185 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530186 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530187 public ParsableDataType getParsableDataType() {
188 return ParsableDataType.ENUM_DATA;
189 }
190
191 /**
192 * Validate the data on entering the corresponding parse tree node.
193 *
194 * @throws DataModelException a violation of data model rules.
195 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530196 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530197 public void validateDataOnEntry() throws DataModelException {
198 // TODO auto-generated method stub, to be implemented by parser
199 }
200
201 /**
202 * Validate the data on exiting the corresponding parse tree node.
203 *
204 * @throws DataModelException a violation of data model rules.
205 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530206 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530207 public void validateDataOnExit() throws DataModelException {
208 // TODO auto-generated method stub, to be implemented by parser
209 }
210}