Vidyashree Rama
Committed by Gerrit Code Review

Change to static import for lesser indentation.

Change-Id: I5350c65496023a96c88cefe9dd5ed64a72c5f30c
......@@ -21,14 +21,16 @@ import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.CONFIG_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -69,8 +71,7 @@ public final class ConfigListener {
boolean isConfig = false;
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.CONFIG_DATA, "", ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, CONFIG_DATA, "", ENTRY);
if (ctx.TRUE_KEYWORD() != null) {
isConfig = true;
......@@ -97,10 +98,7 @@ public final class ConfigListener {
case CHOICE_DATA: // TODO
break;
default:
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.CONFIG_DATA,
"", ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, CONFIG_DATA, "", ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -15,20 +15,30 @@
*/
package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.CONTAINER_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -85,15 +95,11 @@ public final class ContainerListener {
GeneratedYangParser.ContainerStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.CONTAINER_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY);
boolean result = validateSubStatementsCardinality(ctx);
if (!result) {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_CARDINALITY,
yangConstruct, "", ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
}
YangContainer container = new YangContainer();
......@@ -101,25 +107,19 @@ public final class ContainerListener {
Parsable curData = listener.getParsedDataStack().peek();
if (curData instanceof YangNode) {
if ((curData instanceof YangModule) || (curData instanceof YangContainer)
|| (curData instanceof YangList)) {
YangNode curNode = (YangNode) curData;
try {
curNode.addChild(container);
} catch (DataModelException e) {
throw new ParserException(ListenerErrorMessageConstruction
.constructExtendedListenerErrorMessage(ListenerErrorType.UNHANDLED_PARSED_DATA,
ParsableDataType.CONTAINER_DATA,
String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.ENTRY,
e.getMessage()));
throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY, e.getMessage()));
}
listener.getParsedDataStack().push(container);
} else {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.CONTAINER_DATA,
String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, CONTAINER_DATA,
ctx.IDENTIFIER().getText(), ENTRY));
}
}
......@@ -134,18 +134,13 @@ public final class ContainerListener {
GeneratedYangParser.ContainerStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.CONTAINER_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.EXIT);
checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), EXIT);
if (listener.getParsedDataStack().peek() instanceof YangContainer) {
listener.getParsedDataStack().pop();
} else {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.CONTAINER_DATA,
String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.EXIT));
throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, CONTAINER_DATA,
ctx.IDENTIFIER().getText(), EXIT));
}
}
......@@ -155,7 +150,7 @@ public final class ContainerListener {
* @param ctx context object of the grammar rule.
* @return true/false validation success or failure.
*/
public static boolean validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) {
private static boolean validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) {
if ((!ctx.presenceStatement().isEmpty())
&& (ctx.presenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
......
......@@ -18,14 +18,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangDesc;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -61,20 +63,15 @@ public final class DescriptionListener {
GeneratedYangParser.DescriptionStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.DESCRIPTION_DATA, String.valueOf(ctx.string().getText()),
ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, DESCRIPTION_DATA, ctx.string().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
if (tmpData instanceof YangDesc) {
YangDesc description = (YangDesc) tmpData;
description.setDescription(ctx.string().getText());
} else {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.DESCRIPTION_DATA,
String.valueOf(ctx.string().getText()),
ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, DESCRIPTION_DATA,
ctx.string().getText(), ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -24,10 +24,16 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.LEAF_LIST_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -82,15 +88,11 @@ public final class LeafListListener {
GeneratedYangParser.LeafListStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.LEAF_LIST_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY);
boolean result = validateSubStatementsCardinality(ctx);
if (!result) {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_CARDINALITY,
yangConstruct, "", ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
}
YangLeafList leafList = new YangLeafList();
......@@ -103,11 +105,8 @@ public final class LeafListListener {
leaves = (YangLeavesHolder) tmpData;
leaves.addLeafList(leafList);
} else {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.LEAF_LIST_DATA,
String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_LIST_DATA,
ctx.IDENTIFIER().getText(), ENTRY));
}
listener.getParsedDataStack().push(leafList);
}
......@@ -123,18 +122,13 @@ public final class LeafListListener {
GeneratedYangParser.LeafListStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.LEAF_LIST_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.EXIT);
checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), EXIT);
if (listener.getParsedDataStack().peek() instanceof YangLeafList) {
listener.getParsedDataStack().pop();
} else {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.LEAF_LIST_DATA,
String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.EXIT));
throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_LIST_DATA,
ctx.IDENTIFIER().getText(), EXIT));
}
}
......@@ -144,7 +138,7 @@ public final class LeafListListener {
* @param ctx context object of the grammar rule.
* @return true/false validation success or failure.
*/
public static boolean validateSubStatementsCardinality(GeneratedYangParser
private static boolean validateSubStatementsCardinality(GeneratedYangParser
.LeafListStatementContext ctx) {
if (ctx.typeStatement().isEmpty()
......
......@@ -28,10 +28,16 @@ import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.datamodel.YangLeavesHolder;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.LEAF_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -85,15 +91,11 @@ public final class LeafListener {
GeneratedYangParser.LeafStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.LEAF_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), ENTRY);
boolean result = validateSubStatementsCardinality(ctx);
if (!result) {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_CARDINALITY,
yangConstruct, "", ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
}
YangLeaf leaf = new YangLeaf();
......@@ -106,11 +108,8 @@ public final class LeafListener {
leaves = (YangLeavesHolder) tmpData;
leaves.addLeaf(leaf);
} else {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.LEAF_DATA,
String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_DATA,
ctx.IDENTIFIER().getText(), ENTRY));
}
listener.getParsedDataStack().push(leaf);
......@@ -127,18 +126,13 @@ public final class LeafListener {
GeneratedYangParser.LeafStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.LEAF_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.EXIT);
checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), EXIT);
if (listener.getParsedDataStack().peek() instanceof YangLeaf) {
listener.getParsedDataStack().pop();
} else {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.LEAF_DATA,
String.valueOf(ctx.IDENTIFIER().getText()),
ListenerErrorLocation.EXIT));
throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_DATA,
ctx.IDENTIFIER().getText(), EXIT));
}
}
......@@ -148,7 +142,7 @@ public final class LeafListener {
* @param ctx context object of the grammar rule.
* @return true/false validation success or failure.
*/
public static boolean validateSubStatementsCardinality(GeneratedYangParser
private static boolean validateSubStatementsCardinality(GeneratedYangParser
.LeafStatementContext ctx) {
if (ctx.typeStatement().isEmpty()
......
......@@ -18,14 +18,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.MANDATORY_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -67,8 +69,7 @@ public final class MandatoryListener {
GeneratedYangParser.MandatoryStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.MANDATORY_DATA, "", ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, MANDATORY_DATA, "", ENTRY);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
......@@ -83,9 +84,7 @@ public final class MandatoryListener {
case CHOICE_DATA: // TODO
break;
default:
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.MANDATORY_DATA, "", ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, MANDATORY_DATA, "", ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.MAX_ELEMENT_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -66,8 +68,7 @@ public final class MaxElementsListener {
int maxElementsValue;
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.MAX_ELEMENT_DATA, "", ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, MAX_ELEMENT_DATA, "", ENTRY);
if (ctx.maxValueArgument().UNBOUNDED_KEYWORD() != null) {
maxElementsValue = Integer.MAX_VALUE;
......@@ -86,10 +87,7 @@ public final class MaxElementsListener {
yangList.setMaxElelements(maxElementsValue);
break;
default:
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.MAX_ELEMENT_DATA,
"", ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, MAX_ELEMENT_DATA, "", ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.MIN_ELEMENT_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -66,9 +68,7 @@ public final class MinElementsListener {
GeneratedYangParser.MinElementsStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.MIN_ELEMENT_DATA, String.valueOf(ctx.INTEGER().getText()),
ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, MIN_ELEMENT_DATA, ctx.INTEGER().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
switch (tmpData.getParsableDataType()) {
......@@ -81,11 +81,8 @@ public final class MinElementsListener {
yangList.setMinElements(Integer.parseInt(ctx.INTEGER().getText()));
break;
default:
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.MIN_ELEMENT_DATA,
String.valueOf(ctx.INTEGER().getText()),
ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, MIN_ELEMENT_DATA,
ctx.INTEGER().getText(), ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -18,14 +18,17 @@ package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.PRESENCE_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.CONTAINER_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -61,20 +64,15 @@ public final class PresenceListener {
GeneratedYangParser.PresenceStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.PRESENCE_DATA, String.valueOf(ctx.string().getText()),
ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, PRESENCE_DATA, ctx.string().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
if (tmpData.getParsableDataType() == ParsableDataType.CONTAINER_DATA) {
if (tmpData.getParsableDataType() == CONTAINER_DATA) {
YangContainer container = (YangContainer) tmpData;
container.setPresence(ctx.string().getText());
} else {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.PRESENCE_DATA,
String.valueOf(ctx.string().getText()),
ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, PRESENCE_DATA,
ctx.string().getText(), ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -18,14 +18,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangReference;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.REFERENCE_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -61,20 +63,15 @@ public final class ReferenceListener {
GeneratedYangParser.ReferenceStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.REFERENCE_DATA, String.valueOf(ctx.string().getText()),
ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, REFERENCE_DATA, ctx.string().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
if (tmpData instanceof YangReference) {
YangReference reference = (YangReference) tmpData;
reference.setReference(ctx.string().getText());
} else {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.REFERENCE_DATA,
String.valueOf(ctx.string().getText()),
ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, REFERENCE_DATA,
ctx.string().getText(), ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangStatus;
import org.onosproject.yangutils.datamodel.YangStatusType;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.STATUS_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -68,15 +70,14 @@ public final class StatusListener {
YangStatusType status;
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.STATUS_DATA, "", ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, STATUS_DATA, "", ENTRY);
if (ctx.CURRENT_KEYWORD() != null) {
status = YangStatusType.CURRENT.CURRENT;
status = YangStatusType.CURRENT;
} else if (ctx.DEPRECATED_KEYWORD() != null) {
status = YangStatusType.DEPRECATED;
} else {
status = YangStatusType.OBSOLETE.OBSOLETE;
status = YangStatusType.OBSOLETE;
}
Parsable tmpData = listener.getParsedDataStack().peek();
......@@ -84,9 +85,7 @@ public final class StatusListener {
YangStatus yangStatus = (YangStatus) tmpData;
yangStatus.setStatus(status);
} else {
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.STATUS_DATA, "", ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, STATUS_DATA, "", ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -21,14 +21,17 @@ import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -68,9 +71,7 @@ public final class TypeListener {
GeneratedYangParser.TypeStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.TYPE_DATA, String.valueOf(ctx.string().getText()),
ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPE_DATA, ctx.string().getText(), ENTRY);
YangType type = new YangType();
YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText());
......@@ -90,11 +91,8 @@ public final class TypeListener {
case TYPEDEF_DATA: //TODO
break;
default:
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.TYPE_DATA,
String.valueOf(ctx.string().getText()),
ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
ctx.string().getText(), ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -19,14 +19,16 @@ package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.UNITS_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -62,9 +64,7 @@ public final class UnitsListener {
GeneratedYangParser.UnitsStatementContext ctx) {
// Check for stack to be non empty.
ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
ParsableDataType.UNITS_DATA, String.valueOf(ctx.string().getText()),
ListenerErrorLocation.ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, UNITS_DATA, ctx.string().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
switch (tmpData.getParsableDataType()) {
......@@ -80,11 +80,8 @@ public final class UnitsListener {
// TODO
break;
default:
throw new ParserException(ListenerErrorMessageConstruction
.constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
ParsableDataType.UNITS_DATA,
String.valueOf(ctx.string().getText()),
ListenerErrorLocation.ENTRY));
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, UNITS_DATA,
ctx.string().getText(), ENTRY));
}
}
}
\ No newline at end of file
......