Vidyashree Rama
Committed by Gerrit Code Review

Change to static import for lesser indentation.

Change-Id: I5350c65496023a96c88cefe9dd5ed64a72c5f30c
...@@ -21,14 +21,16 @@ import org.onosproject.yangutils.datamodel.YangLeaf; ...@@ -21,14 +21,16 @@ import org.onosproject.yangutils.datamodel.YangLeaf;
21 import org.onosproject.yangutils.datamodel.YangLeafList; 21 import org.onosproject.yangutils.datamodel.YangLeafList;
22 import org.onosproject.yangutils.datamodel.YangList; 22 import org.onosproject.yangutils.datamodel.YangList;
23 import org.onosproject.yangutils.parser.Parsable; 23 import org.onosproject.yangutils.parser.Parsable;
24 -import org.onosproject.yangutils.parser.ParsableDataType;
25 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
26 import org.onosproject.yangutils.parser.exceptions.ParserException; 25 import org.onosproject.yangutils.parser.exceptions.ParserException;
27 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 26 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 27 +
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 28 +import static org.onosproject.yangutils.parser.ParsableDataType.CONFIG_DATA;
30 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
31 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
33 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
32 34
33 /* 35 /*
34 * Reference: RFC6020 and YANG ANTLR Grammar 36 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -69,8 +71,7 @@ public final class ConfigListener { ...@@ -69,8 +71,7 @@ public final class ConfigListener {
69 boolean isConfig = false; 71 boolean isConfig = false;
70 72
71 // Check for stack to be non empty. 73 // Check for stack to be non empty.
72 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 74 + checkStackIsNotEmpty(listener, MISSING_HOLDER, CONFIG_DATA, "", ENTRY);
73 - ParsableDataType.CONFIG_DATA, "", ListenerErrorLocation.ENTRY);
74 75
75 if (ctx.TRUE_KEYWORD() != null) { 76 if (ctx.TRUE_KEYWORD() != null) {
76 isConfig = true; 77 isConfig = true;
...@@ -97,10 +98,7 @@ public final class ConfigListener { ...@@ -97,10 +98,7 @@ public final class ConfigListener {
97 case CHOICE_DATA: // TODO 98 case CHOICE_DATA: // TODO
98 break; 99 break;
99 default: 100 default:
100 - throw new ParserException(ListenerErrorMessageConstruction 101 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, CONFIG_DATA, "", ENTRY));
101 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
102 - ParsableDataType.CONFIG_DATA,
103 - "", ListenerErrorLocation.ENTRY));
104 } 102 }
105 } 103 }
106 } 104 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -15,20 +15,30 @@ ...@@ -15,20 +15,30 @@
15 */ 15 */
16 16
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 +
18 import org.onosproject.yangutils.datamodel.YangContainer; 19 import org.onosproject.yangutils.datamodel.YangContainer;
20 +import org.onosproject.yangutils.datamodel.YangList;
21 +import org.onosproject.yangutils.datamodel.YangModule;
19 import org.onosproject.yangutils.datamodel.YangNode; 22 import org.onosproject.yangutils.datamodel.YangNode;
20 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
21 import org.onosproject.yangutils.parser.Parsable; 24 import org.onosproject.yangutils.parser.Parsable;
22 -
23 import org.onosproject.yangutils.parser.ParsableDataType; 25 import org.onosproject.yangutils.parser.ParsableDataType;
24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 26 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
25 import org.onosproject.yangutils.parser.exceptions.ParserException; 27 import org.onosproject.yangutils.parser.exceptions.ParserException;
26 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 28 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
27 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 29 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 30 +
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 31 +import static org.onosproject.yangutils.parser.ParsableDataType.CONTAINER_DATA;
30 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
31 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 33 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
34 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
35 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
36 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
37 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
38 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
39 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
40 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
41 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
32 42
33 /* 43 /*
34 * Reference: RFC6020 and YANG ANTLR Grammar 44 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -85,15 +95,11 @@ public final class ContainerListener { ...@@ -85,15 +95,11 @@ public final class ContainerListener {
85 GeneratedYangParser.ContainerStatementContext ctx) { 95 GeneratedYangParser.ContainerStatementContext ctx) {
86 96
87 // Check for stack to be non empty. 97 // Check for stack to be non empty.
88 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 98 + checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY);
89 - ParsableDataType.CONTAINER_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
90 - ListenerErrorLocation.ENTRY);
91 99
92 boolean result = validateSubStatementsCardinality(ctx); 100 boolean result = validateSubStatementsCardinality(ctx);
93 if (!result) { 101 if (!result) {
94 - throw new ParserException(ListenerErrorMessageConstruction 102 + throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
95 - .constructListenerErrorMessage(ListenerErrorType.INVALID_CARDINALITY,
96 - yangConstruct, "", ListenerErrorLocation.ENTRY));
97 } 103 }
98 104
99 YangContainer container = new YangContainer(); 105 YangContainer container = new YangContainer();
...@@ -101,25 +107,19 @@ public final class ContainerListener { ...@@ -101,25 +107,19 @@ public final class ContainerListener {
101 107
102 Parsable curData = listener.getParsedDataStack().peek(); 108 Parsable curData = listener.getParsedDataStack().peek();
103 109
104 - if (curData instanceof YangNode) { 110 + if ((curData instanceof YangModule) || (curData instanceof YangContainer)
111 + || (curData instanceof YangList)) {
105 YangNode curNode = (YangNode) curData; 112 YangNode curNode = (YangNode) curData;
106 try { 113 try {
107 curNode.addChild(container); 114 curNode.addChild(container);
108 } catch (DataModelException e) { 115 } catch (DataModelException e) {
109 - throw new ParserException(ListenerErrorMessageConstruction 116 + throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
110 - .constructExtendedListenerErrorMessage(ListenerErrorType.UNHANDLED_PARSED_DATA, 117 + CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY, e.getMessage()));
111 - ParsableDataType.CONTAINER_DATA,
112 - String.valueOf(ctx.IDENTIFIER().getText()),
113 - ListenerErrorLocation.ENTRY,
114 - e.getMessage()));
115 } 118 }
116 listener.getParsedDataStack().push(container); 119 listener.getParsedDataStack().push(container);
117 } else { 120 } else {
118 - throw new ParserException(ListenerErrorMessageConstruction 121 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, CONTAINER_DATA,
119 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 122 + ctx.IDENTIFIER().getText(), ENTRY));
120 - ParsableDataType.CONTAINER_DATA,
121 - String.valueOf(ctx.IDENTIFIER().getText()),
122 - ListenerErrorLocation.ENTRY));
123 } 123 }
124 } 124 }
125 125
...@@ -134,18 +134,13 @@ public final class ContainerListener { ...@@ -134,18 +134,13 @@ public final class ContainerListener {
134 GeneratedYangParser.ContainerStatementContext ctx) { 134 GeneratedYangParser.ContainerStatementContext ctx) {
135 135
136 // Check for stack to be non empty. 136 // Check for stack to be non empty.
137 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 137 + checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), EXIT);
138 - ParsableDataType.CONTAINER_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
139 - ListenerErrorLocation.EXIT);
140 138
141 if (listener.getParsedDataStack().peek() instanceof YangContainer) { 139 if (listener.getParsedDataStack().peek() instanceof YangContainer) {
142 listener.getParsedDataStack().pop(); 140 listener.getParsedDataStack().pop();
143 } else { 141 } else {
144 - throw new ParserException(ListenerErrorMessageConstruction 142 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, CONTAINER_DATA,
145 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 143 + ctx.IDENTIFIER().getText(), EXIT));
146 - ParsableDataType.CONTAINER_DATA,
147 - String.valueOf(ctx.IDENTIFIER().getText()),
148 - ListenerErrorLocation.EXIT));
149 } 144 }
150 } 145 }
151 146
...@@ -155,7 +150,7 @@ public final class ContainerListener { ...@@ -155,7 +150,7 @@ public final class ContainerListener {
155 * @param ctx context object of the grammar rule. 150 * @param ctx context object of the grammar rule.
156 * @return true/false validation success or failure. 151 * @return true/false validation success or failure.
157 */ 152 */
158 - public static boolean validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) { 153 + private static boolean validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) {
159 154
160 if ((!ctx.presenceStatement().isEmpty()) 155 if ((!ctx.presenceStatement().isEmpty())
161 && (ctx.presenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) { 156 && (ctx.presenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
......
...@@ -18,14 +18,16 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -18,14 +18,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 import org.onosproject.yangutils.datamodel.YangDesc; 19 import org.onosproject.yangutils.datamodel.YangDesc;
20 import org.onosproject.yangutils.parser.Parsable; 20 import org.onosproject.yangutils.parser.Parsable;
21 -import org.onosproject.yangutils.parser.ParsableDataType;
22 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 21 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
23 import org.onosproject.yangutils.parser.exceptions.ParserException; 22 import org.onosproject.yangutils.parser.exceptions.ParserException;
24 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 23 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
25 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 24 +
26 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 25 +import static org.onosproject.yangutils.parser.ParsableDataType.DESCRIPTION_DATA;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 26 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
29 31
30 /* 32 /*
31 * Reference: RFC6020 and YANG ANTLR Grammar 33 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -61,20 +63,15 @@ public final class DescriptionListener { ...@@ -61,20 +63,15 @@ public final class DescriptionListener {
61 GeneratedYangParser.DescriptionStatementContext ctx) { 63 GeneratedYangParser.DescriptionStatementContext ctx) {
62 64
63 // Check for stack to be non empty. 65 // Check for stack to be non empty.
64 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 66 + checkStackIsNotEmpty(listener, MISSING_HOLDER, DESCRIPTION_DATA, ctx.string().getText(), ENTRY);
65 - ParsableDataType.DESCRIPTION_DATA, String.valueOf(ctx.string().getText()),
66 - ListenerErrorLocation.ENTRY);
67 67
68 Parsable tmpData = listener.getParsedDataStack().peek(); 68 Parsable tmpData = listener.getParsedDataStack().peek();
69 if (tmpData instanceof YangDesc) { 69 if (tmpData instanceof YangDesc) {
70 YangDesc description = (YangDesc) tmpData; 70 YangDesc description = (YangDesc) tmpData;
71 description.setDescription(ctx.string().getText()); 71 description.setDescription(ctx.string().getText());
72 } else { 72 } else {
73 - throw new ParserException(ListenerErrorMessageConstruction 73 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, DESCRIPTION_DATA,
74 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 74 + ctx.string().getText(), ENTRY));
75 - ParsableDataType.DESCRIPTION_DATA,
76 - String.valueOf(ctx.string().getText()),
77 - ListenerErrorLocation.ENTRY));
78 } 75 }
79 } 76 }
80 } 77 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -24,10 +24,16 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; ...@@ -24,10 +24,16 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
24 import org.onosproject.yangutils.parser.exceptions.ParserException; 24 import org.onosproject.yangutils.parser.exceptions.ParserException;
25 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 25 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
26 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 26 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 27 +
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 28 +import static org.onosproject.yangutils.parser.ParsableDataType.LEAF_LIST_DATA;
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
30 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
33 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
34 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
35 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
36 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
31 37
32 /* 38 /*
33 * Reference: RFC6020 and YANG ANTLR Grammar 39 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -82,15 +88,11 @@ public final class LeafListListener { ...@@ -82,15 +88,11 @@ public final class LeafListListener {
82 GeneratedYangParser.LeafListStatementContext ctx) { 88 GeneratedYangParser.LeafListStatementContext ctx) {
83 89
84 // Check for stack to be non empty. 90 // Check for stack to be non empty.
85 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 91 + checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY);
86 - ParsableDataType.LEAF_LIST_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
87 - ListenerErrorLocation.ENTRY);
88 92
89 boolean result = validateSubStatementsCardinality(ctx); 93 boolean result = validateSubStatementsCardinality(ctx);
90 if (!result) { 94 if (!result) {
91 - throw new ParserException(ListenerErrorMessageConstruction 95 + throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
92 - .constructListenerErrorMessage(ListenerErrorType.INVALID_CARDINALITY,
93 - yangConstruct, "", ListenerErrorLocation.ENTRY));
94 } 96 }
95 97
96 YangLeafList leafList = new YangLeafList(); 98 YangLeafList leafList = new YangLeafList();
...@@ -103,11 +105,8 @@ public final class LeafListListener { ...@@ -103,11 +105,8 @@ public final class LeafListListener {
103 leaves = (YangLeavesHolder) tmpData; 105 leaves = (YangLeavesHolder) tmpData;
104 leaves.addLeafList(leafList); 106 leaves.addLeafList(leafList);
105 } else { 107 } else {
106 - throw new ParserException(ListenerErrorMessageConstruction 108 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_LIST_DATA,
107 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 109 + ctx.IDENTIFIER().getText(), ENTRY));
108 - ParsableDataType.LEAF_LIST_DATA,
109 - String.valueOf(ctx.IDENTIFIER().getText()),
110 - ListenerErrorLocation.ENTRY));
111 } 110 }
112 listener.getParsedDataStack().push(leafList); 111 listener.getParsedDataStack().push(leafList);
113 } 112 }
...@@ -123,18 +122,13 @@ public final class LeafListListener { ...@@ -123,18 +122,13 @@ public final class LeafListListener {
123 GeneratedYangParser.LeafListStatementContext ctx) { 122 GeneratedYangParser.LeafListStatementContext ctx) {
124 123
125 // Check for stack to be non empty. 124 // Check for stack to be non empty.
126 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 125 + checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), EXIT);
127 - ParsableDataType.LEAF_LIST_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
128 - ListenerErrorLocation.EXIT);
129 126
130 if (listener.getParsedDataStack().peek() instanceof YangLeafList) { 127 if (listener.getParsedDataStack().peek() instanceof YangLeafList) {
131 listener.getParsedDataStack().pop(); 128 listener.getParsedDataStack().pop();
132 } else { 129 } else {
133 - throw new ParserException(ListenerErrorMessageConstruction 130 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_LIST_DATA,
134 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 131 + ctx.IDENTIFIER().getText(), EXIT));
135 - ParsableDataType.LEAF_LIST_DATA,
136 - String.valueOf(ctx.IDENTIFIER().getText()),
137 - ListenerErrorLocation.EXIT));
138 } 132 }
139 } 133 }
140 134
...@@ -144,7 +138,7 @@ public final class LeafListListener { ...@@ -144,7 +138,7 @@ public final class LeafListListener {
144 * @param ctx context object of the grammar rule. 138 * @param ctx context object of the grammar rule.
145 * @return true/false validation success or failure. 139 * @return true/false validation success or failure.
146 */ 140 */
147 - public static boolean validateSubStatementsCardinality(GeneratedYangParser 141 + private static boolean validateSubStatementsCardinality(GeneratedYangParser
148 .LeafListStatementContext ctx) { 142 .LeafListStatementContext ctx) {
149 143
150 if (ctx.typeStatement().isEmpty() 144 if (ctx.typeStatement().isEmpty()
......
...@@ -28,10 +28,16 @@ import org.onosproject.yangutils.parser.exceptions.ParserException; ...@@ -28,10 +28,16 @@ import org.onosproject.yangutils.parser.exceptions.ParserException;
28 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 28 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
29 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 29 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
30 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 30 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
31 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 31 +
32 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 32 +import static org.onosproject.yangutils.parser.ParsableDataType.LEAF_DATA;
33 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 33 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
34 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 34 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
35 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
36 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
37 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
38 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
39 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
40 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
35 41
36 /* 42 /*
37 * Reference: RFC6020 and YANG ANTLR Grammar 43 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -85,15 +91,11 @@ public final class LeafListener { ...@@ -85,15 +91,11 @@ public final class LeafListener {
85 GeneratedYangParser.LeafStatementContext ctx) { 91 GeneratedYangParser.LeafStatementContext ctx) {
86 92
87 // Check for stack to be non empty. 93 // Check for stack to be non empty.
88 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 94 + checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), ENTRY);
89 - ParsableDataType.LEAF_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
90 - ListenerErrorLocation.ENTRY);
91 95
92 boolean result = validateSubStatementsCardinality(ctx); 96 boolean result = validateSubStatementsCardinality(ctx);
93 if (!result) { 97 if (!result) {
94 - throw new ParserException(ListenerErrorMessageConstruction 98 + throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
95 - .constructListenerErrorMessage(ListenerErrorType.INVALID_CARDINALITY,
96 - yangConstruct, "", ListenerErrorLocation.ENTRY));
97 } 99 }
98 100
99 YangLeaf leaf = new YangLeaf(); 101 YangLeaf leaf = new YangLeaf();
...@@ -106,11 +108,8 @@ public final class LeafListener { ...@@ -106,11 +108,8 @@ public final class LeafListener {
106 leaves = (YangLeavesHolder) tmpData; 108 leaves = (YangLeavesHolder) tmpData;
107 leaves.addLeaf(leaf); 109 leaves.addLeaf(leaf);
108 } else { 110 } else {
109 - throw new ParserException(ListenerErrorMessageConstruction 111 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_DATA,
110 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 112 + ctx.IDENTIFIER().getText(), ENTRY));
111 - ParsableDataType.LEAF_DATA,
112 - String.valueOf(ctx.IDENTIFIER().getText()),
113 - ListenerErrorLocation.ENTRY));
114 } 113 }
115 114
116 listener.getParsedDataStack().push(leaf); 115 listener.getParsedDataStack().push(leaf);
...@@ -127,18 +126,13 @@ public final class LeafListener { ...@@ -127,18 +126,13 @@ public final class LeafListener {
127 GeneratedYangParser.LeafStatementContext ctx) { 126 GeneratedYangParser.LeafStatementContext ctx) {
128 127
129 // Check for stack to be non empty. 128 // Check for stack to be non empty.
130 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 129 + checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), EXIT);
131 - ParsableDataType.LEAF_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
132 - ListenerErrorLocation.EXIT);
133 130
134 if (listener.getParsedDataStack().peek() instanceof YangLeaf) { 131 if (listener.getParsedDataStack().peek() instanceof YangLeaf) {
135 listener.getParsedDataStack().pop(); 132 listener.getParsedDataStack().pop();
136 } else { 133 } else {
137 - throw new ParserException(ListenerErrorMessageConstruction 134 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_DATA,
138 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 135 + ctx.IDENTIFIER().getText(), EXIT));
139 - ParsableDataType.LEAF_DATA,
140 - String.valueOf(ctx.IDENTIFIER().getText()),
141 - ListenerErrorLocation.EXIT));
142 } 136 }
143 } 137 }
144 138
...@@ -148,7 +142,7 @@ public final class LeafListener { ...@@ -148,7 +142,7 @@ public final class LeafListener {
148 * @param ctx context object of the grammar rule. 142 * @param ctx context object of the grammar rule.
149 * @return true/false validation success or failure. 143 * @return true/false validation success or failure.
150 */ 144 */
151 - public static boolean validateSubStatementsCardinality(GeneratedYangParser 145 + private static boolean validateSubStatementsCardinality(GeneratedYangParser
152 .LeafStatementContext ctx) { 146 .LeafStatementContext ctx) {
153 147
154 if (ctx.typeStatement().isEmpty() 148 if (ctx.typeStatement().isEmpty()
......
...@@ -18,14 +18,16 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -18,14 +18,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 import org.onosproject.yangutils.datamodel.YangLeaf; 19 import org.onosproject.yangutils.datamodel.YangLeaf;
20 import org.onosproject.yangutils.parser.Parsable; 20 import org.onosproject.yangutils.parser.Parsable;
21 -import org.onosproject.yangutils.parser.ParsableDataType;
22 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 21 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
23 import org.onosproject.yangutils.parser.exceptions.ParserException; 22 import org.onosproject.yangutils.parser.exceptions.ParserException;
24 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 23 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
25 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 24 +
26 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 25 +import static org.onosproject.yangutils.parser.ParsableDataType.MANDATORY_DATA;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 26 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
29 31
30 /* 32 /*
31 * Reference: RFC6020 and YANG ANTLR Grammar 33 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -67,8 +69,7 @@ public final class MandatoryListener { ...@@ -67,8 +69,7 @@ public final class MandatoryListener {
67 GeneratedYangParser.MandatoryStatementContext ctx) { 69 GeneratedYangParser.MandatoryStatementContext ctx) {
68 70
69 // Check for stack to be non empty. 71 // Check for stack to be non empty.
70 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 72 + checkStackIsNotEmpty(listener, MISSING_HOLDER, MANDATORY_DATA, "", ENTRY);
71 - ParsableDataType.MANDATORY_DATA, "", ListenerErrorLocation.ENTRY);
72 73
73 Parsable tmpNode = listener.getParsedDataStack().peek(); 74 Parsable tmpNode = listener.getParsedDataStack().peek();
74 switch (tmpNode.getParsableDataType()) { 75 switch (tmpNode.getParsableDataType()) {
...@@ -83,9 +84,7 @@ public final class MandatoryListener { ...@@ -83,9 +84,7 @@ public final class MandatoryListener {
83 case CHOICE_DATA: // TODO 84 case CHOICE_DATA: // TODO
84 break; 85 break;
85 default: 86 default:
86 - throw new ParserException(ListenerErrorMessageConstruction 87 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, MANDATORY_DATA, "", ENTRY));
87 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
88 - ParsableDataType.MANDATORY_DATA, "", ListenerErrorLocation.ENTRY));
89 } 88 }
90 } 89 }
91 } 90 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
19 import org.onosproject.yangutils.datamodel.YangLeafList; 19 import org.onosproject.yangutils.datamodel.YangLeafList;
20 import org.onosproject.yangutils.datamodel.YangList; 20 import org.onosproject.yangutils.datamodel.YangList;
21 import org.onosproject.yangutils.parser.Parsable; 21 import org.onosproject.yangutils.parser.Parsable;
22 -import org.onosproject.yangutils.parser.ParsableDataType;
23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 22 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
24 import org.onosproject.yangutils.parser.exceptions.ParserException; 23 import org.onosproject.yangutils.parser.exceptions.ParserException;
25 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 24 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
26 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 25 +
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 26 +import static org.onosproject.yangutils.parser.ParsableDataType.MAX_ELEMENT_DATA;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
30 32
31 /* 33 /*
32 * Reference: RFC6020 and YANG ANTLR Grammar 34 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -66,8 +68,7 @@ public final class MaxElementsListener { ...@@ -66,8 +68,7 @@ public final class MaxElementsListener {
66 int maxElementsValue; 68 int maxElementsValue;
67 69
68 // Check for stack to be non empty. 70 // Check for stack to be non empty.
69 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 71 + checkStackIsNotEmpty(listener, MISSING_HOLDER, MAX_ELEMENT_DATA, "", ENTRY);
70 - ParsableDataType.MAX_ELEMENT_DATA, "", ListenerErrorLocation.ENTRY);
71 72
72 if (ctx.maxValueArgument().UNBOUNDED_KEYWORD() != null) { 73 if (ctx.maxValueArgument().UNBOUNDED_KEYWORD() != null) {
73 maxElementsValue = Integer.MAX_VALUE; 74 maxElementsValue = Integer.MAX_VALUE;
...@@ -86,10 +87,7 @@ public final class MaxElementsListener { ...@@ -86,10 +87,7 @@ public final class MaxElementsListener {
86 yangList.setMaxElelements(maxElementsValue); 87 yangList.setMaxElelements(maxElementsValue);
87 break; 88 break;
88 default: 89 default:
89 - throw new ParserException(ListenerErrorMessageConstruction 90 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, MAX_ELEMENT_DATA, "", ENTRY));
90 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
91 - ParsableDataType.MAX_ELEMENT_DATA,
92 - "", ListenerErrorLocation.ENTRY));
93 } 91 }
94 } 92 }
95 } 93 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
19 import org.onosproject.yangutils.datamodel.YangLeafList; 19 import org.onosproject.yangutils.datamodel.YangLeafList;
20 import org.onosproject.yangutils.datamodel.YangList; 20 import org.onosproject.yangutils.datamodel.YangList;
21 import org.onosproject.yangutils.parser.Parsable; 21 import org.onosproject.yangutils.parser.Parsable;
22 -import org.onosproject.yangutils.parser.ParsableDataType;
23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 22 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
24 import org.onosproject.yangutils.parser.exceptions.ParserException; 23 import org.onosproject.yangutils.parser.exceptions.ParserException;
25 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 24 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
26 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 25 +
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 26 +import static org.onosproject.yangutils.parser.ParsableDataType.MIN_ELEMENT_DATA;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
30 32
31 /* 33 /*
32 * Reference: RFC6020 and YANG ANTLR Grammar 34 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -66,9 +68,7 @@ public final class MinElementsListener { ...@@ -66,9 +68,7 @@ public final class MinElementsListener {
66 GeneratedYangParser.MinElementsStatementContext ctx) { 68 GeneratedYangParser.MinElementsStatementContext ctx) {
67 69
68 // Check for stack to be non empty. 70 // Check for stack to be non empty.
69 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 71 + checkStackIsNotEmpty(listener, MISSING_HOLDER, MIN_ELEMENT_DATA, ctx.INTEGER().getText(), ENTRY);
70 - ParsableDataType.MIN_ELEMENT_DATA, String.valueOf(ctx.INTEGER().getText()),
71 - ListenerErrorLocation.ENTRY);
72 72
73 Parsable tmpData = listener.getParsedDataStack().peek(); 73 Parsable tmpData = listener.getParsedDataStack().peek();
74 switch (tmpData.getParsableDataType()) { 74 switch (tmpData.getParsableDataType()) {
...@@ -81,11 +81,8 @@ public final class MinElementsListener { ...@@ -81,11 +81,8 @@ public final class MinElementsListener {
81 yangList.setMinElements(Integer.parseInt(ctx.INTEGER().getText())); 81 yangList.setMinElements(Integer.parseInt(ctx.INTEGER().getText()));
82 break; 82 break;
83 default: 83 default:
84 - throw new ParserException(ListenerErrorMessageConstruction 84 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, MIN_ELEMENT_DATA,
85 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 85 + ctx.INTEGER().getText(), ENTRY));
86 - ParsableDataType.MIN_ELEMENT_DATA,
87 - String.valueOf(ctx.INTEGER().getText()),
88 - ListenerErrorLocation.ENTRY));
89 } 86 }
90 } 87 }
91 } 88 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -18,14 +18,17 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -18,14 +18,17 @@ package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 import org.onosproject.yangutils.datamodel.YangContainer; 19 import org.onosproject.yangutils.datamodel.YangContainer;
20 import org.onosproject.yangutils.parser.Parsable; 20 import org.onosproject.yangutils.parser.Parsable;
21 -import org.onosproject.yangutils.parser.ParsableDataType;
22 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 21 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
23 import org.onosproject.yangutils.parser.exceptions.ParserException; 22 import org.onosproject.yangutils.parser.exceptions.ParserException;
24 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 23 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
25 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 24 +
26 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 25 +import static org.onosproject.yangutils.parser.ParsableDataType.PRESENCE_DATA;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 26 +import static org.onosproject.yangutils.parser.ParsableDataType.CONTAINER_DATA;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
29 32
30 /* 33 /*
31 * Reference: RFC6020 and YANG ANTLR Grammar 34 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -61,20 +64,15 @@ public final class PresenceListener { ...@@ -61,20 +64,15 @@ public final class PresenceListener {
61 GeneratedYangParser.PresenceStatementContext ctx) { 64 GeneratedYangParser.PresenceStatementContext ctx) {
62 65
63 // Check for stack to be non empty. 66 // Check for stack to be non empty.
64 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 67 + checkStackIsNotEmpty(listener, MISSING_HOLDER, PRESENCE_DATA, ctx.string().getText(), ENTRY);
65 - ParsableDataType.PRESENCE_DATA, String.valueOf(ctx.string().getText()),
66 - ListenerErrorLocation.ENTRY);
67 68
68 Parsable tmpData = listener.getParsedDataStack().peek(); 69 Parsable tmpData = listener.getParsedDataStack().peek();
69 - if (tmpData.getParsableDataType() == ParsableDataType.CONTAINER_DATA) { 70 + if (tmpData.getParsableDataType() == CONTAINER_DATA) {
70 YangContainer container = (YangContainer) tmpData; 71 YangContainer container = (YangContainer) tmpData;
71 container.setPresence(ctx.string().getText()); 72 container.setPresence(ctx.string().getText());
72 } else { 73 } else {
73 - throw new ParserException(ListenerErrorMessageConstruction 74 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, PRESENCE_DATA,
74 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 75 + ctx.string().getText(), ENTRY));
75 - ParsableDataType.PRESENCE_DATA,
76 - String.valueOf(ctx.string().getText()),
77 - ListenerErrorLocation.ENTRY));
78 } 76 }
79 } 77 }
80 } 78 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -18,14 +18,16 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -18,14 +18,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 import org.onosproject.yangutils.datamodel.YangReference; 19 import org.onosproject.yangutils.datamodel.YangReference;
20 import org.onosproject.yangutils.parser.Parsable; 20 import org.onosproject.yangutils.parser.Parsable;
21 -import org.onosproject.yangutils.parser.ParsableDataType;
22 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 21 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
23 import org.onosproject.yangutils.parser.exceptions.ParserException; 22 import org.onosproject.yangutils.parser.exceptions.ParserException;
24 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 23 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
25 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 24 +
26 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 25 +import static org.onosproject.yangutils.parser.ParsableDataType.REFERENCE_DATA;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 26 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
29 31
30 /* 32 /*
31 * Reference: RFC6020 and YANG ANTLR Grammar 33 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -61,20 +63,15 @@ public final class ReferenceListener { ...@@ -61,20 +63,15 @@ public final class ReferenceListener {
61 GeneratedYangParser.ReferenceStatementContext ctx) { 63 GeneratedYangParser.ReferenceStatementContext ctx) {
62 64
63 // Check for stack to be non empty. 65 // Check for stack to be non empty.
64 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 66 + checkStackIsNotEmpty(listener, MISSING_HOLDER, REFERENCE_DATA, ctx.string().getText(), ENTRY);
65 - ParsableDataType.REFERENCE_DATA, String.valueOf(ctx.string().getText()),
66 - ListenerErrorLocation.ENTRY);
67 67
68 Parsable tmpData = listener.getParsedDataStack().peek(); 68 Parsable tmpData = listener.getParsedDataStack().peek();
69 if (tmpData instanceof YangReference) { 69 if (tmpData instanceof YangReference) {
70 YangReference reference = (YangReference) tmpData; 70 YangReference reference = (YangReference) tmpData;
71 reference.setReference(ctx.string().getText()); 71 reference.setReference(ctx.string().getText());
72 } else { 72 } else {
73 - throw new ParserException(ListenerErrorMessageConstruction 73 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, REFERENCE_DATA,
74 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 74 + ctx.string().getText(), ENTRY));
75 - ParsableDataType.REFERENCE_DATA,
76 - String.valueOf(ctx.string().getText()),
77 - ListenerErrorLocation.ENTRY));
78 } 75 }
79 } 76 }
80 } 77 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
19 import org.onosproject.yangutils.datamodel.YangStatus; 19 import org.onosproject.yangutils.datamodel.YangStatus;
20 import org.onosproject.yangutils.datamodel.YangStatusType; 20 import org.onosproject.yangutils.datamodel.YangStatusType;
21 import org.onosproject.yangutils.parser.Parsable; 21 import org.onosproject.yangutils.parser.Parsable;
22 -import org.onosproject.yangutils.parser.ParsableDataType;
23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 22 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
24 import org.onosproject.yangutils.parser.exceptions.ParserException; 23 import org.onosproject.yangutils.parser.exceptions.ParserException;
25 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 24 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
26 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 25 +
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 26 +import static org.onosproject.yangutils.parser.ParsableDataType.STATUS_DATA;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
30 32
31 /* 33 /*
32 * Reference: RFC6020 and YANG ANTLR Grammar 34 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -68,15 +70,14 @@ public final class StatusListener { ...@@ -68,15 +70,14 @@ public final class StatusListener {
68 YangStatusType status; 70 YangStatusType status;
69 71
70 // Check for stack to be non empty. 72 // Check for stack to be non empty.
71 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 73 + checkStackIsNotEmpty(listener, MISSING_HOLDER, STATUS_DATA, "", ENTRY);
72 - ParsableDataType.STATUS_DATA, "", ListenerErrorLocation.ENTRY);
73 74
74 if (ctx.CURRENT_KEYWORD() != null) { 75 if (ctx.CURRENT_KEYWORD() != null) {
75 - status = YangStatusType.CURRENT.CURRENT; 76 + status = YangStatusType.CURRENT;
76 } else if (ctx.DEPRECATED_KEYWORD() != null) { 77 } else if (ctx.DEPRECATED_KEYWORD() != null) {
77 status = YangStatusType.DEPRECATED; 78 status = YangStatusType.DEPRECATED;
78 } else { 79 } else {
79 - status = YangStatusType.OBSOLETE.OBSOLETE; 80 + status = YangStatusType.OBSOLETE;
80 } 81 }
81 82
82 Parsable tmpData = listener.getParsedDataStack().peek(); 83 Parsable tmpData = listener.getParsedDataStack().peek();
...@@ -84,9 +85,7 @@ public final class StatusListener { ...@@ -84,9 +85,7 @@ public final class StatusListener {
84 YangStatus yangStatus = (YangStatus) tmpData; 85 YangStatus yangStatus = (YangStatus) tmpData;
85 yangStatus.setStatus(status); 86 yangStatus.setStatus(status);
86 } else { 87 } else {
87 - throw new ParserException(ListenerErrorMessageConstruction 88 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, STATUS_DATA, "", ENTRY));
88 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
89 - ParsableDataType.STATUS_DATA, "", ListenerErrorLocation.ENTRY));
90 } 89 }
91 } 90 }
92 } 91 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -21,14 +21,17 @@ import org.onosproject.yangutils.datamodel.YangLeaf; ...@@ -21,14 +21,17 @@ import org.onosproject.yangutils.datamodel.YangLeaf;
21 import org.onosproject.yangutils.datamodel.YangLeafList; 21 import org.onosproject.yangutils.datamodel.YangLeafList;
22 import org.onosproject.yangutils.datamodel.YangType; 22 import org.onosproject.yangutils.datamodel.YangType;
23 import org.onosproject.yangutils.parser.Parsable; 23 import org.onosproject.yangutils.parser.Parsable;
24 -import org.onosproject.yangutils.parser.ParsableDataType;
25 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
26 import org.onosproject.yangutils.parser.exceptions.ParserException; 25 import org.onosproject.yangutils.parser.exceptions.ParserException;
27 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 26 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 27 +
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 28 +import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
30 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
31 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
33 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
34 +
32 35
33 /* 36 /*
34 * Reference: RFC6020 and YANG ANTLR Grammar 37 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -68,9 +71,7 @@ public final class TypeListener { ...@@ -68,9 +71,7 @@ public final class TypeListener {
68 GeneratedYangParser.TypeStatementContext ctx) { 71 GeneratedYangParser.TypeStatementContext ctx) {
69 72
70 // Check for stack to be non empty. 73 // Check for stack to be non empty.
71 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 74 + checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPE_DATA, ctx.string().getText(), ENTRY);
72 - ParsableDataType.TYPE_DATA, String.valueOf(ctx.string().getText()),
73 - ListenerErrorLocation.ENTRY);
74 75
75 YangType type = new YangType(); 76 YangType type = new YangType();
76 YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText()); 77 YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText());
...@@ -90,11 +91,8 @@ public final class TypeListener { ...@@ -90,11 +91,8 @@ public final class TypeListener {
90 case TYPEDEF_DATA: //TODO 91 case TYPEDEF_DATA: //TODO
91 break; 92 break;
92 default: 93 default:
93 - throw new ParserException(ListenerErrorMessageConstruction 94 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
94 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 95 + ctx.string().getText(), ENTRY));
95 - ParsableDataType.TYPE_DATA,
96 - String.valueOf(ctx.string().getText()),
97 - ListenerErrorLocation.ENTRY));
98 } 96 }
99 } 97 }
100 } 98 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
19 import org.onosproject.yangutils.datamodel.YangLeaf; 19 import org.onosproject.yangutils.datamodel.YangLeaf;
20 import org.onosproject.yangutils.datamodel.YangLeafList; 20 import org.onosproject.yangutils.datamodel.YangLeafList;
21 import org.onosproject.yangutils.parser.Parsable; 21 import org.onosproject.yangutils.parser.Parsable;
22 -import org.onosproject.yangutils.parser.ParsableDataType;
23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 22 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
24 import org.onosproject.yangutils.parser.exceptions.ParserException; 23 import org.onosproject.yangutils.parser.exceptions.ParserException;
25 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 24 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
26 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 25 +
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 26 +import static org.onosproject.yangutils.parser.ParsableDataType.UNITS_DATA;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
30 32
31 /* 33 /*
32 * Reference: RFC6020 and YANG ANTLR Grammar 34 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -62,9 +64,7 @@ public final class UnitsListener { ...@@ -62,9 +64,7 @@ public final class UnitsListener {
62 GeneratedYangParser.UnitsStatementContext ctx) { 64 GeneratedYangParser.UnitsStatementContext ctx) {
63 65
64 // Check for stack to be non empty. 66 // Check for stack to be non empty.
65 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 67 + checkStackIsNotEmpty(listener, MISSING_HOLDER, UNITS_DATA, ctx.string().getText(), ENTRY);
66 - ParsableDataType.UNITS_DATA, String.valueOf(ctx.string().getText()),
67 - ListenerErrorLocation.ENTRY);
68 68
69 Parsable tmpData = listener.getParsedDataStack().peek(); 69 Parsable tmpData = listener.getParsedDataStack().peek();
70 switch (tmpData.getParsableDataType()) { 70 switch (tmpData.getParsableDataType()) {
...@@ -80,11 +80,8 @@ public final class UnitsListener { ...@@ -80,11 +80,8 @@ public final class UnitsListener {
80 // TODO 80 // TODO
81 break; 81 break;
82 default: 82 default:
83 - throw new ParserException(ListenerErrorMessageConstruction 83 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, UNITS_DATA,
84 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 84 + ctx.string().getText(), ENTRY));
85 - ParsableDataType.UNITS_DATA,
86 - String.valueOf(ctx.string().getText()),
87 - ListenerErrorLocation.ENTRY));
88 } 85 }
89 } 86 }
90 } 87 }
...\ No newline at end of file ...\ No newline at end of file
......