Vinod Kumar S | 13139e9 | 2016-02-05 20:21:19 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 13139e9 | 2016-02-05 20:21:19 +0530 | [diff] [blame] | 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 | */ |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 16 | package org.onosproject.yangutils.utils; |
Vinod Kumar S | 13139e9 | 2016-02-05 20:21:19 +0530 | [diff] [blame] | 17 | |
| 18 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 19 | * Represents ENUM to represent the type of data in parse tree. |
Vinod Kumar S | 13139e9 | 2016-02-05 20:21:19 +0530 | [diff] [blame] | 20 | */ |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 21 | public enum YangConstructType { |
Vinod Kumar S | 13139e9 | 2016-02-05 20:21:19 +0530 | [diff] [blame] | 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 | /** |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 233 | * Identifies the YANG data definition statements. |
| 234 | */ |
| 235 | DATA_DEF_DATA, |
| 236 | |
| 237 | /** |
Gaurav Agrawal | f576642 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 238 | * Identifies the YANG union element parsed data. |
| 239 | */ |
| 240 | UNION_DATA, |
| 241 | |
| 242 | /** |
| 243 | * Identifies the YANG notification element parsed data. |
| 244 | */ |
| 245 | NOTIFICATION_DATA, |
| 246 | |
| 247 | /** |
| 248 | * Identifies the YANG when element parsed data. |
| 249 | */ |
| 250 | WHEN_DATA, |
| 251 | |
| 252 | /** |
| 253 | * Identifies the YANG input element parsed data. |
| 254 | */ |
| 255 | INPUT_DATA, |
| 256 | |
| 257 | /** |
| 258 | * Identifies the YANG output element parsed data. |
| 259 | */ |
| 260 | OUTPUT_DATA, |
| 261 | |
| 262 | /** |
| 263 | * Identifies the YANG rpc element parsed data. |
| 264 | */ |
| 265 | RPC_DATA, |
| 266 | |
| 267 | /** |
| 268 | * Identifies the YANG short case element parsed data. |
| 269 | */ |
| 270 | SHORT_CASE_DATA, |
| 271 | |
| 272 | /** |
Vinod Kumar S | 48848f7 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 273 | * Identifies the derived data type. |
| 274 | */ |
Vidyashree Rama | 6250e6d | 2016-03-29 09:52:22 +0530 | [diff] [blame] | 275 | DERIVED, |
| 276 | |
| 277 | /** |
| 278 | * Identifies the YANG range element parsed data. |
| 279 | */ |
Vidyashree Rama | bc9611f | 2016-04-12 23:33:33 +0530 | [diff] [blame] | 280 | RANGE_DATA, |
| 281 | |
| 282 | /** |
| 283 | * Identifies the YANG length element parsed data. |
| 284 | */ |
| 285 | LENGTH_DATA, |
| 286 | |
| 287 | /** |
| 288 | * Identifies the YANG pattern element parsed data. |
| 289 | */ |
Vidyashree Rama | b624817 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 290 | PATTERN_DATA, |
| 291 | |
| 292 | /** |
| 293 | * Identifies the YANG extension element parsed data. |
| 294 | */ |
| 295 | EXTENSION_DATA, |
| 296 | |
| 297 | /** |
| 298 | * Identifies the YANG identity element parsed data. |
| 299 | */ |
| 300 | IDENTITY_DATA, |
| 301 | |
| 302 | /** |
| 303 | * Identifies the YANG base element parsed data. |
| 304 | */ |
| 305 | BASE_DATA, |
| 306 | |
| 307 | /** |
| 308 | * Identifies the YANG feature element parsed data. |
| 309 | */ |
| 310 | FEATURE_DATA, |
| 311 | |
| 312 | /** |
| 313 | * Identifies the YANG if-feature element parsed data. |
| 314 | */ |
| 315 | IF_FEATURE_DATA, |
| 316 | |
| 317 | /** |
| 318 | * Identifies the YANG path element parsed data. |
| 319 | */ |
| 320 | PATH_DATA, |
| 321 | |
| 322 | /** |
| 323 | * Identifies the YANG require-instance element parsed data. |
| 324 | */ |
| 325 | REQUIRE_INSTANCE_DATA, |
| 326 | |
| 327 | /** |
| 328 | * Identifies the YANG ordered-by element parsed data. |
| 329 | */ |
| 330 | ORDERED_BY_DATA, |
| 331 | |
| 332 | /** |
| 333 | * Identifies the YANG error-message element parsed data. |
| 334 | */ |
| 335 | ERROR_MESSAGE_DATA, |
| 336 | |
| 337 | /** |
| 338 | * Identifies the YANG error-app-tag element parsed data. |
| 339 | */ |
| 340 | ERROR_APP_TAG_DATA, |
| 341 | |
| 342 | /** |
| 343 | * Identifies the YANG unique element parsed data. |
| 344 | */ |
| 345 | UNIQUE_DATA, |
| 346 | |
| 347 | /** |
| 348 | * Identifies the YANG refine element parsed data. |
| 349 | */ |
| 350 | REFINE_DATA, |
| 351 | |
| 352 | /** |
janani b | b08850e | 2016-05-17 18:20:33 +0530 | [diff] [blame] | 353 | * Identifies the YANG leafref element parsed data. |
| 354 | */ |
| 355 | LEAFREF_DATA, |
| 356 | |
| 357 | /** |
| 358 | * Identifies the YANG identityref element parsed data. |
| 359 | */ |
| 360 | IDENTITYREF_DATA, |
| 361 | |
| 362 | /** |
| 363 | * Identifies the YANG instance identifier element parsed data. |
| 364 | */ |
| 365 | INSTANCE_IDENTIFIER_DATA, |
| 366 | |
| 367 | /** |
Vidyashree Rama | b624817 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 368 | * Identifies the YANG deviation element parsed data. |
| 369 | */ |
| 370 | DEVIATION_DATA, |
| 371 | |
| 372 | /** |
| 373 | * Identifies the YANG anyxml element parsed data. |
| 374 | */ |
| 375 | ANYXML_DATA; |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 376 | |
| 377 | /** |
| 378 | * Returns the YANG construct keyword corresponding to enum values. |
| 379 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 380 | * @param yangConstructType enum value for parsable data type. |
| 381 | * @return YANG construct keyword. |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 382 | */ |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 383 | public static String getYangConstructType(YangConstructType yangConstructType) { |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 384 | |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 385 | switch (yangConstructType) { |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 386 | case MODULE_DATA: |
| 387 | return "module"; |
| 388 | case SUB_MODULE_DATA: |
| 389 | return "submodule"; |
| 390 | case TYPEDEF_DATA: |
| 391 | return "typedef"; |
| 392 | case TYPE_DATA: |
| 393 | return "type"; |
| 394 | case CHOICE_DATA: |
| 395 | return "choice"; |
| 396 | case CASE_DATA: |
| 397 | return "case"; |
| 398 | case ENUMERATION_DATA: |
| 399 | return "enumeration"; |
| 400 | case GROUPING_DATA: |
| 401 | return "grouping"; |
| 402 | case USES_DATA: |
| 403 | return "uses"; |
| 404 | case AUGMENT_DATA: |
| 405 | return "augment"; |
| 406 | case CONTAINER_DATA: |
| 407 | return "container"; |
| 408 | case LIST_DATA: |
| 409 | return "list"; |
| 410 | case BELONGS_TO_DATA: |
| 411 | return "belongs-to"; |
| 412 | case BIT_DATA: |
| 413 | return "bit"; |
| 414 | case BITS_DATA: |
| 415 | return "bits"; |
| 416 | case ENUM_DATA: |
| 417 | return "enum"; |
| 418 | case IMPORT_DATA: |
| 419 | return "import"; |
| 420 | case INCLUDE_DATA: |
| 421 | return "include"; |
| 422 | case LEAF_DATA: |
| 423 | return "leaf"; |
| 424 | case LEAF_LIST_DATA: |
| 425 | return "leaf-list"; |
| 426 | case MUST_DATA: |
| 427 | return "must"; |
| 428 | case REVISION_DATA: |
| 429 | return "revision"; |
| 430 | case REVISION_DATE_DATA: |
| 431 | return "revision-date"; |
| 432 | case NAMESPACE_DATA: |
| 433 | return "namespace"; |
| 434 | case CONTACT_DATA: |
| 435 | return "contact"; |
| 436 | case CONFIG_DATA: |
| 437 | return "config"; |
| 438 | case DESCRIPTION_DATA: |
| 439 | return "description"; |
| 440 | case KEY_DATA: |
| 441 | return "key"; |
| 442 | case MANDATORY_DATA: |
| 443 | return "mandatory"; |
| 444 | case MAX_ELEMENT_DATA: |
| 445 | return "max-elements"; |
| 446 | case MIN_ELEMENT_DATA: |
| 447 | return "min-elements"; |
| 448 | case PRESENCE_DATA: |
| 449 | return "presence"; |
| 450 | case REFERENCE_DATA: |
| 451 | return "reference"; |
| 452 | case STATUS_DATA: |
| 453 | return "status"; |
| 454 | case UNITS_DATA: |
| 455 | return "units"; |
| 456 | case VERSION_DATA: |
| 457 | return "version"; |
| 458 | case YANGBASE_DATA: |
| 459 | return "yangbase"; |
| 460 | case PREFIX_DATA: |
| 461 | return "prefix"; |
| 462 | case ORGANIZATION_DATA: |
| 463 | return "organization"; |
| 464 | case VALUE_DATA: |
| 465 | return "value"; |
Gaurav Agrawal | 480a47d | 2016-02-26 02:47:39 +0530 | [diff] [blame] | 466 | case POSITION_DATA: |
| 467 | return "position"; |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 468 | case DEFAULT_DATA: |
| 469 | return "default"; |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 470 | case DATA_DEF_DATA: |
| 471 | return "data-def-substatements"; |
Gaurav Agrawal | f576642 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 472 | case WHEN_DATA: |
| 473 | return "when"; |
| 474 | case INPUT_DATA: |
| 475 | return "input"; |
| 476 | case OUTPUT_DATA: |
| 477 | return "ouput"; |
| 478 | case RPC_DATA: |
| 479 | return "rpc"; |
| 480 | case SHORT_CASE_DATA: |
| 481 | return "short-case"; |
Vinod Kumar S | 48848f7 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 482 | case DERIVED: |
| 483 | return "derived"; |
Gaurav Agrawal | f576642 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 484 | case NOTIFICATION_DATA: |
| 485 | return "notification"; |
| 486 | case UNION_DATA: |
| 487 | return "union"; |
Vidyashree Rama | 6250e6d | 2016-03-29 09:52:22 +0530 | [diff] [blame] | 488 | case RANGE_DATA: |
| 489 | return "range"; |
Vidyashree Rama | bc9611f | 2016-04-12 23:33:33 +0530 | [diff] [blame] | 490 | case LENGTH_DATA: |
| 491 | return "length"; |
| 492 | case PATTERN_DATA: |
| 493 | return "pattern"; |
Vidyashree Rama | b624817 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 494 | case EXTENSION_DATA: |
| 495 | return "extension"; |
| 496 | case IDENTITY_DATA: |
| 497 | return "identity"; |
| 498 | case BASE_DATA: |
| 499 | return "base"; |
| 500 | case FEATURE_DATA: |
| 501 | return "feature"; |
| 502 | case IF_FEATURE_DATA: |
| 503 | return "if-feature"; |
| 504 | case PATH_DATA: |
| 505 | return "path"; |
| 506 | case REQUIRE_INSTANCE_DATA: |
| 507 | return "require-instance"; |
| 508 | case ORDERED_BY_DATA: |
| 509 | return "ordered-by"; |
| 510 | case ERROR_MESSAGE_DATA: |
| 511 | return "error-message"; |
| 512 | case ERROR_APP_TAG_DATA: |
| 513 | return "error-app-tag"; |
| 514 | case UNIQUE_DATA: |
| 515 | return "unique"; |
| 516 | case REFINE_DATA: |
| 517 | return "refine"; |
janani b | b08850e | 2016-05-17 18:20:33 +0530 | [diff] [blame] | 518 | case LEAFREF_DATA: |
| 519 | return "leafref"; |
| 520 | case IDENTITYREF_DATA: |
| 521 | return "identityref"; |
| 522 | case INSTANCE_IDENTIFIER_DATA: |
| 523 | return "instance-identifier"; |
Vidyashree Rama | b624817 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 524 | case DEVIATION_DATA: |
| 525 | return "deviation"; |
| 526 | case ANYXML_DATA: |
| 527 | return "anyxml"; |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 528 | default: |
| 529 | return "yang"; |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 530 | } |
| 531 | } |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 532 | } |