blob: e28d186c1da2191925b71f9589fe62d50e09c744 [file] [log] [blame]
Gaurav Agrawala04483c2016-02-13 14:23:40 +05301/*
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
17package org.onosproject.yangutils.parser.impl.parserutils;
18
19/**
20 * Maintains listener error type.
21 */
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 Agrawala04483c2016-02-13 14:23:40 +053058 * 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 Agrawal9c512e02016-02-25 04:37:05 +053071 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 Agrawala04483c2016-02-13 14:23:40 +053087 }
88 }
Gaurav Agrawal9c512e02016-02-25 04:37:05 +053089}