Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +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 | |
| 17 | package org.onosproject.yangutils.parser.impl.parserutils; |
| 18 | |
| 19 | /** |
| 20 | * Maintains listener error type. |
| 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 | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 58 | * Represents that some of earlier parsed data is not handled correctly. |
| 59 | */ |
| 60 | UNHANDLED_PARSED_DATA(); |
| 61 | |
| 62 | /** |
| 63 | * Returns the message corresponding to listener error type. |
| 64 | * |
| 65 | * @param errorType enum value for type of error. |
| 66 | * @return message corresponding to listener error type. |
| 67 | */ |
| 68 | public static String getErrorType(ListenerErrorType errorType) { |
| 69 | |
| 70 | switch (errorType) { |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 71 | case INVALID_HOLDER: |
| 72 | return "Invalid holder for"; |
| 73 | case MISSING_HOLDER: |
| 74 | return "Missing holder at"; |
| 75 | case MISSING_CURRENT_HOLDER: |
| 76 | return "Missing"; |
| 77 | case INVALID_CHILD: |
| 78 | return "Invalid child in"; |
| 79 | case INVALID_CARDINALITY: |
| 80 | return "Invalid cardinality in"; |
| 81 | case DUPLICATE_ENTRY: |
| 82 | return "Duplicate"; |
| 83 | case UNHANDLED_PARSED_DATA: |
| 84 | return "Unhandled parsed data at"; |
| 85 | default: |
| 86 | return "Problem in"; |
Gaurav Agrawal | 2737d2a | 2016-02-13 14:23:40 +0530 | [diff] [blame] | 87 | } |
| 88 | } |
Gaurav Agrawal | 4ce3acf | 2016-02-25 04:37:05 +0530 | [diff] [blame] | 89 | } |