blob: 1d061d7cb83b4b1214e1bdc714f62c36ccd62bf9 [file] [log] [blame]
Gaurav Agrawal2737d2a2016-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 Agrawal4ce3acf2016-02-25 04:37:05 +053024 * Represents the parent holder in parsable stack for given YANG construct
25 * is invalid.
Gaurav Agrawal2737d2a2016-02-13 14:23:40 +053026 */
27 INVALID_HOLDER(),
28
29 /**
Gaurav Agrawal4ce3acf2016-02-25 04:37:05 +053030 * Represents the parent holder in parsable stack for given YANG construct
31 * is missing.
Gaurav Agrawal2737d2a2016-02-13 14:23:40 +053032 */
33 MISSING_HOLDER(),
34
35 /**
Gaurav Agrawal4ce3acf2016-02-25 04:37:05 +053036 * Represents the current holder in parsable stack for given YANG construct
37 * is missing.
Gaurav Agrawal2737d2a2016-02-13 14:23:40 +053038 */
39 MISSING_CURRENT_HOLDER(),
40
41 /**
Gaurav Agrawal4ce3acf2016-02-25 04:37:05 +053042 * Represents that the child in parsable stack for given YANG construct is
43 * invalid.
Gaurav Agrawal2737d2a2016-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 Agrawal4ce3acf2016-02-25 04:37:05 +053053 * Represents that the entry is duplicate.
54 */
55 DUPLICATE_ENTRY(),
56
57 /**
Gaurav Agrawal480a47d2016-02-26 02:47:39 +053058 * Represents that the content is invalid.
59 */
60 INVALID_CONTENT(),
61
62 /**
Gaurav Agrawal2737d2a2016-02-13 14:23:40 +053063 * Represents that some of earlier parsed data is not handled correctly.
64 */
65 UNHANDLED_PARSED_DATA();
66
67 /**
68 * Returns the message corresponding to listener error type.
69 *
70 * @param errorType enum value for type of error.
71 * @return message corresponding to listener error type.
72 */
73 public static String getErrorType(ListenerErrorType errorType) {
74
75 switch (errorType) {
Gaurav Agrawal4ce3acf2016-02-25 04:37:05 +053076 case INVALID_HOLDER:
77 return "Invalid holder for";
78 case MISSING_HOLDER:
79 return "Missing holder at";
80 case MISSING_CURRENT_HOLDER:
81 return "Missing";
82 case INVALID_CHILD:
83 return "Invalid child in";
84 case INVALID_CARDINALITY:
85 return "Invalid cardinality in";
86 case DUPLICATE_ENTRY:
87 return "Duplicate";
Gaurav Agrawal480a47d2016-02-26 02:47:39 +053088 case INVALID_CONTENT:
89 return "Invalid content in";
Gaurav Agrawal4ce3acf2016-02-25 04:37:05 +053090 case UNHANDLED_PARSED_DATA:
91 return "Unhandled parsed data at";
92 default:
93 return "Problem in";
Gaurav Agrawal2737d2a2016-02-13 14:23:40 +053094 }
95 }
Gaurav Agrawal4ce3acf2016-02-25 04:37:05 +053096}