blob: f1cb2843c4f778f2ae241a32a538bad6d1f2ee81 [file] [log] [blame]
Gaurav Agrawala04483c2016-02-13 14:23:40 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Gaurav Agrawala04483c2016-02-13 14:23:40 +05303 *
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.parser.impl.parserutils;
18
19/**
Bharat saraswald9822e92016-04-05 15:13:44 +053020 * Represents listener error type.
Gaurav Agrawala04483c2016-02-13 14:23:40 +053021 */
22public enum ListenerErrorType {
23 /**
Gaurav Agrawal9c512e02016-02-25 04:37:05 +053024 * Represents the parent holder in parsable stack for given YANG construct
25 * is invalid.
Gaurav Agrawala04483c2016-02-13 14:23:40 +053026 */
27 INVALID_HOLDER(),
28
29 /**
Gaurav Agrawal9c512e02016-02-25 04:37:05 +053030 * Represents the parent holder in parsable stack for given YANG construct
31 * is missing.
Gaurav Agrawala04483c2016-02-13 14:23:40 +053032 */
33 MISSING_HOLDER(),
34
35 /**
Gaurav Agrawal9c512e02016-02-25 04:37:05 +053036 * Represents the current holder in parsable stack for given YANG construct
37 * is missing.
Gaurav Agrawala04483c2016-02-13 14:23:40 +053038 */
39 MISSING_CURRENT_HOLDER(),
40
41 /**
Gaurav Agrawal9c512e02016-02-25 04:37:05 +053042 * Represents that the child in parsable stack for given YANG construct is
43 * invalid.
Gaurav Agrawala04483c2016-02-13 14:23:40 +053044 */
45 INVALID_CHILD(),
46
47 /**
48 * Represents that the cardinality for given YANG construct is invalid.
49 */
50 INVALID_CARDINALITY(),
51
52 /**
Gaurav Agrawal9c512e02016-02-25 04:37:05 +053053 * Represents that the entry is duplicate.
54 */
55 DUPLICATE_ENTRY(),
56
57 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +053058 * Represents that the content is invalid.
59 */
60 INVALID_CONTENT(),
61
62 /**
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053063 * Represents that the identifier collision is detected.
64 */
65 IDENTIFIER_COLLISION(),
66
67 /**
Gaurav Agrawala04483c2016-02-13 14:23:40 +053068 * 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 Agrawal8e8770a2016-02-27 03:57:50 +053075 * @param errorType enum value for type of error
76 * @return message corresponding to listener error type
Gaurav Agrawala04483c2016-02-13 14:23:40 +053077 */
78 public static String getErrorType(ListenerErrorType errorType) {
79
80 switch (errorType) {
Gaurav Agrawal9c512e02016-02-25 04:37:05 +053081 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 Agrawal0cfdeed2016-02-26 02:47:39 +053093 case INVALID_CONTENT:
94 return "Invalid content in";
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053095 case IDENTIFIER_COLLISION:
96 return "Identifier collision detected for";
Gaurav Agrawal9c512e02016-02-25 04:37:05 +053097 case UNHANDLED_PARSED_DATA:
98 return "Unhandled parsed data at";
99 default:
100 return "Problem in";
Gaurav Agrawala04483c2016-02-13 14:23:40 +0530101 }
102 }
Gaurav Agrawal9c512e02016-02-25 04:37:05 +0530103}