Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +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 | */ |
| 16 | |
| 17 | package org.onosproject.yangutils.parser.impl.parserutils; |
| 18 | |
| 19 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 20 | * Represents listener error type. |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 21 | */ |
| 22 | public enum ListenerErrorType { |
| 23 | /** |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 24 | * Represents the parent holder in parsable stack for given YANG construct |
| 25 | * is invalid. |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 26 | */ |
| 27 | INVALID_HOLDER(), |
| 28 | |
| 29 | /** |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 30 | * Represents the parent holder in parsable stack for given YANG construct |
| 31 | * is missing. |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 32 | */ |
| 33 | MISSING_HOLDER(), |
| 34 | |
| 35 | /** |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 36 | * Represents the current holder in parsable stack for given YANG construct |
| 37 | * is missing. |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 38 | */ |
| 39 | MISSING_CURRENT_HOLDER(), |
| 40 | |
| 41 | /** |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 42 | * Represents that the child in parsable stack for given YANG construct is |
| 43 | * invalid. |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 44 | */ |
| 45 | INVALID_CHILD(), |
| 46 | |
| 47 | /** |
| 48 | * Represents that the cardinality for given YANG construct is invalid. |
| 49 | */ |
| 50 | INVALID_CARDINALITY(), |
| 51 | |
| 52 | /** |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 53 | * Represents that the entry is duplicate. |
| 54 | */ |
| 55 | DUPLICATE_ENTRY(), |
| 56 | |
| 57 | /** |
Gaurav Agrawal | 480a47d | 2016-02-26 02:47:39 +0530 | [diff] [blame] | 58 | * Represents that the content is invalid. |
| 59 | */ |
| 60 | INVALID_CONTENT(), |
| 61 | |
| 62 | /** |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 63 | * Represents that the identifier collision is detected. |
| 64 | */ |
| 65 | IDENTIFIER_COLLISION(), |
| 66 | |
| 67 | /** |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 68 | * Represents that some of earlier parsed data is not handled correctly. |
| 69 | */ |
| 70 | UNHANDLED_PARSED_DATA(); |
| 71 | |
| 72 | /** |
| 73 | * Returns the message corresponding to listener error type. |
| 74 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 75 | * @param errorType enum value for type of error |
| 76 | * @return message corresponding to listener error type |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 77 | */ |
| 78 | public static String getErrorType(ListenerErrorType errorType) { |
| 79 | |
| 80 | switch (errorType) { |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 81 | case INVALID_HOLDER: |
| 82 | return "Invalid holder for"; |
| 83 | case MISSING_HOLDER: |
| 84 | return "Missing holder at"; |
| 85 | case MISSING_CURRENT_HOLDER: |
| 86 | return "Missing"; |
| 87 | case INVALID_CHILD: |
| 88 | return "Invalid child in"; |
| 89 | case INVALID_CARDINALITY: |
| 90 | return "Invalid cardinality in"; |
| 91 | case DUPLICATE_ENTRY: |
| 92 | return "Duplicate"; |
Gaurav Agrawal | 480a47d | 2016-02-26 02:47:39 +0530 | [diff] [blame] | 93 | case INVALID_CONTENT: |
| 94 | return "Invalid content in"; |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 95 | case IDENTIFIER_COLLISION: |
| 96 | return "Identifier collision detected for"; |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 97 | case UNHANDLED_PARSED_DATA: |
| 98 | return "Unhandled parsed data at"; |
| 99 | default: |
| 100 | return "Problem in"; |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 101 | } |
| 102 | } |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 103 | } |