Vinod Kumar S | 13139e9 | 2016-02-05 20:21:19 +0530 | [diff] [blame] | 1 | /* |
| 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 | package org.onosproject.yangutils.parser; |
| 17 | |
| 18 | /** |
| 19 | * ENUM to represent the type of data in parse tree. |
| 20 | */ |
| 21 | public enum ParsableDataType { |
| 22 | /** |
| 23 | * Identifies the module parsed data. |
| 24 | */ |
| 25 | MODULE_DATA, |
| 26 | |
| 27 | /** |
| 28 | * Identifies the sub module parsed data. |
| 29 | */ |
| 30 | SUB_MODULE_DATA, |
| 31 | |
| 32 | /** |
| 33 | * Identifies the typedef parsed data. |
| 34 | */ |
| 35 | TYPEDEF_DATA, |
| 36 | |
| 37 | /** |
| 38 | * Identifies the type parsed data. |
| 39 | */ |
| 40 | TYPE_DATA, |
| 41 | |
| 42 | /** |
| 43 | * Identifies the choice parsed data. |
| 44 | */ |
| 45 | CHOICE_DATA, |
| 46 | |
| 47 | /** |
| 48 | * Identifies the case parsed data. |
| 49 | */ |
| 50 | CASE_DATA, |
| 51 | |
| 52 | /** |
| 53 | * Identifies the YANG enumeration parsed data. |
| 54 | */ |
| 55 | ENUMERATION_DATA, |
| 56 | |
| 57 | /** |
| 58 | * Identifies the grouping parsed data. |
| 59 | */ |
| 60 | GROUPING_DATA, |
| 61 | |
| 62 | /** |
| 63 | * Identifies the uses parsed data. |
| 64 | */ |
| 65 | USES_DATA, |
| 66 | |
| 67 | /** |
| 68 | * Identifies the augment parsed data. |
| 69 | */ |
| 70 | AUGMENT_DATA, |
| 71 | |
| 72 | /** |
| 73 | * Identifies the container parsed data. |
| 74 | */ |
| 75 | CONTAINER_DATA, |
| 76 | |
| 77 | /** |
| 78 | * Identifies the YANG list parsed data. |
| 79 | */ |
| 80 | LIST_DATA, |
| 81 | |
| 82 | /** |
| 83 | * Identifies the YANG belongs-to parsed data. |
| 84 | */ |
| 85 | BELONGS_TO_DATA, |
| 86 | |
| 87 | /** |
| 88 | * Identifies the YANG bit parsed data. |
| 89 | */ |
| 90 | BIT_DATA, |
| 91 | |
| 92 | /** |
| 93 | * Identifies the YANG bits parsed data. |
| 94 | */ |
| 95 | BITS_DATA, |
| 96 | |
| 97 | /** |
| 98 | * Identifies the YANG enum parsed data. |
| 99 | */ |
| 100 | ENUM_DATA, |
| 101 | |
| 102 | /** |
| 103 | * Identifies the YANG import parsed data. |
| 104 | */ |
| 105 | IMPORT_DATA, |
| 106 | |
| 107 | /** |
| 108 | * Identifies the YANG include parsed data. |
| 109 | */ |
| 110 | INCLUDE_DATA, |
| 111 | |
| 112 | /** |
| 113 | * Identifies the YANG leaf parsed data. |
| 114 | */ |
| 115 | LEAF_DATA, |
| 116 | |
| 117 | /** |
| 118 | * Identifies the YANG leaf list parsed data. |
| 119 | */ |
| 120 | LEAF_LIST_DATA, |
| 121 | |
| 122 | /** |
| 123 | * Identifies the YANG must parsed data. |
| 124 | */ |
| 125 | MUST_DATA, |
| 126 | |
| 127 | /** |
| 128 | * Identifies the YANG revision parsed data. |
| 129 | */ |
| 130 | REVISION_DATA, |
| 131 | |
| 132 | /** |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 133 | * Identifies the YANG revision date parsed data. |
| 134 | */ |
| 135 | REVISION_DATE_DATA, |
| 136 | |
| 137 | /** |
Vinod Kumar S | 13139e9 | 2016-02-05 20:21:19 +0530 | [diff] [blame] | 138 | * Identifies the YANG namespace parsed data. |
| 139 | */ |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 140 | NAMESPACE_DATA, |
| 141 | |
| 142 | /** |
| 143 | * Identifies the YANG contact parsed data. |
| 144 | */ |
| 145 | CONTACT_DATA, |
| 146 | |
| 147 | /** |
| 148 | * Identifies the YANG config parsed data. |
| 149 | */ |
| 150 | CONFIG_DATA, |
| 151 | |
| 152 | /** |
| 153 | * Identifies the YANG description parsed data. |
| 154 | */ |
| 155 | DESCRIPTION_DATA, |
| 156 | |
| 157 | /** |
| 158 | * Identifies the YANG key parsed data. |
| 159 | */ |
| 160 | KEY_DATA, |
| 161 | |
| 162 | /** |
| 163 | * Identifies the YANG mandatory parsed data. |
| 164 | */ |
| 165 | MANDATORY_DATA, |
| 166 | |
| 167 | /** |
| 168 | * Identifies the YANG max element parsed data. |
| 169 | */ |
| 170 | MAX_ELEMENT_DATA, |
| 171 | |
| 172 | /** |
| 173 | * Identifies the YANG min element parsed data. |
| 174 | */ |
| 175 | MIN_ELEMENT_DATA, |
| 176 | |
| 177 | /** |
| 178 | * Identifies the YANG presence element parsed data. |
| 179 | */ |
| 180 | PRESENCE_DATA, |
| 181 | |
| 182 | /** |
| 183 | * Identifies the YANG reference element parsed data. |
| 184 | */ |
| 185 | REFERENCE_DATA, |
| 186 | |
| 187 | /** |
| 188 | * Identifies the YANG status element parsed data. |
| 189 | */ |
| 190 | STATUS_DATA, |
| 191 | |
| 192 | /** |
| 193 | * Identifies the YANG units element parsed data. |
| 194 | */ |
| 195 | UNITS_DATA, |
| 196 | |
| 197 | /** |
| 198 | * Identifies the YANG version element parsed data. |
| 199 | */ |
| 200 | VERSION_DATA, |
| 201 | |
| 202 | /** |
| 203 | * Identifies the YANG base element parsed data. |
| 204 | */ |
| 205 | YANGBASE_DATA, |
| 206 | |
| 207 | /** |
| 208 | * Identifies the YANG prefix element parsed data. |
| 209 | */ |
| 210 | PREFIX_DATA, |
| 211 | |
| 212 | /** |
| 213 | * Identifies the YANG default element parsed data. |
| 214 | */ |
| 215 | DEFAULT_DATA, |
| 216 | |
| 217 | /** |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 218 | * Identifies the YANG value element parsed data. |
| 219 | */ |
| 220 | VALUE_DATA, |
| 221 | |
| 222 | /** |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 223 | * Identifies the YANG organization parsed data. |
| 224 | */ |
Vinod Kumar S | 48848f7 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 225 | ORGANIZATION_DATA, |
| 226 | |
| 227 | /** |
Gaurav Agrawal | 480a47d | 2016-02-26 02:47:39 +0530 | [diff] [blame^] | 228 | * Identifies the YANG position element parsed data. |
| 229 | */ |
| 230 | POSITION_DATA, |
| 231 | |
| 232 | /** |
Vinod Kumar S | 48848f7 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 233 | * Identifies the derived data type. |
| 234 | */ |
| 235 | DERIVED; |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 236 | |
| 237 | /** |
| 238 | * Returns the YANG construct keyword corresponding to enum values. |
| 239 | * |
| 240 | * @param parsableDataType enum value for parsable data type. |
| 241 | * @return YANG construct keyword. |
| 242 | */ |
| 243 | public static String getParsableDataType(ParsableDataType parsableDataType) { |
| 244 | |
| 245 | switch (parsableDataType) { |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 246 | case MODULE_DATA: |
| 247 | return "module"; |
| 248 | case SUB_MODULE_DATA: |
| 249 | return "submodule"; |
| 250 | case TYPEDEF_DATA: |
| 251 | return "typedef"; |
| 252 | case TYPE_DATA: |
| 253 | return "type"; |
| 254 | case CHOICE_DATA: |
| 255 | return "choice"; |
| 256 | case CASE_DATA: |
| 257 | return "case"; |
| 258 | case ENUMERATION_DATA: |
| 259 | return "enumeration"; |
| 260 | case GROUPING_DATA: |
| 261 | return "grouping"; |
| 262 | case USES_DATA: |
| 263 | return "uses"; |
| 264 | case AUGMENT_DATA: |
| 265 | return "augment"; |
| 266 | case CONTAINER_DATA: |
| 267 | return "container"; |
| 268 | case LIST_DATA: |
| 269 | return "list"; |
| 270 | case BELONGS_TO_DATA: |
| 271 | return "belongs-to"; |
| 272 | case BIT_DATA: |
| 273 | return "bit"; |
| 274 | case BITS_DATA: |
| 275 | return "bits"; |
| 276 | case ENUM_DATA: |
| 277 | return "enum"; |
| 278 | case IMPORT_DATA: |
| 279 | return "import"; |
| 280 | case INCLUDE_DATA: |
| 281 | return "include"; |
| 282 | case LEAF_DATA: |
| 283 | return "leaf"; |
| 284 | case LEAF_LIST_DATA: |
| 285 | return "leaf-list"; |
| 286 | case MUST_DATA: |
| 287 | return "must"; |
| 288 | case REVISION_DATA: |
| 289 | return "revision"; |
| 290 | case REVISION_DATE_DATA: |
| 291 | return "revision-date"; |
| 292 | case NAMESPACE_DATA: |
| 293 | return "namespace"; |
| 294 | case CONTACT_DATA: |
| 295 | return "contact"; |
| 296 | case CONFIG_DATA: |
| 297 | return "config"; |
| 298 | case DESCRIPTION_DATA: |
| 299 | return "description"; |
| 300 | case KEY_DATA: |
| 301 | return "key"; |
| 302 | case MANDATORY_DATA: |
| 303 | return "mandatory"; |
| 304 | case MAX_ELEMENT_DATA: |
| 305 | return "max-elements"; |
| 306 | case MIN_ELEMENT_DATA: |
| 307 | return "min-elements"; |
| 308 | case PRESENCE_DATA: |
| 309 | return "presence"; |
| 310 | case REFERENCE_DATA: |
| 311 | return "reference"; |
| 312 | case STATUS_DATA: |
| 313 | return "status"; |
| 314 | case UNITS_DATA: |
| 315 | return "units"; |
| 316 | case VERSION_DATA: |
| 317 | return "version"; |
| 318 | case YANGBASE_DATA: |
| 319 | return "yangbase"; |
| 320 | case PREFIX_DATA: |
| 321 | return "prefix"; |
| 322 | case ORGANIZATION_DATA: |
| 323 | return "organization"; |
| 324 | case VALUE_DATA: |
| 325 | return "value"; |
Gaurav Agrawal | 480a47d | 2016-02-26 02:47:39 +0530 | [diff] [blame^] | 326 | case POSITION_DATA: |
| 327 | return "position"; |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 328 | case DEFAULT_DATA: |
| 329 | return "default"; |
Vinod Kumar S | 48848f7 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 330 | case DERIVED: |
| 331 | return "derived"; |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 332 | default: |
| 333 | return "yang"; |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 334 | } |
| 335 | } |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 336 | } |