Gaurav Agrawal
Committed by Gerrit Code Review

[ONOS-3880, 3881] Change to static import for lesser indentation.

Change-Id: I93a39f9b0ccd019ace5900bf8ba68f7d60f228a0
Showing 17 changed files with 304 additions and 395 deletions
...@@ -19,14 +19,17 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -19,14 +19,17 @@ package org.onosproject.yangutils.parser.impl.listeners;
19 import org.onosproject.yangutils.datamodel.YangModule; 19 import org.onosproject.yangutils.datamodel.YangModule;
20 import org.onosproject.yangutils.datamodel.YangNode; 20 import org.onosproject.yangutils.datamodel.YangNode;
21 import org.onosproject.yangutils.datamodel.YangSubModule; 21 import org.onosproject.yangutils.datamodel.YangSubModule;
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.YANGBASE_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.ListenerErrorLocation.EXIT;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
30 33
31 /* 34 /*
32 * Reference: RFC6020 and YANG ANTLR Grammar 35 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -49,9 +52,8 @@ public final class BaseFileListener { ...@@ -49,9 +52,8 @@ public final class BaseFileListener {
49 } 52 }
50 53
51 /** 54 /**
52 - * It is called when parser receives an input matching the grammar 55 + * It is called when parser receives an input matching the grammar rule
53 - * rule (yangfile), perform validations and update the data model 56 + * (yangfile), perform validations and update the data model tree.
54 - * tree.
55 * 57 *
56 * @param listener Listener's object. 58 * @param listener Listener's object.
57 * @param ctx context object of the grammar rule. 59 * @param ctx context object of the grammar rule.
...@@ -59,8 +61,7 @@ public final class BaseFileListener { ...@@ -59,8 +61,7 @@ public final class BaseFileListener {
59 public static void processYangFileEntry(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) { 61 public static void processYangFileEntry(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) {
60 62
61 // Check if stack is empty. 63 // Check if stack is empty.
62 - ListenerValidation.checkStackIsEmpty(listener, ListenerErrorType.INVALID_HOLDER, 64 + checkStackIsEmpty(listener, INVALID_HOLDER, YANGBASE_DATA, "", ENTRY);
63 - ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.ENTRY);
64 65
65 } 66 }
66 67
...@@ -74,23 +75,17 @@ public final class BaseFileListener { ...@@ -74,23 +75,17 @@ public final class BaseFileListener {
74 public static void processYangFileExit(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) { 75 public static void processYangFileExit(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) {
75 76
76 // Check for stack to be non empty. 77 // Check for stack to be non empty.
77 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 78 + checkStackIsNotEmpty(listener, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
78 - ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
79 79
80 // Data Model tree root node is set. 80 // Data Model tree root node is set.
81 if (listener.getParsedDataStack().peek() instanceof YangModule 81 if (listener.getParsedDataStack().peek() instanceof YangModule
82 - | listener.getParsedDataStack().peek() instanceof YangSubModule) { 82 + || listener.getParsedDataStack().peek() instanceof YangSubModule) {
83 listener.setRootNode((YangNode) listener.getParsedDataStack().pop()); 83 listener.setRootNode((YangNode) listener.getParsedDataStack().pop());
84 } else { 84 } else {
85 - throw new ParserException( 85 + throw new ParserException(constructListenerErrorMessage(INVALID_CHILD, YANGBASE_DATA, "", EXIT));
86 - ListenerErrorMessageConstruction
87 - .constructListenerErrorMessage(ListenerErrorType.INVALID_CHILD,
88 - ParsableDataType.YANGBASE_DATA, "",
89 - ListenerErrorLocation.EXIT));
90 } 86 }
91 87
92 // Check if stack is empty. 88 // Check if stack is empty.
93 - ListenerValidation.checkStackIsEmpty(listener, ListenerErrorType.INVALID_HOLDER, 89 + checkStackIsEmpty(listener, INVALID_HOLDER, YANGBASE_DATA, "", EXIT);
94 - ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
95 } 90 }
96 -}
...\ No newline at end of file ...\ No newline at end of file
91 +}
......
...@@ -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.YangBelongsTo; 19 import org.onosproject.yangutils.datamodel.YangBelongsTo;
20 import org.onosproject.yangutils.datamodel.YangSubModule; 20 import org.onosproject.yangutils.datamodel.YangSubModule;
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.BELONGS_TO_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.ListenerErrorLocation.EXIT;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
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
...@@ -52,8 +54,9 @@ import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; ...@@ -52,8 +54,9 @@ import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
52 */ 54 */
53 55
54 /** 56 /**
55 - * Implements listener based call back function corresponding to the "belongs to" 57 + * Implements listener based call back function corresponding to the
56 - * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. 58 + * "belongs to" rule defined in ANTLR grammar file for corresponding ABNF rule
59 + * in RFC 6020.
57 */ 60 */
58 public final class BelongsToListener { 61 public final class BelongsToListener {
59 62
...@@ -64,9 +67,8 @@ public final class BelongsToListener { ...@@ -64,9 +67,8 @@ public final class BelongsToListener {
64 } 67 }
65 68
66 /** 69 /**
67 - * It is called when parser receives an input matching the grammar 70 + * It is called when parser receives an input matching the grammar rule
68 - * rule (belongsto), perform validations and update the data model 71 + * (belongsto), perform validations and update the data model tree.
69 - * tree.
70 * 72 *
71 * @param listener Listener's object. 73 * @param listener Listener's object.
72 * @param ctx context object of the grammar rule. 74 * @param ctx context object of the grammar rule.
...@@ -75,10 +77,8 @@ public final class BelongsToListener { ...@@ -75,10 +77,8 @@ public final class BelongsToListener {
75 GeneratedYangParser.BelongstoStatementContext ctx) { 77 GeneratedYangParser.BelongstoStatementContext ctx) {
76 78
77 // Check for stack to be non empty. 79 // Check for stack to be non empty.
78 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 80 + checkStackIsNotEmpty(listener, MISSING_HOLDER, BELONGS_TO_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
79 - ParsableDataType.BELONGS_TO_DATA, 81 + ENTRY);
80 - String.valueOf(ctx.IDENTIFIER().getText()),
81 - ListenerErrorLocation.ENTRY);
82 82
83 YangBelongsTo belongstoNode = new YangBelongsTo(); 83 YangBelongsTo belongstoNode = new YangBelongsTo();
84 belongstoNode.setBelongsToModuleName(String.valueOf(ctx.IDENTIFIER().getText())); 84 belongstoNode.setBelongsToModuleName(String.valueOf(ctx.IDENTIFIER().getText()));
...@@ -98,20 +98,16 @@ public final class BelongsToListener { ...@@ -98,20 +98,16 @@ public final class BelongsToListener {
98 GeneratedYangParser.BelongstoStatementContext ctx) { 98 GeneratedYangParser.BelongstoStatementContext ctx) {
99 99
100 // Check for stack to be non empty. 100 // Check for stack to be non empty.
101 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 101 + checkStackIsNotEmpty(listener, MISSING_HOLDER, BELONGS_TO_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
102 - ParsableDataType.BELONGS_TO_DATA, 102 + EXIT);
103 - String.valueOf(ctx.IDENTIFIER().getText()),
104 - ListenerErrorLocation.EXIT);
105 103
106 Parsable tmpBelongstoNode = listener.getParsedDataStack().peek(); 104 Parsable tmpBelongstoNode = listener.getParsedDataStack().peek();
107 if (tmpBelongstoNode instanceof YangBelongsTo) { 105 if (tmpBelongstoNode instanceof YangBelongsTo) {
108 listener.getParsedDataStack().pop(); 106 listener.getParsedDataStack().pop();
109 107
110 // Check for stack to be empty. 108 // Check for stack to be empty.
111 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 109 + checkStackIsNotEmpty(listener, MISSING_HOLDER, BELONGS_TO_DATA,
112 - ParsableDataType.BELONGS_TO_DATA, 110 + String.valueOf(ctx.IDENTIFIER().getText()), EXIT);
113 - String.valueOf(ctx.IDENTIFIER().getText()),
114 - ListenerErrorLocation.EXIT);
115 111
116 Parsable tmpNode = listener.getParsedDataStack().peek(); 112 Parsable tmpNode = listener.getParsedDataStack().peek();
117 switch (tmpNode.getParsableDataType()) { 113 switch (tmpNode.getParsableDataType()) {
...@@ -121,22 +117,13 @@ public final class BelongsToListener { ...@@ -121,22 +117,13 @@ public final class BelongsToListener {
121 break; 117 break;
122 } 118 }
123 default: 119 default:
124 - throw new ParserException( 120 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, BELONGS_TO_DATA,
125 - ListenerErrorMessageConstruction 121 + String.valueOf(ctx.IDENTIFIER().getText()),
126 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 122 + EXIT));
127 - ParsableDataType.BELONGS_TO_DATA,
128 - String.valueOf(ctx.IDENTIFIER()
129 - .getText()),
130 - ListenerErrorLocation.EXIT));
131 } 123 }
132 } else { 124 } else {
133 - throw new ParserException( 125 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, BELONGS_TO_DATA,
134 - ListenerErrorMessageConstruction 126 + String.valueOf(ctx.IDENTIFIER().getText()), EXIT));
135 - .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
136 - ParsableDataType.BELONGS_TO_DATA,
137 - String.valueOf(ctx.IDENTIFIER()
138 - .getText()),
139 - ListenerErrorLocation.EXIT));
140 } 127 }
141 } 128 }
142 -}
...\ No newline at end of file ...\ No newline at end of file
129 +}
......
...@@ -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.YangModule; 19 import org.onosproject.yangutils.datamodel.YangModule;
20 import org.onosproject.yangutils.datamodel.YangSubModule; 20 import org.onosproject.yangutils.datamodel.YangSubModule;
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.CONTACT_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
...@@ -81,9 +83,8 @@ public final class ContactListener { ...@@ -81,9 +83,8 @@ public final class ContactListener {
81 } 83 }
82 84
83 /** 85 /**
84 - * It is called when parser receives an input matching the grammar 86 + * It is called when parser receives an input matching the grammar rule
85 - * rule (contact), perform validations and update the data model 87 + * (contact), perform validations and update the data model tree.
86 - * tree.
87 * 88 *
88 * @param listener Listener's object. 89 * @param listener Listener's object.
89 * @param ctx context object of the grammar rule. 90 * @param ctx context object of the grammar rule.
...@@ -91,9 +92,7 @@ public final class ContactListener { ...@@ -91,9 +92,7 @@ public final class ContactListener {
91 public static void processContactEntry(TreeWalkListener listener, GeneratedYangParser.ContactStatementContext ctx) { 92 public static void processContactEntry(TreeWalkListener listener, GeneratedYangParser.ContactStatementContext ctx) {
92 93
93 // Check for stack to be non empty. 94 // Check for stack to be non empty.
94 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 95 + checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTACT_DATA, String.valueOf(ctx.string().getText()), ENTRY);
95 - ParsableDataType.CONTACT_DATA,
96 - String.valueOf(ctx.string().getText()), ListenerErrorLocation.ENTRY);
97 96
98 // Obtain the node of the stack. 97 // Obtain the node of the stack.
99 Parsable tmpNode = listener.getParsedDataStack().peek(); 98 Parsable tmpNode = listener.getParsedDataStack().peek();
...@@ -109,12 +108,8 @@ public final class ContactListener { ...@@ -109,12 +108,8 @@ public final class ContactListener {
109 break; 108 break;
110 } 109 }
111 default: 110 default:
112 - throw new ParserException( 111 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA,
113 - ListenerErrorMessageConstruction 112 + String.valueOf(ctx.string().getText()), ENTRY));
114 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
115 - ParsableDataType.CONTACT_DATA,
116 - String.valueOf(ctx.string().getText()),
117 - ListenerErrorLocation.ENTRY));
118 } 113 }
119 } 114 }
120 -}
...\ No newline at end of file ...\ No newline at end of file
115 +}
......
...@@ -20,14 +20,16 @@ import org.onosproject.yangutils.datamodel.YangImport; ...@@ -20,14 +20,16 @@ import org.onosproject.yangutils.datamodel.YangImport;
20 import org.onosproject.yangutils.datamodel.YangModule; 20 import org.onosproject.yangutils.datamodel.YangModule;
21 import org.onosproject.yangutils.datamodel.YangSubModule; 21 import org.onosproject.yangutils.datamodel.YangSubModule;
22 import org.onosproject.yangutils.parser.Parsable; 22 import org.onosproject.yangutils.parser.Parsable;
23 -import org.onosproject.yangutils.parser.ParsableDataType;
24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
25 import org.onosproject.yangutils.parser.exceptions.ParserException; 24 import org.onosproject.yangutils.parser.exceptions.ParserException;
26 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 25 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 26 +
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 27 +import static org.onosproject.yangutils.parser.ParsableDataType.IMPORT_DATA;
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
30 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
31 33
32 /* 34 /*
33 * Reference: RFC6020 and YANG ANTLR Grammar 35 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -64,9 +66,8 @@ public final class ImportListener { ...@@ -64,9 +66,8 @@ public final class ImportListener {
64 } 66 }
65 67
66 /** 68 /**
67 - * It is called when parser receives an input matching the grammar 69 + * It is called when parser receives an input matching the grammar rule
68 - * rule (import), perform validations and update the data model 70 + * (import), perform validations and update the data model tree.
69 - * tree.
70 * 71 *
71 * @param listener Listener's object. 72 * @param listener Listener's object.
72 * @param ctx context object of the grammar rule. 73 * @param ctx context object of the grammar rule.
...@@ -74,10 +75,7 @@ public final class ImportListener { ...@@ -74,10 +75,7 @@ public final class ImportListener {
74 public static void processImportEntry(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) { 75 public static void processImportEntry(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) {
75 76
76 // Check for stack to be non empty. 77 // Check for stack to be non empty.
77 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 78 + checkStackIsNotEmpty(listener, MISSING_HOLDER, IMPORT_DATA, String.valueOf(ctx.IDENTIFIER().getText()), ENTRY);
78 - ParsableDataType.IMPORT_DATA,
79 - String.valueOf(ctx.IDENTIFIER().getText()),
80 - ListenerErrorLocation.ENTRY);
81 79
82 YangImport importNode = new YangImport(); 80 YangImport importNode = new YangImport();
83 importNode.setModuleName(String.valueOf(ctx.IDENTIFIER().getText())); 81 importNode.setModuleName(String.valueOf(ctx.IDENTIFIER().getText()));
...@@ -96,20 +94,15 @@ public final class ImportListener { ...@@ -96,20 +94,15 @@ public final class ImportListener {
96 public static void processImportExit(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) { 94 public static void processImportExit(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) {
97 95
98 // Check for stack to be non empty. 96 // Check for stack to be non empty.
99 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 97 + checkStackIsNotEmpty(listener, MISSING_HOLDER, IMPORT_DATA, String.valueOf(ctx.IDENTIFIER().getText()), EXIT);
100 - ParsableDataType.IMPORT_DATA,
101 - String.valueOf(ctx.IDENTIFIER().getText()),
102 - ListenerErrorLocation.EXIT);
103 98
104 Parsable tmpImportNode = listener.getParsedDataStack().peek(); 99 Parsable tmpImportNode = listener.getParsedDataStack().peek();
105 if (tmpImportNode instanceof YangImport) { 100 if (tmpImportNode instanceof YangImport) {
106 listener.getParsedDataStack().pop(); 101 listener.getParsedDataStack().pop();
107 102
108 // Check for stack to be non empty. 103 // Check for stack to be non empty.
109 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 104 + checkStackIsNotEmpty(listener, MISSING_HOLDER, IMPORT_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
110 - ParsableDataType.IMPORT_DATA, 105 + EXIT);
111 - String.valueOf(ctx.IDENTIFIER().getText()),
112 - ListenerErrorLocation.EXIT);
113 106
114 Parsable tmpNode = listener.getParsedDataStack().peek(); 107 Parsable tmpNode = listener.getParsedDataStack().peek();
115 switch (tmpNode.getParsableDataType()) { 108 switch (tmpNode.getParsableDataType()) {
...@@ -124,22 +117,13 @@ public final class ImportListener { ...@@ -124,22 +117,13 @@ public final class ImportListener {
124 break; 117 break;
125 } 118 }
126 default: 119 default:
127 - throw new ParserException( 120 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, IMPORT_DATA,
128 - ListenerErrorMessageConstruction 121 + String.valueOf(ctx.IDENTIFIER().getText()),
129 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 122 + EXIT));
130 - ParsableDataType.IMPORT_DATA,
131 - String.valueOf(ctx.IDENTIFIER()
132 - .getText()),
133 - ListenerErrorLocation.EXIT));
134 } 123 }
135 } else { 124 } else {
136 - throw new ParserException( 125 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, IMPORT_DATA,
137 - ListenerErrorMessageConstruction 126 + String.valueOf(ctx.IDENTIFIER().getText()), EXIT));
138 - .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
139 - ParsableDataType.IMPORT_DATA, String
140 - .valueOf(ctx.IDENTIFIER()
141 - .getText()),
142 - ListenerErrorLocation.EXIT));
143 } 127 }
144 } 128 }
145 -}
...\ No newline at end of file ...\ No newline at end of file
129 +}
......
...@@ -20,14 +20,16 @@ import org.onosproject.yangutils.datamodel.YangInclude; ...@@ -20,14 +20,16 @@ import org.onosproject.yangutils.datamodel.YangInclude;
20 import org.onosproject.yangutils.datamodel.YangModule; 20 import org.onosproject.yangutils.datamodel.YangModule;
21 import org.onosproject.yangutils.datamodel.YangSubModule; 21 import org.onosproject.yangutils.datamodel.YangSubModule;
22 import org.onosproject.yangutils.parser.Parsable; 22 import org.onosproject.yangutils.parser.Parsable;
23 -import org.onosproject.yangutils.parser.ParsableDataType;
24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
25 import org.onosproject.yangutils.parser.exceptions.ParserException; 24 import org.onosproject.yangutils.parser.exceptions.ParserException;
26 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 25 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 26 +
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 27 +import static org.onosproject.yangutils.parser.ParsableDataType.INCLUDE_DATA;
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
30 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
31 33
32 /* 34 /*
33 * Reference: RFC6020 and YANG ANTLR Grammar 35 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -63,9 +65,8 @@ public final class IncludeListener { ...@@ -63,9 +65,8 @@ public final class IncludeListener {
63 } 65 }
64 66
65 /** 67 /**
66 - * It is called when parser receives an input matching the grammar 68 + * It is called when parser receives an input matching the grammar rule
67 - * rule (include), perform validations and update the data model 69 + * (include), perform validations and update the data model tree.
68 - * tree.
69 * 70 *
70 * @param listener Listener's object. 71 * @param listener Listener's object.
71 * @param ctx context object of the grammar rule. 72 * @param ctx context object of the grammar rule.
...@@ -73,10 +74,8 @@ public final class IncludeListener { ...@@ -73,10 +74,8 @@ public final class IncludeListener {
73 public static void processIncludeEntry(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) { 74 public static void processIncludeEntry(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) {
74 75
75 // Check for stack to be non empty. 76 // Check for stack to be non empty.
76 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 77 + checkStackIsNotEmpty(listener, MISSING_HOLDER, INCLUDE_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
77 - ParsableDataType.INCLUDE_DATA, 78 + ENTRY);
78 - String.valueOf(ctx.IDENTIFIER().getText()),
79 - ListenerErrorLocation.ENTRY);
80 79
81 YangInclude includeNode = new YangInclude(); 80 YangInclude includeNode = new YangInclude();
82 includeNode.setSubModuleName(String.valueOf(ctx.IDENTIFIER().getText())); 81 includeNode.setSubModuleName(String.valueOf(ctx.IDENTIFIER().getText()));
...@@ -94,20 +93,15 @@ public final class IncludeListener { ...@@ -94,20 +93,15 @@ public final class IncludeListener {
94 public static void processIncludeExit(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) { 93 public static void processIncludeExit(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) {
95 94
96 // Check for stack to be non empty. 95 // Check for stack to be non empty.
97 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 96 + checkStackIsNotEmpty(listener, MISSING_HOLDER, INCLUDE_DATA, String.valueOf(ctx.IDENTIFIER().getText()), EXIT);
98 - ParsableDataType.INCLUDE_DATA,
99 - String.valueOf(ctx.IDENTIFIER().getText()),
100 - ListenerErrorLocation.EXIT);
101 97
102 Parsable tmpIncludeNode = listener.getParsedDataStack().peek(); 98 Parsable tmpIncludeNode = listener.getParsedDataStack().peek();
103 if (tmpIncludeNode instanceof YangInclude) { 99 if (tmpIncludeNode instanceof YangInclude) {
104 listener.getParsedDataStack().pop(); 100 listener.getParsedDataStack().pop();
105 101
106 // Check for stack to be non empty. 102 // Check for stack to be non empty.
107 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 103 + checkStackIsNotEmpty(listener, MISSING_HOLDER, INCLUDE_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
108 - ParsableDataType.INCLUDE_DATA, 104 + EXIT);
109 - String.valueOf(ctx.IDENTIFIER().getText()),
110 - ListenerErrorLocation.EXIT);
111 105
112 Parsable tmpNode = listener.getParsedDataStack().peek(); 106 Parsable tmpNode = listener.getParsedDataStack().peek();
113 switch (tmpNode.getParsableDataType()) { 107 switch (tmpNode.getParsableDataType()) {
...@@ -122,22 +116,13 @@ public final class IncludeListener { ...@@ -122,22 +116,13 @@ public final class IncludeListener {
122 break; 116 break;
123 } 117 }
124 default: 118 default:
125 - throw new ParserException( 119 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, INCLUDE_DATA,
126 - ListenerErrorMessageConstruction 120 + String.valueOf(ctx.IDENTIFIER().getText()),
127 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 121 + EXIT));
128 - ParsableDataType.INCLUDE_DATA,
129 - String.valueOf(ctx.IDENTIFIER()
130 - .getText()),
131 - ListenerErrorLocation.EXIT));
132 } 122 }
133 } else { 123 } else {
134 - throw new ParserException( 124 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, INCLUDE_DATA,
135 - ListenerErrorMessageConstruction 125 + String.valueOf(ctx.IDENTIFIER().getText()), EXIT));
136 - .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
137 - ParsableDataType.INCLUDE_DATA, String
138 - .valueOf(ctx.IDENTIFIER()
139 - .getText()),
140 - ListenerErrorLocation.EXIT));
141 } 126 }
142 } 127 }
143 -}
...\ No newline at end of file ...\ No newline at end of file
128 +}
......
...@@ -17,14 +17,17 @@ ...@@ -17,14 +17,17 @@
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 import org.onosproject.yangutils.datamodel.YangModule; 19 import org.onosproject.yangutils.datamodel.YangModule;
20 -import org.onosproject.yangutils.parser.ParsableDataType;
21 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 20 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
22 import org.onosproject.yangutils.parser.exceptions.ParserException; 21 import org.onosproject.yangutils.parser.exceptions.ParserException;
23 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 22 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
24 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 23 +
25 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 24 +import static org.onosproject.yangutils.parser.ParsableDataType.MODULE_DATA;
26 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 25 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 26 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
28 31
29 /* 32 /*
30 * Reference: RFC6020 and YANG ANTLR Grammar 33 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -57,9 +60,8 @@ public final class ModuleListener { ...@@ -57,9 +60,8 @@ public final class ModuleListener {
57 } 60 }
58 61
59 /** 62 /**
60 - * It is called when parser receives an input matching the grammar 63 + * It is called when parser receives an input matching the grammar rule
61 - * rule (module), perform validations and update the data model 64 + * (module), perform validations and update the data model tree.
62 - * tree.
63 * 65 *
64 * @param listener Listener's object. 66 * @param listener Listener's object.
65 * @param ctx context object of the grammar rule. 67 * @param ctx context object of the grammar rule.
...@@ -67,9 +69,7 @@ public final class ModuleListener { ...@@ -67,9 +69,7 @@ public final class ModuleListener {
67 public static void processModuleEntry(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) { 69 public static void processModuleEntry(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
68 70
69 // Check if stack is empty. 71 // Check if stack is empty.
70 - ListenerValidation 72 + checkStackIsEmpty(listener, INVALID_HOLDER, MODULE_DATA, String.valueOf(ctx.IDENTIFIER().getText()), ENTRY);
71 - .checkStackIsEmpty(listener, ListenerErrorType.INVALID_HOLDER, ParsableDataType.MODULE_DATA,
72 - String.valueOf(ctx.IDENTIFIER().getText()), ListenerErrorLocation.ENTRY);
73 73
74 YangModule yangModule = new YangModule(); 74 YangModule yangModule = new YangModule();
75 yangModule.setName(ctx.IDENTIFIER().getText()); 75 yangModule.setName(ctx.IDENTIFIER().getText());
...@@ -87,19 +87,11 @@ public final class ModuleListener { ...@@ -87,19 +87,11 @@ public final class ModuleListener {
87 public static void processModuleExit(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) { 87 public static void processModuleExit(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
88 88
89 // Check for stack to be non empty. 89 // Check for stack to be non empty.
90 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 90 + checkStackIsNotEmpty(listener, MISSING_HOLDER, MODULE_DATA, String.valueOf(ctx.IDENTIFIER().getText()), EXIT);
91 - ParsableDataType.MODULE_DATA,
92 - String.valueOf(ctx.IDENTIFIER().getText()),
93 - ListenerErrorLocation.EXIT);
94 91
95 if (!(listener.getParsedDataStack().peek() instanceof YangModule)) { 92 if (!(listener.getParsedDataStack().peek() instanceof YangModule)) {
96 - throw new ParserException( 93 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, MODULE_DATA,
97 - ListenerErrorMessageConstruction 94 + String.valueOf(ctx.IDENTIFIER().getText()), EXIT));
98 - .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
99 - ParsableDataType.MODULE_DATA, String
100 - .valueOf(ctx.IDENTIFIER()
101 - .getText()),
102 - ListenerErrorLocation.EXIT));
103 } 95 }
104 } 96 }
105 -}
...\ No newline at end of file ...\ No newline at end of file
97 +}
......
...@@ -19,17 +19,19 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -19,17 +19,19 @@ package org.onosproject.yangutils.parser.impl.listeners;
19 import org.onosproject.yangutils.datamodel.YangModule; 19 import org.onosproject.yangutils.datamodel.YangModule;
20 import org.onosproject.yangutils.datamodel.YangNameSpace; 20 import org.onosproject.yangutils.datamodel.YangNameSpace;
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;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
30 25
31 import java.net.URI; 26 import java.net.URI;
32 27
28 +import static org.onosproject.yangutils.parser.ParsableDataType.NAMESPACE_DATA;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
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 +
33 /* 35 /*
34 * Reference: RFC6020 and YANG ANTLR Grammar 36 * Reference: RFC6020 and YANG ANTLR Grammar
35 * 37 *
...@@ -65,9 +67,8 @@ public final class NamespaceListener { ...@@ -65,9 +67,8 @@ public final class NamespaceListener {
65 } 67 }
66 68
67 /** 69 /**
68 - * It is called when parser receives an input matching the grammar 70 + * It is called when parser receives an input matching the grammar rule
69 - * rule (namespace), perform validations and update the data model 71 + * (namespace), perform validations and update the data model tree.
70 - * tree.
71 * 72 *
72 * @param listener Listener's object. 73 * @param listener Listener's object.
73 * @param ctx context object of the grammar rule. 74 * @param ctx context object of the grammar rule.
...@@ -76,9 +77,7 @@ public final class NamespaceListener { ...@@ -76,9 +77,7 @@ public final class NamespaceListener {
76 GeneratedYangParser.NamespaceStatementContext ctx) { 77 GeneratedYangParser.NamespaceStatementContext ctx) {
77 78
78 // Check for stack to be non empty. 79 // Check for stack to be non empty.
79 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 80 + checkStackIsNotEmpty(listener, MISSING_HOLDER, NAMESPACE_DATA, String.valueOf(ctx.string().getText()), ENTRY);
80 - ParsableDataType.NAMESPACE_DATA,
81 - String.valueOf(ctx.string().getText()), ListenerErrorLocation.ENTRY);
82 81
83 if (!validateUriValue(String.valueOf(ctx.string().getText()))) { 82 if (!validateUriValue(String.valueOf(ctx.string().getText()))) {
84 ParserException parserException = new ParserException("Invalid namespace URI"); 83 ParserException parserException = new ParserException("Invalid namespace URI");
...@@ -98,12 +97,8 @@ public final class NamespaceListener { ...@@ -98,12 +97,8 @@ public final class NamespaceListener {
98 break; 97 break;
99 } 98 }
100 default: 99 default:
101 - throw new ParserException( 100 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, NAMESPACE_DATA,
102 - ListenerErrorMessageConstruction 101 + String.valueOf(ctx.string().getText()), ENTRY));
103 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
104 - ParsableDataType.NAMESPACE_DATA,
105 - String.valueOf(ctx.string().getText()),
106 - ListenerErrorLocation.ENTRY));
107 } 102 }
108 } 103 }
109 104
...@@ -123,4 +118,4 @@ public final class NamespaceListener { ...@@ -123,4 +118,4 @@ public final class NamespaceListener {
123 } 118 }
124 return true; 119 return true;
125 } 120 }
126 -}
...\ No newline at end of file ...\ No newline at end of file
121 +}
......
...@@ -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.YangModule; 19 import org.onosproject.yangutils.datamodel.YangModule;
20 import org.onosproject.yangutils.datamodel.YangSubModule; 20 import org.onosproject.yangutils.datamodel.YangSubModule;
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.ORGANIZATION_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
...@@ -70,8 +72,9 @@ import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; ...@@ -70,8 +72,9 @@ import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
70 */ 72 */
71 73
72 /** 74 /**
73 - * Implements listener based call back function corresponding to the "organization" 75 + * Implements listener based call back function corresponding to the
74 - * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. 76 + * "organization" rule defined in ANTLR grammar file for corresponding ABNF rule
77 + * in RFC 6020.
75 */ 78 */
76 public final class OrganizationListener { 79 public final class OrganizationListener {
77 80
...@@ -82,9 +85,8 @@ public final class OrganizationListener { ...@@ -82,9 +85,8 @@ public final class OrganizationListener {
82 } 85 }
83 86
84 /** 87 /**
85 - * It is called when parser receives an input matching the grammar 88 + * It is called when parser receives an input matching the grammar rule
86 - * rule (organization), perform validations and update the data model 89 + * (organization), perform validations and update the data model tree.
87 - * tree.
88 * 90 *
89 * @param listener Listener's object. 91 * @param listener Listener's object.
90 * @param ctx context object of the grammar rule. 92 * @param ctx context object of the grammar rule.
...@@ -93,9 +95,8 @@ public final class OrganizationListener { ...@@ -93,9 +95,8 @@ public final class OrganizationListener {
93 GeneratedYangParser.OrganizationStatementContext ctx) { 95 GeneratedYangParser.OrganizationStatementContext ctx) {
94 96
95 // Check for stack to be non empty. 97 // Check for stack to be non empty.
96 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 98 + checkStackIsNotEmpty(listener, MISSING_HOLDER, ORGANIZATION_DATA, String.valueOf(ctx.string().getText()),
97 - ParsableDataType.ORGANIZATION_DATA, 99 + ENTRY);
98 - String.valueOf(ctx.string().getText()), ListenerErrorLocation.ENTRY);
99 100
100 // Obtain the node of the stack. 101 // Obtain the node of the stack.
101 Parsable tmpNode = listener.getParsedDataStack().peek(); 102 Parsable tmpNode = listener.getParsedDataStack().peek();
...@@ -111,12 +112,8 @@ public final class OrganizationListener { ...@@ -111,12 +112,8 @@ public final class OrganizationListener {
111 break; 112 break;
112 } 113 }
113 default: 114 default:
114 - throw new ParserException( 115 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, ORGANIZATION_DATA,
115 - ListenerErrorMessageConstruction 116 + String.valueOf(ctx.string().getText()), ENTRY));
116 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
117 - ParsableDataType.ORGANIZATION_DATA,
118 - String.valueOf(ctx.string().getText()),
119 - ListenerErrorLocation.ENTRY));
120 } 117 }
121 } 118 }
122 -}
...\ No newline at end of file ...\ No newline at end of file
119 +}
......
...@@ -20,14 +20,16 @@ import org.onosproject.yangutils.datamodel.YangBelongsTo; ...@@ -20,14 +20,16 @@ import org.onosproject.yangutils.datamodel.YangBelongsTo;
20 import org.onosproject.yangutils.datamodel.YangImport; 20 import org.onosproject.yangutils.datamodel.YangImport;
21 import org.onosproject.yangutils.datamodel.YangModule; 21 import org.onosproject.yangutils.datamodel.YangModule;
22 import org.onosproject.yangutils.parser.Parsable; 22 import org.onosproject.yangutils.parser.Parsable;
23 -import org.onosproject.yangutils.parser.ParsableDataType;
24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
25 import org.onosproject.yangutils.parser.exceptions.ParserException; 24 import org.onosproject.yangutils.parser.exceptions.ParserException;
26 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 25 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 26 +
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 27 +import static org.onosproject.yangutils.parser.ParsableDataType.PREFIX_DATA;
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
30 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
31 33
32 /* 34 /*
33 * Reference: RFC6020 and YANG ANTLR Grammar 35 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -65,9 +67,8 @@ public final class PrefixListener { ...@@ -65,9 +67,8 @@ public final class PrefixListener {
65 } 67 }
66 68
67 /** 69 /**
68 - * It is called when parser receives an input matching the grammar 70 + * It is called when parser receives an input matching the grammar rule
69 - * rule (prefix),perform validations and update the data model 71 + * (prefix),perform validations and update the data model tree.
70 - * tree.
71 * 72 *
72 * @param listener Listener's object. 73 * @param listener Listener's object.
73 * @param ctx context object of the grammar rule. 74 * @param ctx context object of the grammar rule.
...@@ -75,10 +76,7 @@ public final class PrefixListener { ...@@ -75,10 +76,7 @@ public final class PrefixListener {
75 public static void processPrefixEntry(TreeWalkListener listener, GeneratedYangParser.PrefixStatementContext ctx) { 76 public static void processPrefixEntry(TreeWalkListener listener, GeneratedYangParser.PrefixStatementContext ctx) {
76 77
77 // Check for stack to be non empty. 78 // Check for stack to be non empty.
78 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 79 + checkStackIsNotEmpty(listener, MISSING_HOLDER, PREFIX_DATA, String.valueOf(ctx.IDENTIFIER().getText()), ENTRY);
79 - ParsableDataType.PREFIX_DATA,
80 - String.valueOf(ctx.IDENTIFIER().getText()),
81 - ListenerErrorLocation.ENTRY);
82 80
83 // Obtain the node of the stack. 81 // Obtain the node of the stack.
84 Parsable tmpNode = listener.getParsedDataStack().peek(); 82 Parsable tmpNode = listener.getParsedDataStack().peek();
...@@ -99,13 +97,8 @@ public final class PrefixListener { ...@@ -99,13 +97,8 @@ public final class PrefixListener {
99 break; 97 break;
100 } 98 }
101 default: 99 default:
102 - throw new ParserException( 100 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, PREFIX_DATA,
103 - ListenerErrorMessageConstruction 101 + String.valueOf(ctx.IDENTIFIER().getText()), ENTRY));
104 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
105 - ParsableDataType.PREFIX_DATA, String
106 - .valueOf(ctx.IDENTIFIER()
107 - .getText()),
108 - ListenerErrorLocation.ENTRY));
109 } 102 }
110 } 103 }
111 -}
...\ No newline at end of file ...\ No newline at end of file
104 +}
......
...@@ -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.YangImport; 19 import org.onosproject.yangutils.datamodel.YangImport;
20 import org.onosproject.yangutils.datamodel.YangInclude; 20 import org.onosproject.yangutils.datamodel.YangInclude;
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.REVISION_DATE_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
...@@ -57,8 +59,9 @@ import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; ...@@ -57,8 +59,9 @@ import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
57 */ 59 */
58 60
59 /** 61 /**
60 - * Implements listener based call back function corresponding to the "revision date" 62 + * Implements listener based call back function corresponding to the
61 - * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. 63 + * "revision date" rule defined in ANTLR grammar file for corresponding ABNF
64 + * rule in RFC 6020.
62 */ 65 */
63 public final class RevisionDateListener { 66 public final class RevisionDateListener {
64 67
...@@ -69,9 +72,8 @@ public final class RevisionDateListener { ...@@ -69,9 +72,8 @@ public final class RevisionDateListener {
69 } 72 }
70 73
71 /** 74 /**
72 - * It is called when parser receives an input matching the grammar 75 + * It is called when parser receives an input matching the grammar rule
73 - * rule (revision date),perform validations and update the data model 76 + * (revision date),perform validations and update the data model tree.
74 - * tree.
75 * 77 *
76 * @param listener Listener's object. 78 * @param listener Listener's object.
77 * @param ctx context object of the grammar rule. 79 * @param ctx context object of the grammar rule.
...@@ -80,10 +82,8 @@ public final class RevisionDateListener { ...@@ -80,10 +82,8 @@ public final class RevisionDateListener {
80 GeneratedYangParser.RevisionDateStatementContext ctx) { 82 GeneratedYangParser.RevisionDateStatementContext ctx) {
81 83
82 // Check for stack to be non empty. 84 // Check for stack to be non empty.
83 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 85 + checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATE_DATA, String.valueOf(ctx.DATE_ARG().getText()),
84 - ParsableDataType.REVISION_DATE_DATA, 86 + ENTRY);
85 - String.valueOf(ctx.DATE_ARG().getText()),
86 - ListenerErrorLocation.ENTRY);
87 87
88 // Obtain the node of the stack. 88 // Obtain the node of the stack.
89 Parsable tmpNode = listener.getParsedDataStack().peek(); 89 Parsable tmpNode = listener.getParsedDataStack().peek();
...@@ -99,13 +99,9 @@ public final class RevisionDateListener { ...@@ -99,13 +99,9 @@ public final class RevisionDateListener {
99 break; 99 break;
100 } 100 }
101 default: 101 default:
102 - throw new ParserException( 102 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, REVISION_DATE_DATA,
103 - ListenerErrorMessageConstruction 103 + String.valueOf(ctx.DATE_ARG().getText()), ENTRY));
104 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
105 - ParsableDataType.REVISION_DATE_DATA,
106 - String.valueOf(ctx.DATE_ARG().getText()),
107 - ListenerErrorLocation.ENTRY));
108 } 104 }
109 } 105 }
110 // TODO Implement the DATE_ARG validation as per RFC 6020. 106 // TODO Implement the DATE_ARG validation as per RFC 6020.
111 -}
...\ No newline at end of file ...\ No newline at end of file
107 +}
......
...@@ -20,14 +20,16 @@ import org.onosproject.yangutils.datamodel.YangModule; ...@@ -20,14 +20,16 @@ import org.onosproject.yangutils.datamodel.YangModule;
20 import org.onosproject.yangutils.datamodel.YangRevision; 20 import org.onosproject.yangutils.datamodel.YangRevision;
21 import org.onosproject.yangutils.datamodel.YangSubModule; 21 import org.onosproject.yangutils.datamodel.YangSubModule;
22 import org.onosproject.yangutils.parser.Parsable; 22 import org.onosproject.yangutils.parser.Parsable;
23 -import org.onosproject.yangutils.parser.ParsableDataType;
24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
25 import org.onosproject.yangutils.parser.exceptions.ParserException; 24 import org.onosproject.yangutils.parser.exceptions.ParserException;
26 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 25 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 26 +
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 27 +import static org.onosproject.yangutils.parser.ParsableDataType.REVISION_DATA;
29 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
30 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
31 33
32 /* 34 /*
33 * Reference: RFC6020 and YANG ANTLR Grammar 35 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -69,16 +71,21 @@ public final class RevisionListener { ...@@ -69,16 +71,21 @@ public final class RevisionListener {
69 private RevisionListener() { 71 private RevisionListener() {
70 } 72 }
71 73
74 + /**
75 + * It is called when parser receives an input matching the grammar rule
76 + * (revision),perform validations and update the data model tree.
77 + *
78 + * @param listener Listener's object.
79 + * @param ctx context object of the grammar rule.
80 + */
72 public static void processRevisionEntry(TreeWalkListener listener, 81 public static void processRevisionEntry(TreeWalkListener listener,
73 GeneratedYangParser.RevisionStatementContext ctx) { 82 GeneratedYangParser.RevisionStatementContext ctx) {
74 83
75 // Check for stack to be non empty. 84 // Check for stack to be non empty.
76 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 85 + checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATA, String.valueOf(ctx.DATE_ARG().getText()), ENTRY);
77 - ParsableDataType.REVISION_DATA,
78 - String.valueOf(ctx.DATE_ARG().getText()),
79 - ListenerErrorLocation.ENTRY);
80 86
81 - // Validate for reverse chronological order of revision & for revision value. 87 + // Validate for reverse chronological order of revision & for revision
88 + // value.
82 if (!validateRevision(listener, ctx)) { 89 if (!validateRevision(listener, ctx)) {
83 return; 90 return;
84 // TODO to be implemented. 91 // TODO to be implemented.
...@@ -97,23 +104,19 @@ public final class RevisionListener { ...@@ -97,23 +104,19 @@ public final class RevisionListener {
97 * @param listener Listener's object. 104 * @param listener Listener's object.
98 * @param ctx context object of the grammar rule. 105 * @param ctx context object of the grammar rule.
99 */ 106 */
100 - public static void processRevisionExit(TreeWalkListener listener, 107 + public static void processRevisionExit(TreeWalkListener listener, GeneratedYangParser.RevisionStatementContext
101 - GeneratedYangParser.RevisionStatementContext ctx) { 108 + ctx) {
102 109
103 // Check for stack to be non empty. 110 // Check for stack to be non empty.
104 - ListenerValidation 111 + checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATA, String.valueOf(ctx.DATE_ARG().getText()), EXIT);
105 - .checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, ParsableDataType.REVISION_DATA,
106 - String.valueOf(ctx.DATE_ARG().getText()), ListenerErrorLocation.EXIT);
107 112
108 Parsable tmpRevisionNode = listener.getParsedDataStack().peek(); 113 Parsable tmpRevisionNode = listener.getParsedDataStack().peek();
109 if (tmpRevisionNode instanceof YangRevision) { 114 if (tmpRevisionNode instanceof YangRevision) {
110 listener.getParsedDataStack().pop(); 115 listener.getParsedDataStack().pop();
111 116
112 // Check for stack to be non empty. 117 // Check for stack to be non empty.
113 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 118 + checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATA, String.valueOf(ctx.DATE_ARG().getText()),
114 - ParsableDataType.REVISION_DATA, 119 + EXIT);
115 - String.valueOf(ctx.DATE_ARG().getText()),
116 - ListenerErrorLocation.EXIT);
117 120
118 Parsable tmpNode = listener.getParsedDataStack().peek(); 121 Parsable tmpNode = listener.getParsedDataStack().peek();
119 switch (tmpNode.getParsableDataType()) { 122 switch (tmpNode.getParsableDataType()) {
...@@ -128,22 +131,13 @@ public final class RevisionListener { ...@@ -128,22 +131,13 @@ public final class RevisionListener {
128 break; 131 break;
129 } 132 }
130 default: 133 default:
131 - throw new ParserException( 134 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, REVISION_DATA,
132 - ListenerErrorMessageConstruction 135 + String.valueOf(ctx.DATE_ARG().getText()),
133 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 136 + EXIT));
134 - ParsableDataType.REVISION_DATA,
135 - String.valueOf(ctx.DATE_ARG()
136 - .getText()),
137 - ListenerErrorLocation.EXIT));
138 } 137 }
139 } else { 138 } else {
140 - throw new ParserException( 139 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, REVISION_DATA,
141 - ListenerErrorMessageConstruction 140 + String.valueOf(ctx.DATE_ARG().getText()), EXIT));
142 - .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
143 - ParsableDataType.REVISION_DATA, String
144 - .valueOf(ctx.DATE_ARG()
145 - .getText()),
146 - ListenerErrorLocation.EXIT));
147 } 141 }
148 } 142 }
149 143
...@@ -159,4 +153,4 @@ public final class RevisionListener { ...@@ -159,4 +153,4 @@ public final class RevisionListener {
159 // TODO to be implemented 153 // TODO to be implemented
160 return true; 154 return true;
161 } 155 }
162 -}
...\ No newline at end of file ...\ No newline at end of file
156 +}
......
...@@ -17,14 +17,17 @@ ...@@ -17,14 +17,17 @@
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 import org.onosproject.yangutils.datamodel.YangSubModule; 19 import org.onosproject.yangutils.datamodel.YangSubModule;
20 -import org.onosproject.yangutils.parser.ParsableDataType;
21 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 20 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
22 import org.onosproject.yangutils.parser.exceptions.ParserException; 21 import org.onosproject.yangutils.parser.exceptions.ParserException;
23 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 22 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
24 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation; 23 +
25 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction; 24 +import static org.onosproject.yangutils.parser.ParsableDataType.SUB_MODULE_DATA;
26 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 25 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
27 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation; 26 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
28 31
29 /* 32 /*
30 * Reference: RFC6020 and YANG ANTLR Grammar 33 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -58,9 +61,8 @@ public final class SubModuleListener { ...@@ -58,9 +61,8 @@ public final class SubModuleListener {
58 } 61 }
59 62
60 /** 63 /**
61 - * It is called when parser receives an input matching the grammar 64 + * It is called when parser receives an input matching the grammar rule (sub
62 - * rule (sub module), perform validations and update the data model 65 + * module), perform validations and update the data model tree.
63 - * tree.
64 * 66 *
65 * @param listener Listener's object. 67 * @param listener Listener's object.
66 * @param ctx context object of the grammar rule. 68 * @param ctx context object of the grammar rule.
...@@ -69,9 +71,8 @@ public final class SubModuleListener { ...@@ -69,9 +71,8 @@ public final class SubModuleListener {
69 GeneratedYangParser.SubModuleStatementContext ctx) { 71 GeneratedYangParser.SubModuleStatementContext ctx) {
70 72
71 // Check if stack is empty. 73 // Check if stack is empty.
72 - ListenerValidation 74 + checkStackIsEmpty(listener, INVALID_HOLDER, SUB_MODULE_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
73 - .checkStackIsEmpty(listener, ListenerErrorType.INVALID_HOLDER, ParsableDataType.SUB_MODULE_DATA, 75 + ENTRY);
74 - String.valueOf(ctx.IDENTIFIER().getText()), ListenerErrorLocation.ENTRY);
75 76
76 YangSubModule yangSubModule = new YangSubModule(); 77 YangSubModule yangSubModule = new YangSubModule();
77 yangSubModule.setName(ctx.IDENTIFIER().getText()); 78 yangSubModule.setName(ctx.IDENTIFIER().getText());
...@@ -90,19 +91,12 @@ public final class SubModuleListener { ...@@ -90,19 +91,12 @@ public final class SubModuleListener {
90 GeneratedYangParser.SubModuleStatementContext ctx) { 91 GeneratedYangParser.SubModuleStatementContext ctx) {
91 92
92 // Check for stack to be non empty. 93 // Check for stack to be non empty.
93 - ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, 94 + checkStackIsNotEmpty(listener, MISSING_HOLDER, SUB_MODULE_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
94 - ParsableDataType.SUB_MODULE_DATA, 95 + EXIT);
95 - String.valueOf(ctx.IDENTIFIER().getText()),
96 - ListenerErrorLocation.EXIT);
97 96
98 if (!(listener.getParsedDataStack().peek() instanceof YangSubModule)) { 97 if (!(listener.getParsedDataStack().peek() instanceof YangSubModule)) {
99 - throw new ParserException( 98 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, SUB_MODULE_DATA,
100 - ListenerErrorMessageConstruction 99 + String.valueOf(ctx.IDENTIFIER().getText()), EXIT));
101 - .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
102 - ParsableDataType.SUB_MODULE_DATA,
103 - String.valueOf(ctx.IDENTIFIER()
104 - .getText()),
105 - ListenerErrorLocation.EXIT));
106 } 100 }
107 } 101 }
108 -}
...\ No newline at end of file ...\ No newline at end of file
102 +}
......
...@@ -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.YangModule; 19 import org.onosproject.yangutils.datamodel.YangModule;
20 import org.onosproject.yangutils.datamodel.YangSubModule; 20 import org.onosproject.yangutils.datamodel.YangSubModule;
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.VERSION_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
...@@ -73,9 +75,8 @@ public final class VersionListener { ...@@ -73,9 +75,8 @@ public final class VersionListener {
73 } 75 }
74 76
75 /** 77 /**
76 - * It is called when parser receives an input matching the grammar 78 + * It is called when parser receives an input matching the grammar rule
77 - * rule (version), perform validations and update the data model 79 + * (version), perform validations and update the data model tree.
78 - * tree.
79 * 80 *
80 * @param listener Listener's object. 81 * @param listener Listener's object.
81 * @param ctx context object of the grammar rule. 82 * @param ctx context object of the grammar rule.
...@@ -84,9 +85,7 @@ public final class VersionListener { ...@@ -84,9 +85,7 @@ public final class VersionListener {
84 GeneratedYangParser.YangVersionStatementContext ctx) { 85 GeneratedYangParser.YangVersionStatementContext ctx) {
85 86
86 // Check for stack to be non empty. 87 // Check for stack to be non empty.
87 - ListenerValidation 88 + checkStackIsNotEmpty(listener, MISSING_HOLDER, VERSION_DATA, String.valueOf(ctx.INTEGER().getText()), ENTRY);
88 - .checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, ParsableDataType.VERSION_DATA,
89 - String.valueOf(ctx.INTEGER().getText()), ListenerErrorLocation.ENTRY);
90 89
91 Integer version = Integer.valueOf(ctx.INTEGER().getText()); 90 Integer version = Integer.valueOf(ctx.INTEGER().getText());
92 if (!isVersionValid(version)) { 91 if (!isVersionValid(version)) {
...@@ -110,10 +109,8 @@ public final class VersionListener { ...@@ -110,10 +109,8 @@ public final class VersionListener {
110 break; 109 break;
111 } 110 }
112 default: 111 default:
113 - throw new ParserException(ListenerErrorMessageConstruction. 112 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, VERSION_DATA,
114 - constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 113 + String.valueOf(ctx.INTEGER().getText()), ENTRY));
115 - ParsableDataType.VERSION_DATA, String.valueOf(ctx.INTEGER().getText()),
116 - ListenerErrorLocation.ENTRY));
117 } 114 }
118 } 115 }
119 116
...@@ -126,4 +123,4 @@ public final class VersionListener { ...@@ -126,4 +123,4 @@ public final class VersionListener {
126 private static boolean isVersionValid(Integer version) { 123 private static boolean isVersionValid(Integer version) {
127 return version == 1; 124 return version == 1;
128 } 125 }
129 -}
...\ No newline at end of file ...\ No newline at end of file
126 +}
......
...@@ -18,6 +18,10 @@ package org.onosproject.yangutils.parser.impl.parserutils; ...@@ -18,6 +18,10 @@ package org.onosproject.yangutils.parser.impl.parserutils;
18 18
19 import org.onosproject.yangutils.parser.ParsableDataType; 19 import org.onosproject.yangutils.parser.ParsableDataType;
20 20
21 +import static org.onosproject.yangutils.parser.ParsableDataType.getParsableDataType;
22 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.getErrorLocationMessage;
23 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.getErrorType;
24 +
21 /** 25 /**
22 * It's a utility to help construct detailed error message. 26 * It's a utility to help construct detailed error message.
23 */ 27 */
...@@ -30,13 +34,15 @@ public final class ListenerErrorMessageConstruction { ...@@ -30,13 +34,15 @@ public final class ListenerErrorMessageConstruction {
30 } 34 }
31 35
32 /** 36 /**
33 - * Constructs message for error with extended information and returns the same. 37 + * Constructs message for error with extended information and returns the
38 + * same.
34 * 39 *
35 - * @param errorType error type needs to be set in error message. 40 + * @param errorType error type needs to be set in error message.
36 - * @param parsableDataType type of parsable data in which error occurred. 41 + * @param parsableDataType type of parsable data in which error occurred.
37 - * @param parsableDataTypeName identifier/string of parsable data type in which error occurred. 42 + * @param parsableDataTypeName identifier/string of parsable data type in
38 - * @param errorLocation location where error occurred. 43 + * which error occurred.
39 - * @param extendedErrorInformation extended error information. 44 + * @param errorLocation location where error occurred.
45 + * @param extendedErrorInformation extended error information.
40 * @return constructed error message. 46 * @return constructed error message.
41 */ 47 */
42 public static String constructExtendedListenerErrorMessage(ListenerErrorType errorType, 48 public static String constructExtendedListenerErrorMessage(ListenerErrorType errorType,
...@@ -46,16 +52,21 @@ public final class ListenerErrorMessageConstruction { ...@@ -46,16 +52,21 @@ public final class ListenerErrorMessageConstruction {
46 String extendedErrorInformation) { 52 String extendedErrorInformation) {
47 String newErrorMessage; 53 String newErrorMessage;
48 newErrorMessage = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName, 54 newErrorMessage = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName,
49 - errorLocation) + "\n" + "Error Information: " + extendedErrorInformation; 55 + errorLocation)
56 + + "\n"
57 + + "Error Information: "
58 + + extendedErrorInformation;
50 return newErrorMessage; 59 return newErrorMessage;
51 } 60 }
52 61
53 /** 62 /**
54 - * Constructs message for error during listener based tree walk and returns the same. 63 + * Constructs message for error during listener based tree walk and returns
64 + * the same.
55 * 65 *
56 * @param errorType error type needs to be set in error message. 66 * @param errorType error type needs to be set in error message.
57 * @param parsableDataType type of parsable data in which error occurred. 67 * @param parsableDataType type of parsable data in which error occurred.
58 - * @param parsableDataTypeName identifier/string of parsable data type in which error occurred. 68 + * @param parsableDataTypeName identifier/string of parsable data type in
69 + * which error occurred.
59 * @param errorLocation location where error occurred. 70 * @param errorLocation location where error occurred.
60 * @return constructed error message. 71 * @return constructed error message.
61 */ 72 */
...@@ -66,9 +77,8 @@ public final class ListenerErrorMessageConstruction { ...@@ -66,9 +77,8 @@ public final class ListenerErrorMessageConstruction {
66 77
67 String errorMessage; 78 String errorMessage;
68 79
69 - errorMessage = "Internal parser error detected: " + ListenerErrorType.getErrorType(errorType) + " " 80 + errorMessage = "Internal parser error detected: " + getErrorType(errorType) + " "
70 - + ParsableDataType.getParsableDataType(parsableDataType); 81 + + getParsableDataType(parsableDataType);
71 -
72 82
73 if (!parsableDataTypeName.isEmpty()) { 83 if (!parsableDataTypeName.isEmpty()) {
74 errorMessage = errorMessage + " \"" + parsableDataTypeName + "\" "; 84 errorMessage = errorMessage + " \"" + parsableDataTypeName + "\" ";
...@@ -76,7 +86,7 @@ public final class ListenerErrorMessageConstruction { ...@@ -76,7 +86,7 @@ public final class ListenerErrorMessageConstruction {
76 errorMessage = errorMessage + " "; 86 errorMessage = errorMessage + " ";
77 87
78 } 88 }
79 - errorMessage = errorMessage + ListenerErrorLocation.getErrorLocationMessage(errorLocation) + " processing."; 89 + errorMessage = errorMessage + getErrorLocationMessage(errorLocation) + " processing.";
80 return errorMessage; 90 return errorMessage;
81 } 91 }
82 -}
...\ No newline at end of file ...\ No newline at end of file
92 +}
......
...@@ -19,6 +19,7 @@ package org.onosproject.yangutils.parser.impl.parserutils; ...@@ -19,6 +19,7 @@ package org.onosproject.yangutils.parser.impl.parserutils;
19 import org.onosproject.yangutils.parser.ParsableDataType; 19 import org.onosproject.yangutils.parser.ParsableDataType;
20 import org.onosproject.yangutils.parser.exceptions.ParserException; 20 import org.onosproject.yangutils.parser.exceptions.ParserException;
21 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 21 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
22 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
22 23
23 /** 24 /**
24 * It's a utility to carry out listener validation. 25 * It's a utility to carry out listener validation.
...@@ -37,19 +38,21 @@ public final class ListenerValidation { ...@@ -37,19 +38,21 @@ public final class ListenerValidation {
37 * @param listener Listener's object. 38 * @param listener Listener's object.
38 * @param errorType error type needs to be set in error message. 39 * @param errorType error type needs to be set in error message.
39 * @param parsableDataType type of parsable data in which error occurred. 40 * @param parsableDataType type of parsable data in which error occurred.
40 - * @param parsableDataTypeName name of parsable data type in which error occurred. 41 + * @param parsableDataTypeName name of parsable data type in which error
42 + * occurred.
41 * @param errorLocation location where error occurred. 43 * @param errorLocation location where error occurred.
42 */ 44 */
43 public static void checkStackIsNotEmpty(TreeWalkListener listener, ListenerErrorType errorType, 45 public static void checkStackIsNotEmpty(TreeWalkListener listener, ListenerErrorType errorType,
44 - ParsableDataType parsableDataType, String parsableDataTypeName, 46 + ParsableDataType parsableDataType, String parsableDataTypeName,
45 - ListenerErrorLocation errorLocation) { 47 + ListenerErrorLocation errorLocation) {
46 if (listener.getParsedDataStack().empty()) { 48 if (listener.getParsedDataStack().empty()) {
47 /* 49 /*
48 - * If stack is empty it indicates error condition, value of parsableDataTypeName will be null in case there 50 + * If stack is empty it indicates error condition, value of
49 - * is no name attached to parsable data type. 51 + * parsableDataTypeName will be null in case there is no name
52 + * attached to parsable data type.
50 */ 53 */
51 - String message = ListenerErrorMessageConstruction.constructListenerErrorMessage(errorType, parsableDataType, 54 + String message = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName,
52 - parsableDataTypeName, errorLocation); 55 + errorLocation);
53 throw new ParserException(message); 56 throw new ParserException(message);
54 } 57 }
55 } 58 }
...@@ -60,22 +63,24 @@ public final class ListenerValidation { ...@@ -60,22 +63,24 @@ public final class ListenerValidation {
60 * @param listener Listener's object. 63 * @param listener Listener's object.
61 * @param errorType error type needs to be set in error message. 64 * @param errorType error type needs to be set in error message.
62 * @param parsableDataType type of parsable data in which error occurred. 65 * @param parsableDataType type of parsable data in which error occurred.
63 - * @param parsableDataTypeName name of parsable data type in which error occurred. 66 + * @param parsableDataTypeName name of parsable data type in which error
67 + * occurred.
64 * @param errorLocation location where error occurred. 68 * @param errorLocation location where error occurred.
65 */ 69 */
66 70
67 public static void checkStackIsEmpty(TreeWalkListener listener, ListenerErrorType errorType, 71 public static void checkStackIsEmpty(TreeWalkListener listener, ListenerErrorType errorType,
68 - ParsableDataType parsableDataType, String parsableDataTypeName, 72 + ParsableDataType parsableDataType, String parsableDataTypeName,
69 - ListenerErrorLocation errorLocation) { 73 + ListenerErrorLocation errorLocation) {
70 74
71 if (!listener.getParsedDataStack().empty()) { 75 if (!listener.getParsedDataStack().empty()) {
72 /* 76 /*
73 - * If stack is empty it indicates error condition, value of parsableDataTypeName will be null in case there 77 + * If stack is empty it indicates error condition, value of
74 - * is no name attached to parsable data type. 78 + * parsableDataTypeName will be null in case there is no name
79 + * attached to parsable data type.
75 */ 80 */
76 - String message = ListenerErrorMessageConstruction.constructListenerErrorMessage(errorType, parsableDataType, 81 + String message = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName,
77 - parsableDataTypeName, errorLocation); 82 + errorLocation);
78 throw new ParserException(message); 83 throw new ParserException(message);
79 } 84 }
80 } 85 }
81 -}
...\ No newline at end of file ...\ No newline at end of file
86 +}
......
...@@ -17,13 +17,14 @@ ...@@ -17,13 +17,14 @@
17 package org.onosproject.yangutils.parser.parseutils; 17 package org.onosproject.yangutils.parser.parseutils;
18 18
19 import org.junit.Test; 19 import org.junit.Test;
20 -import org.onosproject.yangutils.parser.ParsableDataType;
21 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
22 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
23 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
24 20
25 import static org.hamcrest.core.Is.is; 21 import static org.hamcrest.core.Is.is;
26 import static org.junit.Assert.assertThat; 22 import static org.junit.Assert.assertThat;
23 +import static org.onosproject.yangutils.parser.ParsableDataType.CONTACT_DATA;
24 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
25 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
26 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
27 28
28 /** 29 /**
29 * Test case for testing listener error message construction util. 30 * Test case for testing listener error message construction util.
...@@ -37,9 +38,7 @@ public class ListenerErrorMessageConstructionTest { ...@@ -37,9 +38,7 @@ public class ListenerErrorMessageConstructionTest {
37 public void checkErrorMsgConstructionWithName() { 38 public void checkErrorMsgConstructionWithName() {
38 39
39 // Create an test error message 40 // Create an test error message
40 - String testErrorMessage = ListenerErrorMessageConstruction 41 + String testErrorMessage = constructListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA, "Test Instance", ENTRY);
41 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, ParsableDataType.CONTACT_DATA,
42 - "Test Instance", ListenerErrorLocation.ENTRY);
43 42
44 // Check message. 43 // Check message.
45 assertThat(testErrorMessage, is("Internal parser error detected: Invalid holder for contact " 44 assertThat(testErrorMessage, is("Internal parser error detected: Invalid holder for contact "
...@@ -53,9 +52,7 @@ public class ListenerErrorMessageConstructionTest { ...@@ -53,9 +52,7 @@ public class ListenerErrorMessageConstructionTest {
53 public void checkErrorMsgConstructionWithoutName() { 52 public void checkErrorMsgConstructionWithoutName() {
54 53
55 // Create an test error message 54 // Create an test error message
56 - String testErrorMessage = ListenerErrorMessageConstruction 55 + String testErrorMessage = constructListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA, "Test Instance", ENTRY);
57 - .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, ParsableDataType.CONTACT_DATA,
58 - "Test Instance", ListenerErrorLocation.ENTRY);
59 56
60 // Check message. 57 // Check message.
61 assertThat(testErrorMessage, 58 assertThat(testErrorMessage,
...@@ -64,16 +61,16 @@ public class ListenerErrorMessageConstructionTest { ...@@ -64,16 +61,16 @@ public class ListenerErrorMessageConstructionTest {
64 } 61 }
65 62
66 /** 63 /**
67 - * Checks for extended error message construction with parsable data type name. 64 + * Checks for extended error message construction with parsable data type
65 + * name.
68 */ 66 */
69 @Test 67 @Test
70 public void checkExtendedErrorMsgConstructionWithName() { 68 public void checkExtendedErrorMsgConstructionWithName() {
71 69
72 // Create an test error message 70 // Create an test error message
73 - String testErrorMessage = ListenerErrorMessageConstruction 71 + String testErrorMessage = constructExtendedListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA,
74 - .constructExtendedListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 72 + "Test Instance", ENTRY,
75 - ParsableDataType.CONTACT_DATA, "Test Instance", 73 + "Extended Information");
76 - ListenerErrorLocation.ENTRY, "Extended Information");
77 74
78 // Check message. 75 // Check message.
79 assertThat(testErrorMessage, 76 assertThat(testErrorMessage,
...@@ -82,19 +79,18 @@ public class ListenerErrorMessageConstructionTest { ...@@ -82,19 +79,18 @@ public class ListenerErrorMessageConstructionTest {
82 } 79 }
83 80
84 /** 81 /**
85 - * Checks for extended error message construction without parsable data type name. 82 + * Checks for extended error message construction without parsable data type
83 + * name.
86 */ 84 */
87 @Test 85 @Test
88 public void checkExtendedErrorMsgConstructionWithoutName() { 86 public void checkExtendedErrorMsgConstructionWithoutName() {
89 87
90 // Create an test error message 88 // Create an test error message
91 - String testErrorMessage = ListenerErrorMessageConstruction 89 + String testErrorMessage = constructExtendedListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA, "", ENTRY,
92 - .constructExtendedListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, 90 + "Extended Information");
93 - ParsableDataType.CONTACT_DATA, "",
94 - ListenerErrorLocation.ENTRY, "Extended Information");
95 91
96 // Check message. 92 // Check message.
97 assertThat(testErrorMessage, is("Internal parser error detected: Invalid holder for contact" 93 assertThat(testErrorMessage, is("Internal parser error detected: Invalid holder for contact"
98 + " before processing.\n" + "Error Information: Extended Information")); 94 + " before processing.\n" + "Error Information: Extended Information"));
99 } 95 }
100 -}
...\ No newline at end of file ...\ No newline at end of file
96 +}
......
...@@ -20,13 +20,15 @@ import org.junit.Rule; ...@@ -20,13 +20,15 @@ import org.junit.Rule;
20 import org.junit.Test; 20 import org.junit.Test;
21 import org.junit.rules.ExpectedException; 21 import org.junit.rules.ExpectedException;
22 import org.onosproject.yangutils.datamodel.YangRevision; 22 import org.onosproject.yangutils.datamodel.YangRevision;
23 -import org.onosproject.yangutils.parser.ParsableDataType;
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.YANGBASE_DATA;
28 -import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType; 27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
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.MISSING_HOLDER;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
31 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
30 32
31 /** 33 /**
32 * Test case for testing listener validation util. 34 * Test case for testing listener validation util.
...@@ -43,9 +45,7 @@ public class ListenerValidationTest { ...@@ -43,9 +45,7 @@ public class ListenerValidationTest {
43 @Test 45 @Test
44 public void validateStackIsNotEmptyForEmptyStack() { 46 public void validateStackIsNotEmptyForEmptyStack() {
45 47
46 - String expectedError = ListenerErrorMessageConstruction 48 + String expectedError = constructListenerErrorMessage(MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
47 - .constructListenerErrorMessage(ListenerErrorType.MISSING_HOLDER, ParsableDataType.YANGBASE_DATA, "",
48 - ListenerErrorLocation.EXIT);
49 49
50 // Get the exception occurred during parsing. 50 // Get the exception occurred during parsing.
51 thrown.expect(ParserException.class); 51 thrown.expect(ParserException.class);
...@@ -54,13 +54,12 @@ public class ListenerValidationTest { ...@@ -54,13 +54,12 @@ public class ListenerValidationTest {
54 // Create test walker and assign test error to it. 54 // Create test walker and assign test error to it.
55 TreeWalkListener testWalker = new TreeWalkListener(); 55 TreeWalkListener testWalker = new TreeWalkListener();
56 56
57 - ListenerValidation.checkStackIsNotEmpty(testWalker, ListenerErrorType.MISSING_HOLDER, 57 + checkStackIsNotEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
58 - ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
59 } 58 }
60 59
61 /** 60 /**
62 - * Checks if there is no exception in case parsable stack is not empty while validating 61 + * Checks if there is no exception in case parsable stack is not empty while
63 - * for not empty scenario. 62 + * validating for not empty scenario.
64 */ 63 */
65 @Test 64 @Test
66 public void validateStackIsNotEmptyForNonEmptyStack() { 65 public void validateStackIsNotEmptyForNonEmptyStack() {
...@@ -72,8 +71,7 @@ public class ListenerValidationTest { ...@@ -72,8 +71,7 @@ public class ListenerValidationTest {
72 YangRevision tmpNode = new YangRevision(); 71 YangRevision tmpNode = new YangRevision();
73 testWalker.getParsedDataStack().push(tmpNode); 72 testWalker.getParsedDataStack().push(tmpNode);
74 73
75 - ListenerValidation.checkStackIsNotEmpty(testWalker, ListenerErrorType.MISSING_HOLDER, 74 + checkStackIsNotEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
76 - ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
77 } 75 }
78 76
79 /** 77 /**
...@@ -83,9 +81,7 @@ public class ListenerValidationTest { ...@@ -83,9 +81,7 @@ public class ListenerValidationTest {
83 @Test 81 @Test
84 public void validateStackIsEmptyForNonEmptyStack() { 82 public void validateStackIsEmptyForNonEmptyStack() {
85 83
86 - String expectedError = ListenerErrorMessageConstruction 84 + String expectedError = constructListenerErrorMessage(MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
87 - .constructListenerErrorMessage(ListenerErrorType.MISSING_HOLDER, ParsableDataType.YANGBASE_DATA, "",
88 - ListenerErrorLocation.EXIT);
89 85
90 // Get the exception occurred during parsing. 86 // Get the exception occurred during parsing.
91 thrown.expect(ParserException.class); 87 thrown.expect(ParserException.class);
...@@ -98,13 +94,12 @@ public class ListenerValidationTest { ...@@ -98,13 +94,12 @@ public class ListenerValidationTest {
98 YangRevision tmpNode = new YangRevision(); 94 YangRevision tmpNode = new YangRevision();
99 testWalker.getParsedDataStack().push(tmpNode); 95 testWalker.getParsedDataStack().push(tmpNode);
100 96
101 - ListenerValidation.checkStackIsEmpty(testWalker, ListenerErrorType.MISSING_HOLDER, 97 + checkStackIsEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
102 - ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
103 } 98 }
104 99
105 /** 100 /**
106 - * Checks if there is no exception in case parsable stack is empty while validating 101 + * Checks if there is no exception in case parsable stack is empty while
107 - * for empty scenario. 102 + * validating for empty scenario.
108 */ 103 */
109 @Test 104 @Test
110 public void validateStackIsEmptyForEmptyStack() { 105 public void validateStackIsEmptyForEmptyStack() {
...@@ -112,7 +107,6 @@ public class ListenerValidationTest { ...@@ -112,7 +107,6 @@ public class ListenerValidationTest {
112 // Create test walker and assign test error to it. 107 // Create test walker and assign test error to it.
113 TreeWalkListener testWalker = new TreeWalkListener(); 108 TreeWalkListener testWalker = new TreeWalkListener();
114 109
115 - ListenerValidation.checkStackIsEmpty(testWalker, ListenerErrorType.MISSING_HOLDER, 110 + checkStackIsEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
116 - ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
117 } 111 }
118 -}
...\ No newline at end of file ...\ No newline at end of file
112 +}
......