YANG construct collision detection framework added
Change-Id: I1458f9e3192641f3f90c444798c31a64536ffa5d
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/CollisionDetector.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/CollisionDetector.java
new file mode 100644
index 0000000..0913d03
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/CollisionDetector.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.datamodel;
+
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.utils.YangConstructType;
+
+/**
+ * Abstraction of YANG collision function. Abstracted to unify the collision
+ * detection functionality.
+ */
+public interface CollisionDetector {
+ /**
+ * Checks for the colliding child.
+ *
+ * @param identifierName name of identifier for which collision to be
+ * checked
+ * @param dataType type of the YANG construct for which collision to be
+ * checked
+ * @throws DataModelException if there is any collision in YANG rules in
+ * parsed data, corresponding exception should be thrown
+ */
+ void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException;
+
+ /**
+ * Check for the self collision.
+ *
+ * @param identifierName name of identifier for which collision to be
+ * checked
+ * @param dataType type of the YANG construct for which collision to be
+ * checked
+ * @throws DataModelException if there is any collision in YANG rules in
+ * parsed data, corresponding exception should be thrown
+ */
+ void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException;
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
index 378eaf4..30d4978 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
@@ -20,7 +20,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.translator.CachedFileHandle;
/*-
@@ -85,7 +85,7 @@
private String targetNode;
/**
- * description of augment.
+ * Description of augment.
*/
private String description;
@@ -100,7 +100,7 @@
private List<YangLeafList> listOfLeafList;
/**
- * reference.
+ * Reference of the YANG augment.
*/
private String reference;
@@ -110,7 +110,7 @@
private YangStatusType status;
/**
- * package of the generated java code.
+ * Package of the generated java code.
*/
private String pkg;
@@ -124,7 +124,7 @@
/**
* Get the augmented node.
*
- * @return the augmented node.
+ * @return the augmented node
*/
public String getTargetNode() {
return targetNode;
@@ -133,7 +133,7 @@
/**
* Set the augmented node.
*
- * @param targetNode the augmented node.
+ * @param targetNode the augmented node
*/
public void setTargetNode(String targetNode) {
this.targetNode = targetNode;
@@ -142,7 +142,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -152,7 +152,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -162,7 +162,7 @@
/**
* Get the list of leaves.
*
- * @return the list of leaves.
+ * @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
@@ -172,7 +172,7 @@
/**
* Set the list of leaves.
*
- * @param leafsList the list of leaf to set.
+ * @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
@@ -181,7 +181,7 @@
/**
* Add a leaf.
*
- * @param leaf the leaf to be added.
+ * @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
@@ -195,7 +195,7 @@
/**
* Get the list of leaf-list.
*
- * @return the list of leaf-list.
+ * @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
@@ -205,7 +205,7 @@
/**
* Set the list of leaf-list.
*
- * @param listOfLeafList the list of leaf-list to set.
+ * @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
@@ -214,7 +214,7 @@
/**
* Add a leaf-list.
*
- * @param leafList the leaf-list to be added.
+ * @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
@@ -228,7 +228,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -238,7 +238,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -248,7 +248,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -258,7 +258,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -268,17 +268,17 @@
/**
* Returns the type of the data as belongs-to.
*
- * @return returns AUGMENT_DATA.
+ * @return returns AUGMENT_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.AUGMENT_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.AUGMENT_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -288,7 +288,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
@@ -298,7 +298,7 @@
/**
* Get the target nodes name where the augmentation is being done.
*
- * @return target nodes name where the augmentation is being done.
+ * @return target nodes name where the augmentation is being done
*/
@Override
public String getName() {
@@ -308,7 +308,7 @@
/**
* Set the target nodes name where the augmentation is being done.
*
- * @param name target nodes name where the augmentation is being done.
+ * @param name target nodes name where the augmentation is being done
*/
@Override
public void setName(String name) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java
index a4a5cae..b3b718f 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java
@@ -17,7 +17,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*-
* Reference 6020.
@@ -94,7 +94,7 @@
/**
* Get the prefix.
*
- * @return the prefix.
+ * @return the prefix
*/
public String getPrefix() {
return prefix;
@@ -115,14 +115,14 @@
* @return ParsedDataType returns BELONGS_TO_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.BELONGS_TO_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.BELONGS_TO_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -132,7 +132,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBit.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBit.java
index 77f19c1..47956e6 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBit.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBit.java
@@ -18,7 +18,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
import java.util.Objects;
@@ -83,7 +83,7 @@
/**
* Returns bit name.
*
- * @return the bit name.
+ * @return the bit name
*/
public String getBitName() {
return bitName;
@@ -92,7 +92,7 @@
/**
* Set the bit name.
*
- * @param bitName the bit name to set.
+ * @param bitName the bit name to set
*/
public void setBitName(String bitName) {
this.bitName = bitName;
@@ -101,7 +101,7 @@
/**
* Returns description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -111,7 +111,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -121,7 +121,7 @@
/**
* Returns textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -131,7 +131,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -141,7 +141,7 @@
/**
* Returns status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -151,7 +151,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -170,7 +170,7 @@
/**
* Set the bit position.
*
- * @param position the position to set.
+ * @param position the position to set
*/
public void setPosition(int position) {
this.position = position;
@@ -182,8 +182,8 @@
* @return ParsedDataType returns BIT_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.BIT_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.BIT_DATA;
}
@Override
@@ -206,7 +206,7 @@
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -216,7 +216,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBits.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBits.java
index 54898a4..dbf0531 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBits.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangBits.java
@@ -21,7 +21,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference RFC 6020.
@@ -70,12 +70,13 @@
/**
* Add bit info.
*
- * @param bitInfo the bit information to be added.
- * @throws DataModelException due to violation in data model rules.
+ * @param bitInfo the bit information to be added
+ * @throws DataModelException due to violation in data model rules
*/
public void addBitInfo(YangBit bitInfo) throws DataModelException {
if (!getBitSet().add(bitInfo)) {
- throw new DataModelException("YANG Bit already exists");
+ throw new DataModelException("YANG file error: Duplicate identifier detected, same as bit \""
+ + bitInfo.getBitName() + "\"");
}
}
@@ -85,14 +86,14 @@
* @return ParsedDataType returns BITS_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.BITS_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.BITS_DATA;
}
/**
* Returns the bits name.
*
- * @return name of the bits.
+ * @return name of the bits
*/
public String getBitsName() {
return bitsName;
@@ -101,7 +102,7 @@
/**
* Set bits name.
*
- * @param bitsName bit name to be set.
+ * @param bitsName bit name to be set
*/
public void setBitsName(String bitsName) {
this.bitsName = bitsName;
@@ -110,7 +111,7 @@
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -120,7 +121,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
index dc9f36b..b9da3c2 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
@@ -15,14 +15,16 @@
*/
package org.onosproject.yangutils.datamodel;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import org.onosproject.yangutils.parser.Parsable;
+import org.onosproject.yangutils.translator.CachedFileHandle;
+import org.onosproject.yangutils.utils.YangConstructType;
+import static org.onosproject.yangutils.utils.YangConstructType.CASE_DATA;
+
import java.util.LinkedList;
import java.util.List;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
-import org.onosproject.yangutils.translator.CachedFileHandle;
-
/*-
* Reference RFC 6020.
*
@@ -90,7 +92,7 @@
* Data model node to maintain information defined in YANG case.
*/
public class YangCase extends YangNode
- implements YangLeavesHolder, YangCommonInfo, Parsable {
+ implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector {
/**
* Case name.
@@ -100,7 +102,7 @@
// TODO: default field identification for the case
/**
- * Description of container.
+ * Description of case.
*/
private String description;
@@ -125,7 +127,7 @@
private YangStatusType status;
/**
- * package of the generated java code.
+ * Package of the generated java code.
*/
private String pkg;
@@ -139,7 +141,7 @@
/**
* Get the case name.
*
- * @return case name.
+ * @return case name
*/
@Override
public String getName() {
@@ -149,7 +151,7 @@
/**
* Set the case name.
*
- * @param name case name.
+ * @param name case name
*/
@Override
public void setName(String name) {
@@ -159,7 +161,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -169,7 +171,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -179,7 +181,7 @@
/**
* Get the list of leaves.
*
- * @return the list of leaves.
+ * @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
@@ -189,7 +191,7 @@
/**
* Set the list of leaves.
*
- * @param leafsList the list of leaf to set.
+ * @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
@@ -198,7 +200,7 @@
/**
* Add a leaf.
*
- * @param leaf the leaf to be added.
+ * @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
@@ -212,7 +214,7 @@
/**
* Get the list of leaf-list.
*
- * @return the list of leaf-list.
+ * @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
@@ -222,7 +224,7 @@
/**
* Set the list of leaf-list.
*
- * @param listOfLeafList the list of leaf-list to set.
+ * @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
@@ -231,7 +233,7 @@
/**
* Add a leaf-list.
*
- * @param leafList the leaf-list to be added.
+ * @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
@@ -245,7 +247,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -255,7 +257,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -265,7 +267,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -275,7 +277,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -288,14 +290,14 @@
* @return returns CASE_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.CASE_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.CASE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -305,7 +307,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
@@ -361,6 +363,30 @@
@Override
public void setFileHandle(CachedFileHandle fileHandle) {
// TODO Auto-generated method stub
+ }
+ @Override
+ public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
+ if ((this.getParent() == null) || (!(this.getParent() instanceof YangChoice))) {
+ throw new DataModelException("Internal Data Model Tree Error: Invalid/Missing holder in case " +
+ this.getName());
+ }
+ // Traverse up in tree to ask parent choice start collision detection.
+ ((CollisionDetector) this.getParent()).detectCollidingChild(identifierName, dataType);
+ }
+
+ @Override
+ public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
+
+ if (dataType == CASE_DATA) {
+ if (this.getName().equals(identifierName)) {
+ throw new DataModelException("YANG File Error: Identifier collision detected in case \"" +
+ this.getName() + "\"");
+ }
+ return;
+ }
+
+ // Asks helper to detect colliding child.
+ detectCollidingChildUtil(identifierName, dataType, this);
}
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
index be47039..440ca57 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
@@ -15,13 +15,11 @@
*/
package org.onosproject.yangutils.datamodel;
-import java.util.LinkedList;
-import java.util.List;
-
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.translator.CachedFileHandle;
+import org.onosproject.yangutils.utils.YangConstructType;
+import static org.onosproject.yangutils.utils.YangConstructType.CHOICE_DATA;
/*-
* Reference RFC 6020.
@@ -61,7 +59,7 @@
/**
* Data model node to maintain information defined in YANG choice.
*/
-public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
+public class YangChoice extends YangNode implements YangCommonInfo, Parsable, CollisionDetector {
/**
* Name of choice.
@@ -69,11 +67,6 @@
private String name;
/**
- * List of cases for the current choice.
- */
- private List<YangCase> caseList;
-
- /**
* If the choice represents config data.
*/
private boolean isConfig;
@@ -105,7 +98,7 @@
private String defaultCase;
/**
- * Description.
+ * Description of choice.
*/
private String description;
@@ -131,7 +124,7 @@
private String mandatory;
/**
- * reference of the choice.
+ * Reference of the choice.
*/
private String reference;
@@ -141,13 +134,15 @@
private YangStatusType status;
/**
- * Create a Choice node.
+ * Create a choice node.
*/
public YangChoice() {
super(YangNodeType.CHOICE_NODE);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
*/
@Override
@@ -155,8 +150,11 @@
return name;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
*/
@Override
public void setName(String name) {
@@ -164,40 +162,9 @@
}
/**
- * Get the list of cases.
- *
- * @return the case list
- */
- public List<YangCase> getCaseList() {
- return caseList;
- }
-
- /**
- * Set the list of cases.
- *
- * @param caseList list of cases.
- */
- private void setCaseList(List<YangCase> caseList) {
- this.caseList = caseList;
- }
-
- /**
- * Add a case.
- *
- * @param newCase new case for the choice
- */
- public void addCase(YangCase newCase) {
- if (getCaseList() == null) {
- setCaseList(new LinkedList<YangCase>());
- }
-
- getCaseList().add(newCase);
- }
-
- /**
* Get config flag.
*
- * @return the config flag.
+ * @return the config flag
*/
public boolean isConfig() {
return isConfig;
@@ -206,7 +173,7 @@
/**
* Set config flag.
*
- * @param isCfg the config flag.
+ * @param isCfg the config flag
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
@@ -215,7 +182,7 @@
/**
* Get the default case.
*
- * @return the default case.
+ * @return the default case
*/
public String getDefaultCase() {
return defaultCase;
@@ -233,7 +200,7 @@
/**
* Get the mandatory status.
*
- * @return the mandatory status.
+ * @return the mandatory status
*/
public String getMandatory() {
return mandatory;
@@ -242,7 +209,7 @@
/**
* Set the mandatory status.
*
- * @param mandatory the mandatory status.
+ * @param mandatory the mandatory status
*/
public void setMandatory(String mandatory) {
this.mandatory = mandatory;
@@ -251,7 +218,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -261,7 +228,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -271,7 +238,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -281,7 +248,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -291,7 +258,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -301,7 +268,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -314,14 +281,14 @@
* @return returns CHOICE_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.CHOICE_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.CHOICE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -331,14 +298,16 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
*/
@Override
@@ -347,8 +316,11 @@
return null;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
*/
@Override
public void setPackage(String pkg) {
@@ -356,8 +328,12 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry(
+ * )
*/
@Override
public void generateJavaCodeEntry() {
@@ -365,8 +341,11 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
*/
@Override
public void generateJavaCodeExit() {
@@ -385,4 +364,36 @@
// TODO Auto-generated method stub
}
+
+ @Override
+ public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
+
+ YangNode node = this.getChild();
+ while ((node != null)) {
+ if (node instanceof CollisionDetector) {
+ ((CollisionDetector) node).detectSelfCollision(identifierName, dataType);
+ }
+ node = node.getNextSibling();
+ }
+ }
+
+ @Override
+ public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
+
+ if (dataType == CHOICE_DATA) {
+ if (this.getName().equals(identifierName)) {
+ throw new DataModelException("YANG file error: Identifier collision detected in choice \"" +
+ this.getName() + "\"");
+ }
+ return;
+ }
+
+ YangNode node = this.getChild();
+ while ((node != null)) {
+ if (node instanceof CollisionDetector) {
+ ((CollisionDetector) node).detectSelfCollision(identifierName, dataType);
+ }
+ node = node.getNextSibling();
+ }
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
index 99baf4a..d251479 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
@@ -21,8 +21,9 @@
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.translator.CachedFileHandle;
import org.onosproject.yangutils.translator.GeneratedFileType;
import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
@@ -90,7 +91,7 @@
/**
* Data model node to maintain information defined in YANG container.
*/
-public class YangContainer extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
+public class YangContainer extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector {
/**
* Name of the container.
@@ -153,7 +154,7 @@
/**
* Get the YANG name of container.
*
- * @return the name of container as defined in YANG file.
+ * @return the name of container as defined in YANG file
*/
@Override
public String getName() {
@@ -163,7 +164,7 @@
/**
* Set the YANG name of container.
*
- * @param name the name of container as defined in YANG file.
+ * @param name the name of container as defined in YANG file
*/
@Override
public void setName(String name) {
@@ -182,7 +183,7 @@
/**
* Set the config flag.
*
- * @param isCfg the config flag.
+ * @param isCfg the config flag
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
@@ -191,7 +192,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -201,7 +202,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -211,7 +212,7 @@
/**
* Get the list of leaves.
*
- * @return the list of leaves.
+ * @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
@@ -221,7 +222,7 @@
/**
* Set the list of leaves.
*
- * @param leafsList the list of leaf to set.
+ * @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
@@ -230,7 +231,7 @@
/**
* Add a leaf.
*
- * @param leaf the leaf to be added.
+ * @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
@@ -244,7 +245,7 @@
/**
* Get the list of leaf-list.
*
- * @return the list of leaf-list.
+ * @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
@@ -254,7 +255,7 @@
/**
* Set the list of leaf-list.
*
- * @param listOfLeafList the list of leaf-list to set.
+ * @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
@@ -263,7 +264,7 @@
/**
* Add a leaf-list.
*
- * @param leafList the leaf-list to be added.
+ * @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
@@ -277,7 +278,7 @@
/**
* Get the presence string if present.
*
- * @return the isPressence.
+ * @return the presence
*/
public String getPresence() {
return presence;
@@ -295,7 +296,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -305,7 +306,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -315,7 +316,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -325,7 +326,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -355,17 +356,17 @@
/**
* Returns the type of the data.
*
- * @return returns CONTAINER_DATA.
+ * @return returns CONTAINER_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.CONTAINER_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.CONTAINER_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -375,7 +376,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
@@ -387,15 +388,18 @@
}
/**
- * Sets the config's value to all leaf if leaf's config statement is not specified.
+ * Sets the config's value to all leaf if leaf's config statement is not
+ * specified.
*
- * @param leaves list of leaf attributes of container.
- * @param leafLists list of leaf-list attributes of container.
+ * @param leaves list of leaf attributes of container
+ * @param leafLists list of leaf-list attributes of container
*/
private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
- /* If "config" is not specified, the default is the same as the parent
- schema node's "config" value.*/
+ /*
+ * If "config" is not specified, the default is the same as the parent
+ * schema node's "config" value.
+ */
if (leaves != null) {
for (YangLeaf leaf : leaves) {
if (leaf.isConfig() == null) {
@@ -404,8 +408,10 @@
}
}
- /* If "config" is not specified, the default is the same as the parent
- schema node's "config" value.*/
+ /*
+ * If "config" is not specified, the default is the same as the parent
+ * schema node's "config" value.
+ */
if (leafLists != null) {
for (YangLeafList leafList : leafLists) {
if (leafList.isConfig() == null) {
@@ -418,14 +424,16 @@
/**
* Validates config statement of container.
*
- * @param leaves list of leaf attributes of container.
- * @param leafLists list of leaf-list attributes of container.
- * @throws DataModelException a violation of data model rules.
+ * @param leaves list of leaf attributes of container
+ * @param leafLists list of leaf-list attributes of container
+ * @throws DataModelException a violation of data model rules
*/
private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException {
- /* If a node has "config" set to "false", no node underneath it can have
- "config" set to "true".*/
+ /*
+ * If a node has "config" set to "false", no node underneath it can have
+ * "config" set to "true".
+ */
if ((!isConfig) && (leaves != null)) {
for (YangLeaf leaf : leaves) {
if (leaf.isConfig()) {
@@ -468,7 +476,7 @@
/**
* Generate the java code corresponding to YANG container.
*
- * @throws IOException when fails to generate the source files.
+ * @throws IOException when fails to generate the source files
*/
@Override
public void generateJavaCodeEntry() throws IOException {
@@ -532,4 +540,18 @@
}
return;
}
+
+ @Override
+ public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
+ // Asks helper to detect colliding child.
+ detectCollidingChildUtil(identifierName, dataType, this);
+ }
+
+ @Override
+ public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
+ if (this.getName().equals(identifierName)) {
+ throw new DataModelException("YANG file error: Duplicate input identifier detected, same as container \""
+ + this.getName() + "\"");
+ }
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedType.java
index 31484ba..8c9628c 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedType.java
@@ -15,7 +15,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*-
* The typedef Statement
@@ -60,7 +60,7 @@
/**
* Get the effective YANG built-in type of the derived data type.
*
- * @return effective YANG built-in type of the derived data type.
+ * @return effective YANG built-in type of the derived data type
*/
public YangDataTypes getEffectiveYangBuiltInType() {
return effectiveYangBuiltInType;
@@ -69,7 +69,7 @@
/**
* Set the effective YANG built-in type of the derived data type.
*
- * @param builtInType effective YANG built-in type of the derived data type.
+ * @param builtInType effective YANG built-in type of the derived data type
*/
public void setEffectiveYangBuiltInType(YangDataTypes builtInType) {
effectiveYangBuiltInType = builtInType;
@@ -78,7 +78,7 @@
/**
* Get the base type information.
*
- * @return base type information.
+ * @return base type information
*/
public YangType<?> getBaseType() {
return baseType;
@@ -87,7 +87,7 @@
/**
* Get the base type information.
*
- * @param baseType base type information.
+ * @param baseType base type information
*/
public void setBaseType(YangType<?> baseType) {
this.baseType = baseType;
@@ -97,8 +97,8 @@
* Get the parsable type.
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.DERIVED;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.DERIVED;
}
/**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnum.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnum.java
index 76ab0f3..dd79b65 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnum.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnum.java
@@ -18,7 +18,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
import java.util.Objects;
@@ -73,7 +73,7 @@
private YangStatusType status;
/**
- * value of ENUM.
+ * Value of ENUM.
*/
private int value;
@@ -87,7 +87,7 @@
/**
* Get the named value.
*
- * @return the named value.
+ * @return the named value
*/
public String getNamedValue() {
return namedValue;
@@ -96,7 +96,7 @@
/**
* Set the named value.
*
- * @param namedValue the named value to set.
+ * @param namedValue the named value to set
*/
public void setNamedValue(String namedValue) {
this.namedValue = namedValue;
@@ -105,7 +105,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -115,7 +115,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -125,7 +125,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -135,7 +135,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -145,7 +145,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -155,7 +155,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -165,7 +165,7 @@
/**
* Get the value.
*
- * @return the value.
+ * @return the value
*/
public int getValue() {
return value;
@@ -174,7 +174,7 @@
/**
* Set the value.
*
- * @param value the value to set.
+ * @param value the value to set
*/
public void setValue(int value) {
this.value = value;
@@ -186,8 +186,8 @@
* @return ParsedDataType returns ENUM_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.ENUM_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.ENUM_DATA;
}
@Override
@@ -210,7 +210,7 @@
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -220,7 +220,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
index b89cc82..25a3bbb 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
@@ -21,7 +21,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*
* The enumeration built-in type represents values from a set of
@@ -67,8 +67,8 @@
/**
* Add ENUM information.
*
- * @param enumInfo the ENUM information to be added.
- * @throws DataModelException due to violation in data model rules.
+ * @param enumInfo the ENUM information to be added
+ * @throws DataModelException due to violation in data model rules
*/
public void addEnumInfo(YangEnum enumInfo) throws DataModelException {
if (!getEnumSet().add(enumInfo)) {
@@ -100,14 +100,14 @@
* @return returns ENUMERATION_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.ENUMERATION_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.ENUMERATION_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -117,7 +117,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java
index 4e3061d..9d87ee4 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java
@@ -20,7 +20,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.translator.CachedFileHandle;
/*-
@@ -110,7 +110,7 @@
private YangStatusType status;
/**
- * package of the generated java code.
+ * Package of the generated java code.
*/
private String pkg;
@@ -124,7 +124,7 @@
/**
* Get YANG grouping name.
*
- * @return YANG grouping name.
+ * @return YANG grouping name
*/
@Override
public String getName() {
@@ -134,7 +134,7 @@
/**
* Set YANG grouping name.
*
- * @param name YANG grouping name.
+ * @param name YANG grouping name
*/
@Override
public void setName(String name) {
@@ -144,7 +144,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -154,7 +154,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -164,7 +164,7 @@
/**
* Get the list of leaves.
*
- * @return the list of leaves.
+ * @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
@@ -174,7 +174,7 @@
/**
* Set the list of leaves.
*
- * @param leafsList the list of leaf to set.
+ * @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
@@ -183,7 +183,7 @@
/**
* Add a leaf.
*
- * @param leaf the leaf to be added.
+ * @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
@@ -197,7 +197,7 @@
/**
* Get the list of leaf-list.
*
- * @return the list of leaf-list.
+ * @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
@@ -207,7 +207,7 @@
/**
* Set the list of leaf-list.
*
- * @param listOfLeafList the list of leaf-list to set.
+ * @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
@@ -216,7 +216,7 @@
/**
* Add a leaf-list.
*
- * @param leafList the leaf-list to be added.
+ * @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
@@ -230,7 +230,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -240,7 +240,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -250,7 +250,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -260,7 +260,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -270,17 +270,17 @@
/**
* Returns the type of the data.
*
- * @return returns GROUPING_DATA.
+ * @return returns GROUPING_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.GROUPING_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.GROUPING_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -290,7 +290,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
index 83f978e..a6e81f0 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
@@ -17,7 +17,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
@@ -94,7 +94,7 @@
/**
* Get the imported module name.
*
- * @return the module name.
+ * @return the module name
*/
public String getModuleName() {
return name;
@@ -113,7 +113,7 @@
* Get the prefix used to identify the entities from the imported module.
*
* @return the prefix used to identify the entities from the imported
- * module.
+ * module
*/
public String getPrefixId() {
return prefixId;
@@ -122,7 +122,7 @@
/**
* Set prefix identifier.
*
- * @param prefixId set the prefix identifier of the imported module.
+ * @param prefixId set the prefix identifier of the imported module
*/
public void setPrefixId(String prefixId) {
this.prefixId = prefixId;
@@ -131,7 +131,7 @@
/**
* Get the revision of the imported module.
*
- * @return the revision of the imported module.
+ * @return the revision of the imported module
*/
public String getRevision() {
return revision;
@@ -140,7 +140,7 @@
/**
* Set the revision of the imported module.
*
- * @param rev set the revision of the imported module.
+ * @param rev set the revision of the imported module
*/
public void setRevision(String rev) {
revision = rev;
@@ -152,8 +152,8 @@
* @return returns IMPORT_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.IMPORT_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.IMPORT_DATA;
}
/**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
index a506847..917a0d3 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
@@ -17,7 +17,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
@@ -98,8 +98,8 @@
* @return returns INCLUDE_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.INCLUDE_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.INCLUDE_DATA;
}
/**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
index 888094e..a2e5ab5 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
@@ -18,7 +18,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
@@ -108,7 +108,7 @@
/**
* Get the name of leaf.
*
- * @return the leaf name.
+ * @return the leaf name
*/
public String getLeafName() {
return name;
@@ -117,7 +117,7 @@
/**
* Set the name of leaf.
*
- * @param leafName the leaf name to set.
+ * @param leafName the leaf name to set
*/
public void setLeafName(String leafName) {
name = leafName;
@@ -126,7 +126,7 @@
/**
* Get the config flag.
*
- * @return if config flag.
+ * @return if config flag
*/
public Boolean isConfig() {
return isConfig;
@@ -135,7 +135,7 @@
/**
* Set the config flag.
*
- * @param isCfg the flag value to set.
+ * @param isCfg the flag value to set
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
@@ -144,7 +144,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -154,7 +154,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -164,7 +164,7 @@
/**
* Get if the leaf is mandatory.
*
- * @return if leaf is mandatory.
+ * @return if leaf is mandatory
*/
public boolean isMandatory() {
return isMandatory;
@@ -182,7 +182,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -192,7 +192,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -202,7 +202,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -212,7 +212,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -222,7 +222,7 @@
/**
* Get the units.
*
- * @return the units.
+ * @return the units
*/
public String getUnits() {
return units;
@@ -231,7 +231,7 @@
/**
* Set the units.
*
- * @param units the units to set.
+ * @param units the units to set
*/
public void setUnits(String units) {
this.units = units;
@@ -240,7 +240,7 @@
/**
* Get the data type.
*
- * @return the data type.
+ * @return the data type
*/
public YangType<?> getDataType() {
return dataType;
@@ -249,7 +249,7 @@
/**
* Set the data type.
*
- * @param dataType the data type to set.
+ * @param dataType the data type to set
*/
public void setDataType(YangType<?> dataType) {
this.dataType = dataType;
@@ -258,17 +258,17 @@
/**
* Returns the type of the parsed data.
*
- * @return returns LEAF_DATA.
+ * @return returns LEAF_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.LEAF_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.LEAF_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -279,7 +279,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
index 6ce3430..9852a75 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
@@ -18,7 +18,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
@@ -130,7 +130,7 @@
/**
* Get the leaf-list name.
*
- * @return the leaf-list name.
+ * @return the leaf-list name
*/
public String getLeafName() {
return name;
@@ -139,7 +139,7 @@
/**
* Set the leaf-list name.
*
- * @param leafListName the leaf-list name to set.
+ * @param leafListName the leaf-list name to set
*/
public void setLeafName(String leafListName) {
name = leafListName;
@@ -148,7 +148,7 @@
/**
* Get the config flag.
*
- * @return the config flag.
+ * @return the config flag
*/
public Boolean isConfig() {
return isConfig;
@@ -157,7 +157,7 @@
/**
* Set the config flag.
*
- * @param isCfg the config flag.
+ * @param isCfg the config flag
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
@@ -166,7 +166,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -176,7 +176,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -186,7 +186,7 @@
/**
* Get the max elements no.
*
- * @return the max elements no.
+ * @return the max elements no
*/
public int getMaxElelements() {
return maxElelements;
@@ -195,7 +195,7 @@
/**
* Set the max elements no.
*
- * @param maxElelements max elements no.
+ * @param maxElelements max elements no
*/
public void setMaxElelements(int maxElelements) {
this.maxElelements = maxElelements;
@@ -204,7 +204,7 @@
/**
* Get the min elements no.
*
- * @return the min elements no.
+ * @return the min elements no
*/
public int getMinElements() {
return minElements;
@@ -213,7 +213,7 @@
/**
* Set the min elements no.
*
- * @param minElements the min elements no.
+ * @param minElements the min elements no
*/
public void setMinElements(int minElements) {
this.minElements = minElements;
@@ -222,7 +222,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -232,7 +232,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -242,7 +242,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -252,7 +252,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -262,7 +262,7 @@
/**
* Get the units.
*
- * @return the units.
+ * @return the units
*/
public String getUnits() {
return units;
@@ -271,7 +271,7 @@
/**
* Set the units.
*
- * @param units the units to set.
+ * @param units the units to set
*/
public void setUnits(String units) {
this.units = units;
@@ -280,7 +280,7 @@
/**
* Get the data type.
*
- * @return the data type.
+ * @return the data type
*/
public YangType<?> getDataType() {
return dataType;
@@ -289,7 +289,7 @@
/**
* Set the data type.
*
- * @param dataType the data type to set.
+ * @param dataType the data type to set
*/
public void setDataType(YangType<?> dataType) {
this.dataType = dataType;
@@ -298,17 +298,17 @@
/**
* Returns the type of the parsed data.
*
- * @return returns LEAF_LIST_DATA.
+ * @return returns LEAF_LIST_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.LEAF_LIST_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.LEAF_LIST_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -319,7 +319,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
index d2ee876..c0b569b 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
@@ -16,14 +16,15 @@
package org.onosproject.yangutils.datamodel;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import org.onosproject.yangutils.parser.Parsable;
+import org.onosproject.yangutils.translator.CachedFileHandle;
+import org.onosproject.yangutils.utils.YangConstructType;
+
import java.util.LinkedList;
import java.util.List;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
-import org.onosproject.yangutils.translator.CachedFileHandle;
-
/*-
* The "list" statement is used to define an interior data node in the
* schema tree. A list node may exist in multiple instances in the data
@@ -67,10 +68,10 @@
* List data represented in YANG.
*/
public class YangList extends YangNode
- implements YangLeavesHolder, YangCommonInfo, Parsable {
+ implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector {
/**
- * name of the YANG list.
+ * Name of the YANG list.
*/
private String name;
@@ -177,7 +178,7 @@
/**
* Get the YANG list name.
*
- * @return YANG list name.
+ * @return YANG list name
*/
@Override
public String getName() {
@@ -187,7 +188,7 @@
/**
* Set the YANG list name.
*
- * @param name YANG list name.
+ * @param name YANG list name
*/
@Override
public void setName(String name) {
@@ -206,7 +207,7 @@
/**
* Set the config flag.
*
- * @param isCfg the config flag.
+ * @param isCfg the config flag
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
@@ -215,7 +216,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -225,7 +226,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -235,7 +236,7 @@
/**
* Get the list of key field names.
*
- * @return the list of key field names.
+ * @return the list of key field names
*/
public List<String> getKeyList() {
return keyList;
@@ -244,7 +245,7 @@
/**
* Set the list of key field names.
*
- * @param keyList the list of key field names.
+ * @param keyList the list of key field names
*/
private void setKeyList(List<String> keyList) {
this.keyList = keyList;
@@ -254,7 +255,7 @@
* Add a key field name.
*
* @param key key field name.
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
public void addKey(String key) throws DataModelException {
if (getKeyList() == null) {
@@ -272,7 +273,7 @@
/**
* Get the list of leaves.
*
- * @return the list of leaves.
+ * @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
@@ -282,7 +283,7 @@
/**
* Set the list of leaves.
*
- * @param leafsList the list of leaf to set.
+ * @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
@@ -291,7 +292,7 @@
/**
* Add a leaf.
*
- * @param leaf the leaf to be added.
+ * @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
@@ -305,7 +306,7 @@
/**
* Get the list of leaf-list.
*
- * @return the list of leaf-list.
+ * @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
@@ -315,7 +316,7 @@
/**
* Set the list of leaf-list.
*
- * @param listOfLeafList the list of leaf-list to set.
+ * @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
@@ -324,7 +325,7 @@
/**
* Add a leaf-list.
*
- * @param leafList the leaf-list to be added.
+ * @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
@@ -338,7 +339,7 @@
/**
* Get the max elements.
*
- * @return the max elements.
+ * @return the max elements
*/
public int getMaxElelements() {
return maxElelements;
@@ -347,7 +348,7 @@
/**
* Set the max elements.
*
- * @param maxElelements the max elements.
+ * @param maxElelements the max elements
*/
public void setMaxElelements(int maxElelements) {
this.maxElelements = maxElelements;
@@ -356,7 +357,7 @@
/**
* Get the minimum elements.
*
- * @return the minimum elements.
+ * @return the minimum elements
*/
public int getMinElements() {
return minElements;
@@ -365,7 +366,7 @@
/**
* Set the minimum elements.
*
- * @param minElements the minimum elements.
+ * @param minElements the minimum elements
*/
public void setMinElements(int minElements) {
this.minElements = minElements;
@@ -374,7 +375,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -384,7 +385,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -394,7 +395,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -404,7 +405,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -414,17 +415,17 @@
/**
* Returns the type of the parsed data.
*
- * @return returns LIST_DATA.
+ * @return returns LIST_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.LIST_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.LIST_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -434,7 +435,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
@@ -464,8 +465,8 @@
* Sets the config's value to all leaf if leaf's config statement is not
* specified.
*
- * @param leaves list of leaf attributes of YANG list.
- * @param leafLists list of leaf-list attributes of YANG list.
+ * @param leaves list of leaf attributes of YANG list
+ * @param leafLists list of leaf-list attributes of YANG list
*/
private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
@@ -497,9 +498,9 @@
/**
* Validates config statement of YANG list.
*
- * @param leaves list of leaf attributes of YANG list.
- * @param leafLists list of leaf-list attributes of YANG list.
- * @throws DataModelException a violation of data model rules.
+ * @param leaves list of leaf attributes of YANG list
+ * @param leafLists list of leaf-list attributes of YANG list
+ * @throws DataModelException a violation of data model rules
*/
private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException {
@@ -529,9 +530,9 @@
/**
* Validates key statement of list.
*
- * @param leaves list of leaf attributes of list.
- * @param keys list of key attributes of list.
- * @throws DataModelException a violation of data model rules.
+ * @param leaves list of leaf attributes of list
+ * @param keys list of key attributes of list
+ * @throws DataModelException a violation of data model rules
*/
private void validateLeafKey(List<YangLeaf> leaves, List<String> keys) throws DataModelException {
boolean leafFound = false;
@@ -574,9 +575,9 @@
/**
* Validates key statement of list.
*
- * @param leafLists list of leaf-list attributes of list.
- * @param keys list of key attributes of list.
- * @throws DataModelException a violation of data model rules.
+ * @param leafLists list of leaf-list attributes of list
+ * @param keys list of key attributes of list
+ * @throws DataModelException a violation of data model rules
*/
private void validateLeafListKey(List<YangLeafList> leafLists, List<String> keys) throws DataModelException {
boolean leafFound = false;
@@ -668,4 +669,18 @@
// TODO Auto-generated method stub
}
+
+ @Override
+ public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
+ // Asks helper to detect colliding child.
+ detectCollidingChildUtil(identifierName, dataType, this);
+ }
+
+ @Override
+ public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
+ if (this.getName().equals(identifierName)) {
+ throw new DataModelException("YANG file error: Duplicate input identifier detected, same as list \"" +
+ this.getName() + "\"");
+ }
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
index 5644d82..e56bdab 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
@@ -15,20 +15,21 @@
*/
package org.onosproject.yangutils.datamodel;
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.translator.CachedFileHandle;
import org.onosproject.yangutils.translator.CodeGenerator;
import org.onosproject.yangutils.translator.GeneratedFileType;
import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
import org.onosproject.yangutils.utils.UtilConstants;
+import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.utils.io.impl.FileSystemUtil;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
/*-
* Reference:RFC 6020.
* The "module" statement defines the module's name,
@@ -73,7 +74,7 @@
* Data model node to maintain information defined in YANG module.
*/
public class YangModule extends YangNode
- implements YangLeavesHolder, YangDesc, YangReference, Parsable, CodeGenerator {
+ implements YangLeavesHolder, YangDesc, YangReference, Parsable, CodeGenerator, CollisionDetector {
/**
* Name of the module.
@@ -588,8 +589,8 @@
* @return returns MODULE_DATA.
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.MODULE_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.MODULE_DATA;
}
/**
@@ -697,4 +698,15 @@
module.addToNestedReferenceResoulutionList(node);
return;
}
+
+ @Override
+ public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
+ // Asks helper to detect colliding child.
+ detectCollidingChildUtil(identifierName, dataType, this);
+ }
+
+ @Override
+ public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
+ // Not required as module doesn't have any parent.
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java
index 63430c1..1bb9992 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java
@@ -17,7 +17,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*-
* The "must" statement, which is optional, takes as an argument a string that
@@ -59,7 +59,7 @@
private String description;
/**
- * reference string.
+ * Reference string.
*/
private String reference;
@@ -72,7 +72,7 @@
/**
* Get the constraint.
*
- * @return the constraint.
+ * @return the constraint
*/
public String getConstratint() {
return constratint;
@@ -90,7 +90,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -100,7 +100,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -110,7 +110,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -120,7 +120,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -133,14 +133,14 @@
* @return returns MUST_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.MUST_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.MUST_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -150,7 +150,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNameSpace.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNameSpace.java
index 2d79a6f..897552d 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNameSpace.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNameSpace.java
@@ -18,7 +18,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
@@ -45,7 +45,7 @@
/**
* Get the name space URI.
*
- * @return the URI.
+ * @return the URI
*/
public String getUri() {
return uri;
@@ -63,17 +63,17 @@
/**
* Returns the type of the parsed data.
*
- * @return returns NAMESPACE_DATA.
+ * @return returns NAMESPACE_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.NAMESPACE_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.NAMESPACE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -84,7 +84,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangRevision.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangRevision.java
index 8989262..083416b 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangRevision.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangRevision.java
@@ -17,7 +17,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
@@ -86,7 +86,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -96,7 +96,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -106,7 +106,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -116,7 +116,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -126,17 +126,17 @@
/**
* Returns the type of the parsed data.
*
- * @return returns REVISION_DATA.
+ * @return returns REVISION_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.REVISION_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.REVISION_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -147,7 +147,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
index 467217e..f2e9119 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
@@ -15,14 +15,15 @@
*/
package org.onosproject.yangutils.datamodel;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import org.onosproject.yangutils.parser.Parsable;
+import org.onosproject.yangutils.translator.CachedFileHandle;
+import org.onosproject.yangutils.utils.YangConstructType;
+
import java.util.LinkedList;
import java.util.List;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
-import org.onosproject.yangutils.translator.CachedFileHandle;
-
/*
* Reference RFC 6020.
*
@@ -74,7 +75,7 @@
* Data model node to maintain information defined in YANG sub-module.
*/
public class YangSubModule extends YangNode
- implements YangLeavesHolder, YangDesc, YangReference, Parsable {
+ implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector {
/**
* Name of sub module.
@@ -186,7 +187,7 @@
/**
* Set the module info.
*
- * @param belongsTo module info to set.
+ * @param belongsTo module info to set
*/
public void setBelongsTo(YangBelongsTo belongsTo) {
this.belongsTo = belongsTo;
@@ -195,7 +196,7 @@
/**
* Get the contact.
*
- * @return the contact.
+ * @return the contact
*/
public String getContact() {
return contact;
@@ -213,7 +214,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -223,7 +224,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -233,7 +234,7 @@
/**
* Get the list of imported modules.
*
- * @return the list of imported modules.
+ * @return the list of imported modules
*/
public List<YangImport> getImportList() {
return importList;
@@ -242,7 +243,7 @@
/**
* prevent setting the import list from outside.
*
- * @param importList the import list to set.
+ * @param importList the import list to set
*/
private void setImportList(List<YangImport> importList) {
this.importList = importList;
@@ -251,7 +252,7 @@
/**
* Add the imported module information to the import list.
*
- * @param importedModule module being imported.
+ * @param importedModule module being imported
*/
public void addImportedInfo(YangImport importedModule) {
@@ -267,7 +268,7 @@
/**
* Get the list of included sub modules.
*
- * @return the included list of sub modules.
+ * @return the included list of sub modules
*/
public List<YangInclude> getIncludeList() {
return includeList;
@@ -276,7 +277,7 @@
/**
* Set the list of included sub modules.
*
- * @param includeList the included list to set.
+ * @param includeList the included list to set
*/
private void setIncludeList(List<YangInclude> includeList) {
this.includeList = includeList;
@@ -285,7 +286,7 @@
/**
* Add the included sub module information to the include list.
*
- * @param includeModule submodule being included.
+ * @param includeModule submodule being included
*/
public void addIncludedInfo(YangInclude includeModule) {
@@ -300,7 +301,7 @@
/**
* Get the list of leaves.
*
- * @return the list of leaves.
+ * @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
@@ -310,7 +311,7 @@
/**
* Set the list of leaves.
*
- * @param leafsList the list of leaf to set.
+ * @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
@@ -319,7 +320,7 @@
/**
* Add a leaf.
*
- * @param leaf the leaf to be added.
+ * @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
@@ -333,7 +334,7 @@
/**
* Get the list of leaf-list.
*
- * @return the list of leaf-list.
+ * @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
@@ -343,7 +344,7 @@
/**
* Set the list of leaf-list.
*
- * @param listOfLeafList the list of leaf-list to set.
+ * @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
@@ -352,7 +353,7 @@
/**
* Add a leaf-list.
*
- * @param leafList the leaf-list to be added.
+ * @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
@@ -366,7 +367,7 @@
/**
* Get the sub-modules organization.
*
- * @return the organization.
+ * @return the organization
*/
public String getOrganization() {
return organization;
@@ -375,7 +376,7 @@
/**
* Set the sub-modules organization.
*
- * @param org the organization to set.
+ * @param org the organization to set
*/
public void setOrganization(String org) {
organization = org;
@@ -384,7 +385,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -394,7 +395,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -404,7 +405,7 @@
/**
* Get the revision.
*
- * @return the revision.
+ * @return the revision
*/
public YangRevision getRevision() {
return revision;
@@ -413,7 +414,7 @@
/**
* Set the revision.
*
- * @param revision the revision to set.
+ * @param revision the revision to set
*/
public void setRevision(YangRevision revision) {
this.revision = revision;
@@ -422,7 +423,7 @@
/**
* Get the version.
*
- * @return the version.
+ * @return the version
*/
public byte getVersion() {
return version;
@@ -431,7 +432,7 @@
/**
* Set the version.
*
- * @param version the version to set.
+ * @param version the version to set
*/
public void setVersion(byte version) {
this.version = version;
@@ -440,17 +441,17 @@
/**
* Returns the type of the parsed data.
*
- * @return returns SUB_MODULE_DATA.
+ * @return returns SUB_MODULE_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.SUB_MODULE_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.SUB_MODULE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -460,7 +461,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
@@ -515,4 +516,15 @@
// TODO Auto-generated method stub
}
+
+ @Override
+ public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
+ // Asks helper to detect colliding child.
+ detectCollidingChildUtil(identifierName, dataType, this);
+ }
+
+ @Override
+ public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
+ // Not required as module doesn't have any parent.
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
index 723319d..85db895 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
@@ -18,7 +18,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
@@ -77,7 +77,7 @@
/**
* Get the name of data type.
*
- * @return the name of data type.
+ * @return the name of data type
*/
public String getDataTypeName() {
return dataTypeName;
@@ -95,7 +95,7 @@
/**
* Get the type of data.
*
- * @return the data type.
+ * @return the data type
*/
public YangDataTypes getDataType() {
return dataType;
@@ -104,7 +104,7 @@
/**
* Set the type of data.
*
- * @param dataType data type.
+ * @param dataType data type
*/
public void setDataType(YangDataTypes dataType) {
this.dataType = dataType;
@@ -113,7 +113,7 @@
/**
* Get the data type meta data.
*
- * @return the data type meta data.
+ * @return the data type meta data
*/
public T getDataTypeExtendedInfo() {
return dataTypeExtendedInfo;
@@ -131,17 +131,17 @@
/**
* Returns the type of the parsed data.
*
- * @return returns TYPE_DATA.
+ * @return returns TYPE_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.TYPE_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.TYPE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -152,7 +152,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
index f1250a2..a1abd8b 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
@@ -17,7 +17,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.translator.CachedFileHandle;
/*-
@@ -103,7 +103,7 @@
/**
* Get the default value.
*
- * @return the default value.
+ * @return the default value
*/
public String getDefaultValueInString() {
return defaultValueInString;
@@ -112,7 +112,7 @@
/**
* Set the default value.
*
- * @param defaultValueInString the default value.
+ * @param defaultValueInString the default value
*/
public void setDefaultValueInString(String defaultValueInString) {
this.defaultValueInString = defaultValueInString;
@@ -121,7 +121,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -131,7 +131,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -141,7 +141,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -151,7 +151,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -161,7 +161,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -171,7 +171,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -181,7 +181,7 @@
/**
* Get the derived type.
*
- * @return the derived type.
+ * @return the derived type
*/
public YangType<YangDerivedType> getDerivedType() {
return derivedType;
@@ -190,7 +190,7 @@
/**
* Set the derived type.
*
- * @param derivedType the derived type.
+ * @param derivedType the derived type
*/
public void setDerivedType(YangType<YangDerivedType> derivedType) {
this.derivedType = derivedType;
@@ -220,14 +220,14 @@
* @return returns TYPEDEF_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.TYPEDEF_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.TYPEDEF_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -237,7 +237,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
@@ -274,7 +274,7 @@
/**
* Get the YANG name of the typedef.
*
- * @return YANG name of the typedef.
+ * @return YANG name of the typedef
*/
@Override
public String getName() {
@@ -287,7 +287,7 @@
/**
* Set YANG name of the typedef.
*
- * @param name YANG name of the typedef.
+ * @param name YANG name of the typedef
*/
@Override
public void setName(String name) {
@@ -330,7 +330,7 @@
/**
* Set the mapped java package.
*
- * @param pakg mapped java package.
+ * @param pakg mapped java package
*/
@Override
public void setPackage(String pakg) {
@@ -341,7 +341,7 @@
/**
* Get the file handle of the cached file used during code generation.
*
- * @return cached file handle.
+ * @return cached file handle
*/
@Override
public CachedFileHandle getFileHandle() {
@@ -352,7 +352,7 @@
/**
* Set the file handle to be used used for code generation.
*
- * @param fileHandle cached file handle.
+ * @param fileHandle cached file handle
*/
@Override
public void setFileHandle(CachedFileHandle fileHandle) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
index 5326764..5e6bee4 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
@@ -17,7 +17,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.translator.CachedFileHandle;
/*-
@@ -90,7 +90,7 @@
/**
* Get the name.
*
- * @return the name.
+ * @return the name
*/
public String getRefGroupingName() {
return name;
@@ -108,7 +108,7 @@
/**
* Get the referred group.
*
- * @return the referred group.
+ * @return the referred group
*/
public YangGrouping getRefGroup() {
return refGroup;
@@ -117,7 +117,7 @@
/**
* Set the referred group.
*
- * @param refGroup the referred group.
+ * @param refGroup the referred group
*/
public void setRefGroup(YangGrouping refGroup) {
this.refGroup = refGroup;
@@ -126,7 +126,7 @@
/**
* Get the description.
*
- * @return the description.
+ * @return the description
*/
@Override
public String getDescription() {
@@ -136,7 +136,7 @@
/**
* Set the description.
*
- * @param description set the description.
+ * @param description set the description
*/
@Override
public void setDescription(String description) {
@@ -146,7 +146,7 @@
/**
* Get the textual reference.
*
- * @return the reference.
+ * @return the reference
*/
@Override
public String getReference() {
@@ -156,7 +156,7 @@
/**
* Set the textual reference.
*
- * @param reference the reference to set.
+ * @param reference the reference to set
*/
@Override
public void setReference(String reference) {
@@ -166,7 +166,7 @@
/**
* Get the status.
*
- * @return the status.
+ * @return the status
*/
@Override
public YangStatusType getStatus() {
@@ -176,7 +176,7 @@
/**
* Set the status.
*
- * @param status the status to set.
+ * @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
@@ -186,17 +186,17 @@
/**
* Returns the type of the data.
*
- * @return returns USES_DATA.
+ * @return returns USES_DATA
*/
@Override
- public ParsableDataType getParsableDataType() {
- return ParsableDataType.USES_DATA;
+ public YangConstructType getYangConstructType() {
+ return YangConstructType.USES_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
@@ -206,7 +206,7 @@
/**
* Validate the data on exiting the corresponding parse tree node.
*
- * @throws DataModelException a violation of data model rules.
+ * @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
new file mode 100644
index 0000000..8d94dfe
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.datamodel.utils;
+
+import org.onosproject.yangutils.datamodel.CollisionDetector;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangLeavesHolder;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.utils.YangConstructType;
+
+/**
+ * Utilities for data model tree.
+ */
+public final class DataModelUtils {
+
+ /**
+ * Creates a new data model tree utility.
+ */
+ private DataModelUtils() {
+ }
+
+ /**
+ * Detects the colliding identifier name in a given YANG node and its child.
+ *
+ * @param identifierName name for which collision detection is to be
+ * checked.
+ * @param dataType type of YANG node asking for detecting collision.
+ * @param node instance of calling node.
+ * @throws DataModelException a violation of data model rules.
+ */
+ public static void detectCollidingChildUtil(String identifierName, YangConstructType dataType, YangNode node)
+ throws DataModelException {
+ if (((YangLeavesHolder) node).getListOfLeaf() != null) {
+ for (YangLeaf leaf : ((YangLeavesHolder) node).getListOfLeaf()) {
+ if (leaf.getLeafName().equals(identifierName)) {
+ throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \""
+ + leaf.getLeafName() + "\"");
+ }
+ }
+ }
+ if (((YangLeavesHolder) node).getListOfLeafList() != null) {
+ for (YangLeafList leafList : ((YangLeavesHolder) node).getListOfLeafList()) {
+ if (leafList.getLeafName().equals(identifierName)) {
+ throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " +
+ "list \"" + leafList.getLeafName() + "\"");
+ }
+ }
+ }
+ node = node.getChild();
+ while ((node != null)) {
+ if (node instanceof CollisionDetector) {
+ ((CollisionDetector) node).detectSelfCollision(identifierName, dataType);
+ }
+ node = node.getNextSibling();
+ }
+ }
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/package-info.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/package-info.java
new file mode 100644
index 0000000..c37ed45
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Utilities for checking data model tree collisions.
+ */
+package org.onosproject.yangutils.datamodel.utils;
\ No newline at end of file
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/Parsable.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/Parsable.java
index 2beae10..0d220e57 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/Parsable.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/Parsable.java
@@ -17,6 +17,7 @@
package org.onosproject.yangutils.parser;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.utils.YangConstructType;
/**
* Abstraction of an entity which process the data of lexer's parse tree.
@@ -24,11 +25,11 @@
public interface Parsable {
/**
- * Get the type of parsable data.
+ * Get the type of YANG construct data.
*
- * @return the type of parsable data
+ * @return the type of YANG construct data.
*/
- ParsableDataType getParsableDataType();
+ YangConstructType getYangConstructType();
/**
* Check if the node is valid as per YANG grammar's syntax and semantics.
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/YangUtilsParser.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/YangUtilsParser.java
index 36e9c1d..2bbe70e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/YangUtilsParser.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/YangUtilsParser.java
@@ -29,10 +29,10 @@
/**
* It is an entry function to initiate the YANG file parsing.
*
- * @param file input YANG file.
- * @return YangNode root node of the data model tree.
- * @throws ParserException when fails to get the data model.
- * @throws IOException when there is an exception in IO operation.
+ * @param file input YANG file
+ * @return YangNode root node of the data model tree
+ * @throws ParserException when fails to get the data model
+ * @throws IOException when there is an exception in IO operation
*/
YangNode getDataModel(String file) throws IOException, ParserException;
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
index e2f4d70..e615d13 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
@@ -88,7 +88,7 @@
/**
* Returns root node.
*
- * @return rootNode of data model tree.
+ * @return rootNode of data model tree
*/
public YangNode getRootNode() {
return rootNode;
@@ -97,7 +97,7 @@
/**
* Set parsed data stack.
*
- * @param parsedDataStack stack of parsable data objects.
+ * @param parsedDataStack stack of parsable data objects
*/
public void setParsedDataStack(Stack<Parsable> parsedDataStack) {
this.parsedDataStack = parsedDataStack;
@@ -106,7 +106,7 @@
/**
* Set root node.
*
- * @param rootNode root node of data model tree.
+ * @param rootNode root node of data model tree
*/
public void setRootNode(YangNode rootNode) {
this.rootNode = rootNode;
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListener.java
index 527ce08..99f6807 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListener.java
@@ -22,14 +22,15 @@
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-
-import static org.onosproject.yangutils.parser.ParsableDataType.YANGBASE_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.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CHILD;
+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.checkStackIsEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.utils.YangConstructType.YANGBASE_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -55,8 +56,8 @@
* It is called when parser receives an input matching the grammar rule
* (yangfile), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processYangFileEntry(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) {
@@ -69,8 +70,8 @@
* It is called when parser exits from grammar rule (yangfile), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processYangFileExit(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
index fc9793f..c938190 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
@@ -22,13 +22,14 @@
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-
-import static org.onosproject.yangutils.parser.ParsableDataType.BELONGS_TO_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.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.utils.YangConstructType.BELONGS_TO_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -70,8 +71,8 @@
* It is called when parser receives an input matching the grammar rule
* (belongsto), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processBelongsToEntry(TreeWalkListener listener,
GeneratedYangParser.BelongstoStatementContext ctx) {
@@ -91,8 +92,8 @@
* It is called when parser exits from grammar rule (belongsto), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processBelongsToExit(TreeWalkListener listener,
GeneratedYangParser.BelongstoStatementContext ctx) {
@@ -110,7 +111,7 @@
ctx.IDENTIFIER().getText(), EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case SUB_MODULE_DATA: {
YangSubModule subModule = (YangSubModule) tmpNode;
subModule.setBelongsTo((YangBelongsTo) tmpBelongstoNode);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BitListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BitListener.java
index a574091..b13b3b1 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BitListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BitListener.java
@@ -65,7 +65,7 @@
import org.onosproject.yangutils.datamodel.YangBits;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import static org.onosproject.yangutils.parser.ParsableDataType.BIT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.BIT_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -95,8 +95,8 @@
* It is called when parser enters grammar rule (bit), it perform
* validations and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processBitEntry(TreeWalkListener listener,
GeneratedYangParser.BitStatementContext ctx) {
@@ -113,8 +113,8 @@
* It is called when parser exits from grammar rule (bit), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processBitExit(TreeWalkListener listener,
GeneratedYangParser.BitStatementContext ctx) {
@@ -130,7 +130,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, BIT_DATA, ctx.IDENTIFIER().getText(), EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case BITS_DATA: {
YangBits yangBits = (YangBits) tmpNode;
if ((ctx.bitBodyStatement() == null) || (ctx.bitBodyStatement().positionStatement() == null)) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BitsListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BitsListener.java
index d8f8467..c0c302f 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BitsListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BitsListener.java
@@ -46,8 +46,8 @@
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.parser.Parsable;
-import static org.onosproject.yangutils.parser.ParsableDataType.BITS_DATA;
-import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.BITS_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -75,8 +75,8 @@
* It is called when parser enters grammar rule (bits), it perform
* validations and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processBitsEntry(TreeWalkListener listener,
GeneratedYangParser.BitsSpecificationContext ctx) {
@@ -93,7 +93,7 @@
Parsable tmpData = listener.getParsedDataStack().peek();
- switch (tmpData.getParsableDataType()) {
+ switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
bitsNode.setBitsName(((YangLeaf) tmpData).getLeafName());
break;
@@ -116,8 +116,8 @@
* It is called when parser exits from grammar rule (bits), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processBitsExit(TreeWalkListener listener,
GeneratedYangParser.BitsSpecificationContext ctx) {
@@ -133,7 +133,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, BITS_DATA, "", EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case TYPE_DATA: {
YangType typeNode = (YangType) tmpNode;
typeNode.setDataTypeExtendedInfo((YangBits) tmpBitsNode);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListener.java
index 49c0348..68d2b43 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListener.java
@@ -24,13 +24,12 @@
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-
-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;
+import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -62,8 +61,8 @@
* It is called when parser receives an input matching the grammar rule
* (config), performs validation and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processConfigEntry(TreeWalkListener listener,
GeneratedYangParser.ConfigStatementContext ctx) {
@@ -77,7 +76,7 @@
}
Parsable tmpData = listener.getParsedDataStack().peek();
- switch (tmpData.getParsableDataType()) {
+ switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
YangLeaf leaf = (YangLeaf) tmpData;
leaf.setConfig(isConfig);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContactListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContactListener.java
index 53c86cb..f1d670a 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContactListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContactListener.java
@@ -23,7 +23,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.CONTACT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.CONTACT_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;
@@ -86,8 +86,8 @@
* It is called when parser receives an input matching the grammar rule
* (contact), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processContactEntry(TreeWalkListener listener, GeneratedYangParser.ContactStatementContext ctx) {
@@ -96,7 +96,7 @@
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.setContact(ctx.string().getText());
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListener.java
index 2325be3..1f23449 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListener.java
@@ -22,24 +22,27 @@
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.ListenerValidation;
-
-import static org.onosproject.yangutils.parser.ParsableDataType.CONTAINER_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
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.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_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 org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
+import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.CONTAINER_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.PRESENCE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -76,8 +79,6 @@
*/
public final class ContainerListener {
- private static ParsableDataType yangConstruct;
-
/**
* Creates a new container listener.
*/
@@ -85,30 +86,34 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (container), performs validation and updates the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (container), performs validation and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processContainerEntry(TreeWalkListener listener,
- GeneratedYangParser.ContainerStatementContext ctx) {
+ GeneratedYangParser.ContainerStatementContext ctx) {
- YangNode parentNode;
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY);
- boolean result = validateSubStatementsCardinality(ctx);
- if (!result) {
- throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
- }
+ // Validate sub statement cardinality.
+ validateSubStatementsCardinality(ctx);
+
+ // Check for identifier collision
+ int line = ctx.IDENTIFIER().getSymbol().getLine();
+ int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine();
+ String identifierName = ctx.IDENTIFIER().getText();
+ detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, CONTAINER_DATA);
YangContainer container = new YangContainer();
container.setName(ctx.IDENTIFIER().getText());
- /* If "config" is not specified, the default is the same as the parent
- schema node's "config" value. */
+ /*
+ * If "config" is not specified, the default is the same as the parent
+ * schema node's "config" value.
+ */
if (ctx.configStatement().isEmpty()) {
boolean parentConfig = ListenerValidation.getParentNodeConfig(listener);
container.setConfig(parentConfig);
@@ -122,7 +127,7 @@
curNode.addChild(container);
} catch (DataModelException e) {
throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
- CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY, e.getMessage()));
+ CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY, e.getMessage()));
}
listener.getParsedDataStack().push(container);
} else {
@@ -135,11 +140,11 @@
* It is called when parser exits from grammar rule (container), it perform
* validations and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processContainerExit(TreeWalkListener listener,
- GeneratedYangParser.ContainerStatementContext ctx) {
+ GeneratedYangParser.ContainerStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), EXIT);
@@ -155,48 +160,22 @@
listener.getParsedDataStack().pop();
} else {
throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, CONTAINER_DATA,
- ctx.IDENTIFIER().getText(), EXIT));
+ ctx.IDENTIFIER().getText(), EXIT));
}
}
/**
* Validates the cardinality of container sub-statements as per grammar.
*
- * @param ctx context object of the grammar rule.
- * @return true/false validation success or failure.
+ * @param ctx context object of the grammar rule
*/
- private static boolean validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) {
+ private static void validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) {
- if ((!ctx.presenceStatement().isEmpty())
- && (ctx.presenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.PRESENCE_DATA;
- return false;
- }
-
- if ((!ctx.configStatement().isEmpty())
- && (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.CONFIG_DATA;
- return false;
- }
-
- if ((!ctx.descriptionStatement().isEmpty())
- && (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.DESCRIPTION_DATA;
- return false;
- }
-
- if ((!ctx.referenceStatement().isEmpty())
- && (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.REFERENCE_DATA;
- return false;
- }
-
- if ((!ctx.statusStatement().isEmpty())
- && (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.STATUS_DATA;
- return false;
- }
-
- return true;
+ validateCardinality(ctx.presenceStatement(), PRESENCE_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.configStatement(), CONFIG_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.statusStatement(), STATUS_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText());
+ // TODO when, grouping, typedef.
}
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListener.java
index f500cca..42b3cc4 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListener.java
@@ -45,7 +45,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.DEFAULT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.DEFAULT_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.MISSING_HOLDER;
@@ -64,8 +64,8 @@
* It is called when parser enters grammar rule (default), it perform
* validations and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processDefaultEntry(TreeWalkListener listener,
GeneratedYangParser.DefaultStatementContext ctx) {
@@ -74,7 +74,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, DEFAULT_DATA, ctx.string().getText(), ENTRY);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case TYPEDEF_DATA: {
YangTypeDef typeDef = (YangTypeDef) tmpNode;
typeDef.setDefaultValueInString(ctx.string().getText());
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListener.java
index 1befa54..e27c618 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListener.java
@@ -22,7 +22,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.DESCRIPTION_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.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;
@@ -56,8 +56,8 @@
* rule (description), perform validations and updates the data model
* tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processDescriptionEntry(TreeWalkListener listener,
GeneratedYangParser.DescriptionStatementContext ctx) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumListener.java
index e255441..1d45a5e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumListener.java
@@ -64,7 +64,7 @@
import org.onosproject.yangutils.datamodel.YangEnumeration;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import static org.onosproject.yangutils.parser.ParsableDataType.ENUM_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.ENUM_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -94,8 +94,8 @@
* It is called when parser enters grammar rule (enum), it perform
* validations and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processEnumEntry(TreeWalkListener listener, GeneratedYangParser.EnumStatementContext ctx) {
@@ -111,8 +111,8 @@
* It is called when parser exits from grammar rule (enum), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processEnumExit(TreeWalkListener listener, GeneratedYangParser.EnumStatementContext ctx) {
@@ -127,7 +127,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, ENUM_DATA, ctx.string().getText(), EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case ENUMERATION_DATA: {
YangEnumeration yangEnumeration = (YangEnumeration) tmpNode;
if ((ctx.enumStatementBody() == null) || (ctx.enumStatementBody().valueStatement() == null)) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumerationListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumerationListener.java
index f83c49c..5f98fa4 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumerationListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumerationListener.java
@@ -46,8 +46,8 @@
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.parser.Parsable;
-import static org.onosproject.yangutils.parser.ParsableDataType.ENUMERATION_DATA;
-import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.ENUMERATION_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -76,8 +76,8 @@
* It is called when parser enters grammar rule (enumeration), it perform
* validations and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processEnumerationEntry(TreeWalkListener listener,
GeneratedYangParser.EnumSpecificationContext ctx) {
@@ -94,7 +94,7 @@
Parsable tmpData = listener.getParsedDataStack().peek();
- switch (tmpData.getParsableDataType()) {
+ switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
enumerationNode.setEnumerationName(((YangLeaf) tmpData).getLeafName());
break;
@@ -117,8 +117,8 @@
* It is called when parser exits from grammar rule (enumeration), it
* perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processEnumerationExit(TreeWalkListener listener,
GeneratedYangParser.EnumSpecificationContext ctx) {
@@ -134,7 +134,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, ENUMERATION_DATA, "", EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case TYPE_DATA: {
YangType typeNode = (YangType) tmpNode;
typeNode.setDataTypeExtendedInfo((YangEnumeration) tmpEnumerationNode);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java
index 1f5e113..bd120ad 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java
@@ -23,13 +23,14 @@
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-
-import static org.onosproject.yangutils.parser.ParsableDataType.IMPORT_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.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.utils.YangConstructType.IMPORT_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -69,8 +70,8 @@
* It is called when parser receives an input matching the grammar rule
* (import), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processImportEntry(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) {
@@ -88,8 +89,8 @@
* It is called when parser exits from grammar rule (import), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processImportExit(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) {
@@ -105,7 +106,7 @@
EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.addImportedInfo((YangImport) tmpImportNode);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java
index 533db1f..6e28ada 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java
@@ -23,13 +23,14 @@
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-
-import static org.onosproject.yangutils.parser.ParsableDataType.INCLUDE_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.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.utils.YangConstructType.INCLUDE_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -68,8 +69,8 @@
* It is called when parser receives an input matching the grammar rule
* (include), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processIncludeEntry(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) {
@@ -87,8 +88,8 @@
* It is called when parser exits from grammar rule (include), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processIncludeExit(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) {
@@ -104,7 +105,7 @@
EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.addIncludedInfo((YangInclude) tmpIncludeNode);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/KeyListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/KeyListener.java
index 268d535..d3472aa 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/KeyListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/KeyListener.java
@@ -23,7 +23,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.KEY_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.KEY_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.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
@@ -59,8 +59,8 @@
* rule (key), perform validations and updates the data model
* tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processKeyEntry(TreeWalkListener listener,
GeneratedYangParser.KeyStatementContext ctx) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java
index 1ada6dd..896e8ec 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java
@@ -19,21 +19,28 @@
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangLeavesHolder;
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 static org.onosproject.yangutils.parser.ParsableDataType.LEAF_LIST_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
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.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne;
+import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.LEAF_LIST_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.MIN_ELEMENT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.UNITS_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -68,8 +75,6 @@
*/
public final class LeafListListener {
- private static ParsableDataType yangConstruct;
-
/**
* Creates a new leaf list listener.
*/
@@ -77,23 +82,26 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (leaf-list), performs validation and updates the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (leaf-list), performs validation and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processLeafListEntry(TreeWalkListener listener,
- GeneratedYangParser.LeafListStatementContext ctx) {
+ GeneratedYangParser.LeafListStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY);
- boolean result = validateSubStatementsCardinality(ctx);
- if (!result) {
- throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
- }
+ // Validate sub statement cardinality.
+ validateSubStatementsCardinality(ctx);
+
+ // Check for identifier collision
+ int line = ctx.IDENTIFIER().getSymbol().getLine();
+ int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine();
+ String identifierName = ctx.IDENTIFIER().getText();
+ detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, LEAF_LIST_DATA);
YangLeafList leafList = new YangLeafList();
leafList.setLeafName(ctx.IDENTIFIER().getText());
@@ -106,7 +114,7 @@
leaves.addLeafList(leafList);
} else {
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_LIST_DATA,
- ctx.IDENTIFIER().getText(), ENTRY));
+ ctx.IDENTIFIER().getText(), ENTRY));
}
listener.getParsedDataStack().push(leafList);
}
@@ -115,11 +123,11 @@
* It is called when parser exits from grammar rule (leaf-list), it performs
* validation and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processLeafListExit(TreeWalkListener listener,
- GeneratedYangParser.LeafListStatementContext ctx) {
+ GeneratedYangParser.LeafListStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), EXIT);
@@ -136,59 +144,17 @@
* Validates the cardinality of leaf-list sub-statements as per grammar.
*
* @param ctx context object of the grammar rule.
- * @return true/false validation success or failure.
*/
- private static boolean validateSubStatementsCardinality(GeneratedYangParser
- .LeafListStatementContext ctx) {
+ private static void validateSubStatementsCardinality(GeneratedYangParser.LeafListStatementContext ctx) {
- if (ctx.typeStatement().isEmpty()
- || (ctx.typeStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.TYPE_DATA;
- return false;
- }
-
- if ((!ctx.unitsStatement().isEmpty())
- && (ctx.unitsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.UNITS_DATA;
- return false;
- }
-
- if ((!ctx.configStatement().isEmpty())
- && (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.CONFIG_DATA;
- return false;
- }
-
- if ((!ctx.maxElementsStatement().isEmpty())
- && (ctx.maxElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.MAX_ELEMENT_DATA;
- return false;
- }
-
- if ((!ctx.minElementsStatement().isEmpty())
- && (ctx.minElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.MIN_ELEMENT_DATA;
- return false;
- }
-
- if ((!ctx.descriptionStatement().isEmpty())
- && (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.DESCRIPTION_DATA;
- return false;
- }
-
- if ((!ctx.referenceStatement().isEmpty())
- && (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.REFERENCE_DATA;
- return false;
- }
-
- if ((!ctx.statusStatement().isEmpty())
- && (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.STATUS_DATA;
- return false;
- }
-
- return true;
+ validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.unitsStatement(), UNITS_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.configStatement(), CONFIG_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.maxElementsStatement(), MAX_ELEMENT_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.minElementsStatement(), MIN_ELEMENT_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.statusStatement(), STATUS_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
+ //TODO ordered by
}
-}
\ No newline at end of file
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java
index 81e9e1c..226f621 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java
@@ -21,23 +21,29 @@
package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeavesHolder;
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.datamodel.YangLeavesHolder;
-import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
-
-import static org.onosproject.yangutils.parser.ParsableDataType.LEAF_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
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.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne;
+import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.LEAF_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.MANDATORY_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.UNITS_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -66,13 +72,11 @@
*/
/**
- * Implements listener based call back function corresponding to the "leaf"
- * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
+ * Implements listener based call back function corresponding to the "leaf" rule
+ * defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
*/
public final class LeafListener {
- private static ParsableDataType yangConstruct;
-
/**
* Creates a new leaf listener.
*/
@@ -80,23 +84,26 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (leaf), performs validation and updates the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (leaf), performs validation and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processLeafEntry(TreeWalkListener listener,
- GeneratedYangParser.LeafStatementContext ctx) {
+ GeneratedYangParser.LeafStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), ENTRY);
- boolean result = validateSubStatementsCardinality(ctx);
- if (!result) {
- throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
- }
+ // Validate sub statement cardinality.
+ validateSubStatementsCardinality(ctx);
+
+ // Check for identifier collision
+ int line = ctx.IDENTIFIER().getSymbol().getLine();
+ int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine();
+ String identifierName = ctx.IDENTIFIER().getText();
+ detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, LEAF_DATA);
YangLeaf leaf = new YangLeaf();
leaf.setLeafName(ctx.IDENTIFIER().getText());
@@ -123,7 +130,7 @@
* @param ctx context object of the grammar rule.
*/
public static void processLeafExit(TreeWalkListener listener,
- GeneratedYangParser.LeafStatementContext ctx) {
+ GeneratedYangParser.LeafStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), EXIT);
@@ -132,7 +139,7 @@
listener.getParsedDataStack().pop();
} else {
throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_DATA,
- ctx.IDENTIFIER().getText(), EXIT));
+ ctx.IDENTIFIER().getText(), EXIT));
}
}
@@ -140,53 +147,16 @@
* Validates the cardinality of leaf sub-statements as per grammar.
*
* @param ctx context object of the grammar rule.
- * @return true/false validation success or failure.
*/
- private static boolean validateSubStatementsCardinality(GeneratedYangParser
- .LeafStatementContext ctx) {
+ private static void validateSubStatementsCardinality(GeneratedYangParser.LeafStatementContext ctx) {
- if (ctx.typeStatement().isEmpty()
- || (ctx.typeStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.TYPE_DATA;
- return false;
- }
-
- if ((!ctx.unitsStatement().isEmpty())
- && (ctx.unitsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.UNITS_DATA;
- return false;
- }
-
- if ((!ctx.configStatement().isEmpty())
- && (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.CONFIG_DATA;
- return false;
- }
-
- if ((!ctx.mandatoryStatement().isEmpty())
- && (ctx.mandatoryStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.MANDATORY_DATA;
- return false;
- }
-
- if ((!ctx.descriptionStatement().isEmpty())
- && (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.DESCRIPTION_DATA;
- return false;
- }
-
- if ((!ctx.referenceStatement().isEmpty())
- && (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.REFERENCE_DATA;
- return false;
- }
-
- if ((!ctx.statusStatement().isEmpty())
- && (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.STATUS_DATA;
- return false;
- }
-
- return true;
+ validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.unitsStatement(), UNITS_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.configStatement(), CONFIG_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.mandatoryStatement(), MANDATORY_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.statusStatement(), STATUS_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
+ //TODO when.
}
-}
\ No newline at end of file
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ListListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ListListener.java
index 2319b8e..7692025 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ListListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ListListener.java
@@ -16,31 +16,38 @@
package org.onosproject.yangutils.parser.impl.listeners;
-import org.onosproject.yangutils.datamodel.YangList;
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.YangNodeType;
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.ListenerValidation;
-
-import static org.onosproject.yangutils.parser.ParsableDataType.LIST_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
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.constructExtendedListenerErrorMessage;
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_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_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 org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonNull;
+import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.DATA_DEF_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.KEY_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.LIST_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.MIN_ELEMENT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -74,13 +81,11 @@
*/
/**
- * Implements listener based call back function corresponding to the "list"
- * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
+ * Implements listener based call back function corresponding to the "list" rule
+ * defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
*/
public final class ListListener {
- private static ParsableDataType yangConstruct;
-
/**
* Creates a new list listener.
*/
@@ -88,30 +93,35 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (list), performs validation and updates the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (list), performs validation and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processListEntry(TreeWalkListener listener,
- GeneratedYangParser.ListStatementContext ctx) {
+ GeneratedYangParser.ListStatementContext ctx) {
YangNode curNode;
checkStackIsNotEmpty(listener, MISSING_HOLDER, LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY);
- boolean result = validateSubStatementsCardinality(ctx);
- if (!result) {
- throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
- }
+ // Validate sub statement cardinality.
+ validateSubStatementsCardinality(ctx);
+
+ // Check for identifier collision
+ int line = ctx.IDENTIFIER().getSymbol().getLine();
+ int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine();
+ String identifierName = ctx.IDENTIFIER().getText();
+ detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, LIST_DATA);
YangList yangList = new YangList(YangNodeType.LIST_NODE);
yangList.setName(ctx.IDENTIFIER().getText());
- /* If "config" is not specified, the default is the same as the parent
- schema node's "config" value. */
+ /*
+ * If "config" is not specified, the default is the same as the parent
+ * schema node's "config" value.
+ */
if (ctx.configStatement().isEmpty()) {
boolean parentConfig = ListenerValidation.getParentNodeConfig(listener);
yangList.setConfig(parentConfig);
@@ -130,7 +140,7 @@
listener.getParsedDataStack().push(yangList);
} else {
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LIST_DATA,
- ctx.IDENTIFIER().getText(), ENTRY));
+ ctx.IDENTIFIER().getText(), ENTRY));
}
}
@@ -138,11 +148,11 @@
* It is called when parser exits from grammar rule (list), it performs
* validation and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processListExit(TreeWalkListener listener,
- GeneratedYangParser.ListStatementContext ctx) {
+ GeneratedYangParser.ListStatementContext ctx) {
checkStackIsNotEmpty(listener, MISSING_HOLDER, LIST_DATA, ctx.IDENTIFIER().getText(), EXIT);
@@ -157,65 +167,25 @@
listener.getParsedDataStack().pop();
} else {
throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LIST_DATA,
- ctx.IDENTIFIER().getText(), EXIT));
+ ctx.IDENTIFIER().getText(), EXIT));
}
}
/**
* Validates the cardinality of list sub-statements as per grammar.
*
- * @param ctx context object of the grammar rule.
- * @return true/false validation success or failure.
+ * @param ctx context object of the grammar rule
*/
- private static boolean validateSubStatementsCardinality(GeneratedYangParser.ListStatementContext ctx) {
+ private static void validateSubStatementsCardinality(GeneratedYangParser.ListStatementContext ctx) {
- if ((!ctx.keyStatement().isEmpty())
- && (ctx.keyStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.KEY_DATA;
- return false;
- }
-
- if ((!ctx.configStatement().isEmpty())
- && (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.CONFIG_DATA;
- return false;
- }
-
- if ((!ctx.maxElementsStatement().isEmpty())
- && (ctx.maxElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.MAX_ELEMENT_DATA;
- return false;
- }
-
- if ((!ctx.minElementsStatement().isEmpty())
- && (ctx.minElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.MIN_ELEMENT_DATA;
- return false;
- }
-
- if ((!ctx.descriptionStatement().isEmpty())
- && (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.DESCRIPTION_DATA;
- return false;
- }
-
- if ((!ctx.referenceStatement().isEmpty())
- && (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.REFERENCE_DATA;
- return false;
- }
-
- if ((!ctx.statusStatement().isEmpty())
- && (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = ParsableDataType.STATUS_DATA;
- return false;
- }
-
- if (ctx.dataDefStatement().isEmpty()) {
- yangConstruct = ParsableDataType.LIST_DATA;
- return false;
- }
-
- return true;
+ validateCardinality(ctx.keyStatement(), KEY_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.configStatement(), CONFIG_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.maxElementsStatement(), MAX_ELEMENT_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.minElementsStatement(), MIN_ELEMENT_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.statusStatement(), STATUS_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
+ validateCardinalityNonNull(ctx.dataDefStatement(), DATA_DEF_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
+ //TODO when, typedef, grouping, unique
}
-}
\ No newline at end of file
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListener.java
index 2e118ce..ea33cd7 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListener.java
@@ -22,7 +22,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.MANDATORY_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.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;
@@ -62,8 +62,8 @@
* rule (mandatory), performs validation and updates the data model
* tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processMandatoryEntry(TreeWalkListener listener,
GeneratedYangParser.MandatoryStatementContext ctx) {
@@ -72,7 +72,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, MANDATORY_DATA, "", ENTRY);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case LEAF_DATA:
YangLeaf leaf = (YangLeaf) tmpNode;
if (ctx.TRUE_KEYWORD() != null) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListener.java
index bf59311..72ba44d 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListener.java
@@ -23,7 +23,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.MAX_ELEMENT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.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;
@@ -60,8 +60,8 @@
* rule (max-elements), performs validation and updates the data model
* tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processMaxElementsEntry(TreeWalkListener listener,
GeneratedYangParser.MaxElementsStatementContext ctx) {
@@ -77,7 +77,7 @@
}
Parsable tmpData = listener.getParsedDataStack().peek();
- switch (tmpData.getParsableDataType()) {
+ switch (tmpData.getYangConstructType()) {
case LEAF_LIST_DATA:
YangLeafList leafList = (YangLeafList) tmpData;
leafList.setMaxElelements(maxElementsValue);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListener.java
index 8e1e2f7..a89c6ce 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListener.java
@@ -23,7 +23,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.MIN_ELEMENT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.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;
@@ -61,8 +61,8 @@
* rule (min-elements), performs validation and updates the data model
* tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processMinElementsEntry(TreeWalkListener listener,
GeneratedYangParser.MinElementsStatementContext ctx) {
@@ -71,7 +71,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, MIN_ELEMENT_DATA, ctx.INTEGER().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
- switch (tmpData.getParsableDataType()) {
+ switch (tmpData.getYangConstructType()) {
case LEAF_LIST_DATA:
YangLeafList leafList = (YangLeafList) tmpData;
leafList.setMinElements(Integer.parseInt(ctx.INTEGER().getText()));
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
index 8e808a2..f4f6ef5 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
@@ -20,14 +20,15 @@
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-
-import static org.onosproject.yangutils.parser.ParsableDataType.MODULE_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.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.utils.YangConstructType.MODULE_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -63,8 +64,8 @@
* It is called when parser receives an input matching the grammar rule
* (module), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processModuleEntry(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
@@ -74,6 +75,10 @@
YangModule yangModule = new YangModule();
yangModule.setName(ctx.IDENTIFIER().getText());
+ if (ctx.moduleBody(0).moduleHeaderStatement().yangVersionStatement() == null) {
+ yangModule.setVersion((byte) 1);
+ }
+
listener.getParsedDataStack().push(yangModule);
}
@@ -81,8 +86,8 @@
* It is called when parser exits from grammar rule (module), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processModuleExit(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListener.java
index 4030ada..a2cf36c 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListener.java
@@ -25,7 +25,7 @@
import java.net.URI;
-import static org.onosproject.yangutils.parser.ParsableDataType.NAMESPACE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.NAMESPACE_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;
@@ -70,8 +70,8 @@
* It is called when parser receives an input matching the grammar rule
* (namespace), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processNamespaceEntry(TreeWalkListener listener,
GeneratedYangParser.NamespaceStatementContext ctx) {
@@ -80,7 +80,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, NAMESPACE_DATA, ctx.string().getText(), ENTRY);
if (!validateUriValue(ctx.string().getText())) {
- ParserException parserException = new ParserException("Invalid namespace URI");
+ ParserException parserException = new ParserException("YANG file error: Invalid namespace URI");
parserException.setLine(ctx.string().STRING(0).getSymbol().getLine());
parserException.setCharPosition(ctx.string().STRING(0).getSymbol().getCharPositionInLine());
throw parserException;
@@ -88,7 +88,7 @@
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
YangNameSpace uri = new YangNameSpace();
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListener.java
index ab8681c..d0525c0 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListener.java
@@ -23,7 +23,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.ORGANIZATION_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.ORGANIZATION_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;
@@ -88,8 +88,8 @@
* It is called when parser receives an input matching the grammar rule
* (organization), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processOrganizationEntry(TreeWalkListener listener,
GeneratedYangParser.OrganizationStatementContext ctx) {
@@ -100,7 +100,7 @@
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.setOrganization(ctx.string().getText());
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PositionListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PositionListener.java
index 92b3e68..41835d6 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PositionListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PositionListener.java
@@ -36,7 +36,7 @@
import org.onosproject.yangutils.datamodel.YangBit;
import org.onosproject.yangutils.datamodel.YangBits;
import org.onosproject.yangutils.parser.Parsable;
-import static org.onosproject.yangutils.parser.ParsableDataType.POSITION_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.POSITION_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -65,8 +65,8 @@
* It is called when parser receives an input matching the grammar rule
* (position), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processPositionEntry(TreeWalkListener listener,
GeneratedYangParser.PositionStatementContext ctx) {
@@ -76,7 +76,7 @@
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case BIT_DATA: {
YangBit bitNode = (YangBit) tmpNode;
if (!isBitPositionValid(listener, ctx)) {
@@ -97,8 +97,8 @@
/**
* Validates BITS position value correctness and uniqueness.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
* @return validation result
*/
private static boolean isBitPositionValid(TreeWalkListener listener,
@@ -109,18 +109,18 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, POSITION_DATA, ctx.INTEGER().getText(), ENTRY);
if (Integer.valueOf(ctx.INTEGER().getText()) < 0) {
- errMsg = "Negative value of position is invalid";
+ errMsg = "YANG file error: Negative value of position is invalid.";
listener.getParsedDataStack().push(bitNode);
return false;
}
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case BITS_DATA: {
YangBits yangBits = (YangBits) tmpNode;
for (YangBit curBit : yangBits.getBitSet()) {
if (Integer.valueOf(ctx.INTEGER().getText()) == curBit.getPosition()) {
- errMsg = "Duplicate value of position is invalid";
+ errMsg = "YANG file error: Duplicate value of position is invalid.";
listener.getParsedDataStack().push(bitNode);
return false;
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListener.java
index 6b6db62..e59cda0 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListener.java
@@ -24,7 +24,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.PREFIX_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.PREFIX_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;
@@ -70,8 +70,8 @@
* It is called when parser receives an input matching the grammar rule
* (prefix),perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processPrefixEntry(TreeWalkListener listener, GeneratedYangParser.PrefixStatementContext ctx) {
@@ -80,7 +80,7 @@
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.setPrefix(ctx.IDENTIFIER().getText());
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListener.java
index a771307..74e40b1 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListener.java
@@ -22,8 +22,8 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.PRESENCE_DATA;
-import static org.onosproject.yangutils.parser.ParsableDataType.CONTAINER_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.PRESENCE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.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;
@@ -57,8 +57,8 @@
* rule (presence), performs validation and updates the data model
* tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processPresenceEntry(TreeWalkListener listener,
GeneratedYangParser.PresenceStatementContext ctx) {
@@ -67,7 +67,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, PRESENCE_DATA, ctx.string().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
- if (tmpData.getParsableDataType() == CONTAINER_DATA) {
+ if (tmpData.getYangConstructType() == CONTAINER_DATA) {
YangContainer container = (YangContainer) tmpData;
container.setPresence(ctx.string().getText());
} else {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListener.java
index 6e83e86..aaca80c 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListener.java
@@ -22,7 +22,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.REFERENCE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.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;
@@ -56,8 +56,8 @@
* rule (reference), performs validation and updates the data model
* tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processReferenceEntry(TreeWalkListener listener,
GeneratedYangParser.ReferenceStatementContext ctx) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java
index bef6f8e3..17fe6b7 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java
@@ -27,7 +27,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
-import static org.onosproject.yangutils.parser.ParsableDataType.REVISION_DATE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.REVISION_DATE_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;
@@ -79,8 +79,8 @@
* It is called when parser receives an input matching the grammar rule
* (revision date),perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processRevisionDateEntry(TreeWalkListener listener,
GeneratedYangParser.RevisionDateStatementContext ctx) {
@@ -90,7 +90,7 @@
ENTRY);
if (!isDateValid(ctx.DATE_ARG().getText())) {
- ParserException parserException = new ParserException("Input date is not correct");
+ ParserException parserException = new ParserException("YANG file error: Input date is not correct");
parserException.setLine(ctx.DATE_ARG().getSymbol().getLine());
parserException.setCharPosition(ctx.DATE_ARG().getSymbol().getCharPositionInLine());
throw parserException;
@@ -98,7 +98,7 @@
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case IMPORT_DATA: {
YangImport importNode = (YangImport) tmpNode;
importNode.setRevision(ctx.DATE_ARG().getText());
@@ -118,8 +118,8 @@
/**
* Validates the revision date.
*
- * @param dateToValidate input revision date.
- * @return validation result, true for success, false for failure.
+ * @param dateToValidate input revision date
+ * @return validation result, true for success, false for failure
*/
private static boolean isDateValid(String dateToValidate) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java
index a135891..32675cd 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java
@@ -24,13 +24,19 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.REVISION_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
+import static org.onosproject.yangutils.utils.YangConstructType.REVISION_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.*;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
/*
* Reference: RFC6020 and YANG ANTLR Grammar
*
@@ -75,8 +81,8 @@
* It is called when parser receives an input matching the grammar rule
* (revision),perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processRevisionEntry(TreeWalkListener listener,
GeneratedYangParser.RevisionStatementContext ctx) {
@@ -91,6 +97,13 @@
// TODO to be implemented.
}
+ if (!isDateValid(ctx.DATE_ARG().getText())) {
+ ParserException parserException = new ParserException("YANG file error: Input date is not correct");
+ parserException.setLine(ctx.DATE_ARG().getSymbol().getLine());
+ parserException.setCharPosition(ctx.DATE_ARG().getSymbol().getCharPositionInLine());
+ throw parserException;
+ }
+
YangRevision revisionNode = new YangRevision();
revisionNode.setRevDate(ctx.DATE_ARG().getText());
@@ -101,8 +114,8 @@
* It is called when parser exits from grammar rule (revision), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processRevisionExit(TreeWalkListener listener, GeneratedYangParser.RevisionStatementContext
ctx) {
@@ -119,7 +132,7 @@
EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.setRevision((YangRevision) tmpRevisionNode);
@@ -144,8 +157,8 @@
/**
* Validate revision.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
* @return validation result
*/
private static boolean validateRevision(TreeWalkListener listener,
@@ -153,4 +166,29 @@
// TODO to be implemented
return true;
}
+
+ /**
+ * Validates the revision date.
+ *
+ * @param dateToValidate input revision date
+ * @return validation result, true for success, false for failure
+ */
+ private static boolean isDateValid(String dateToValidate) {
+
+ if (dateToValidate == null) {
+ return false;
+ }
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ sdf.setLenient(false);
+
+ try {
+ //if not valid, it will throw ParseException
+ Date date = sdf.parse(dateToValidate);
+ System.out.println(date);
+ } catch (ParseException e) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/StatusListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/StatusListener.java
index 82cdabd..379994e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/StatusListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/StatusListener.java
@@ -23,7 +23,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.STATUS_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.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;
@@ -62,8 +62,8 @@
* rule (status), performs validation and updates the data model
* tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processStatusEntry(TreeWalkListener listener,
GeneratedYangParser.StatusStatementContext ctx) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
index b577bcf..4f8a64e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
@@ -20,14 +20,15 @@
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-
-import static org.onosproject.yangutils.parser.ParsableDataType.SUB_MODULE_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.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.utils.YangConstructType.SUB_MODULE_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -64,8 +65,8 @@
* It is called when parser receives an input matching the grammar rule (sub
* module), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processSubModuleEntry(TreeWalkListener listener,
GeneratedYangParser.SubModuleStatementContext ctx) {
@@ -77,6 +78,10 @@
YangSubModule yangSubModule = new YangSubModule();
yangSubModule.setName(ctx.IDENTIFIER().getText());
+ if (ctx.submoduleBody(0).submoduleHeaderStatement().yangVersionStatement() == null) {
+ yangSubModule.setVersion((byte) 1);
+ }
+
listener.getParsedDataStack().push(yangSubModule);
}
@@ -84,8 +89,8 @@
* It is called when parser exits from grammar rule (submodule), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processSubModuleExit(TreeWalkListener listener,
GeneratedYangParser.SubModuleStatementContext ctx) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeDefListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeDefListener.java
index 5373232..5ba9780 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeDefListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeDefListener.java
@@ -58,24 +58,23 @@
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne;
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 static org.onosproject.yangutils.parser.ParsableDataType.DEFAULT_DATA;
-import static org.onosproject.yangutils.parser.ParsableDataType.DESCRIPTION_DATA;
-import static org.onosproject.yangutils.parser.ParsableDataType.REFERENCE_DATA;
-import static org.onosproject.yangutils.parser.ParsableDataType.STATUS_DATA;
-import static org.onosproject.yangutils.parser.ParsableDataType.TYPEDEF_DATA;
-import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
-import static org.onosproject.yangutils.parser.ParsableDataType.UNITS_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.DEFAULT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.TYPEDEF_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.UNITS_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.constructExtendedListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
@@ -88,8 +87,6 @@
*/
public final class TypeDefListener {
- private static ParsableDataType yangConstruct;
-
/**
* Creates a new typedef listener.
*/
@@ -100,8 +97,8 @@
* It is called when parser enters grammar rule (typedef), it perform
* validations and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processTypeDefEntry(TreeWalkListener listener,
GeneratedYangParser.TypedefStatementContext ctx) {
@@ -109,10 +106,8 @@
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPEDEF_DATA, ctx.IDENTIFIER().getText(), ENTRY);
- boolean result = validateSubStatementsCardinality(ctx);
- if (!result) {
- throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
- }
+ // Validate sub statement cardinality.
+ validateSubStatementsCardinality(ctx);
/*
* Create a derived type information, the base type must be set in type
@@ -150,8 +145,8 @@
* It is called when parser exits from grammar rule (typedef), it perform
* validations and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processTypeDefExit(TreeWalkListener listener,
GeneratedYangParser.TypedefStatementContext ctx) {
@@ -178,45 +173,15 @@
/**
* Validates the cardinality of typedef sub-statements as per grammar.
*
- * @param ctx context object of the grammar rule.
- * @return true/false validation success or failure.
+ * @param ctx context object of the grammar rule
*/
- private static boolean validateSubStatementsCardinality(GeneratedYangParser.TypedefStatementContext ctx) {
+ private static void validateSubStatementsCardinality(GeneratedYangParser.TypedefStatementContext ctx) {
- if ((!ctx.unitsStatement().isEmpty())
- && (ctx.unitsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = UNITS_DATA;
- return false;
- }
-
- if ((!ctx.defaultStatement().isEmpty())
- && (ctx.defaultStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = DEFAULT_DATA;
- return false;
- }
-
- if (ctx.typeStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY) {
- yangConstruct = TYPE_DATA;
- return false;
- }
-
- if ((!ctx.descriptionStatement().isEmpty())
- && (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = DESCRIPTION_DATA;
- return false;
- }
-
- if ((!ctx.referenceStatement().isEmpty())
- && (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = REFERENCE_DATA;
- return false;
- }
-
- if ((!ctx.statusStatement().isEmpty())
- && (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
- yangConstruct = STATUS_DATA;
- return false;
- }
- return true;
+ validateCardinality(ctx.unitsStatement(), UNITS_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.defaultStatement(), DEFAULT_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText());
+ validateCardinality(ctx.statusStatement(), STATUS_DATA, TYPEDEF_DATA, ctx.IDENTIFIER().getText());
}
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
index 891a982..18a7aef 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
@@ -27,7 +27,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.TYPE_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;
@@ -66,8 +66,8 @@
* It is called when parser receives an input matching the grammar rule
* (type), performs validation and updates the data model tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processTypeEntry(TreeWalkListener listener,
GeneratedYangParser.TypeStatementContext ctx) {
@@ -88,8 +88,8 @@
* It is called when parser exits from grammar rule (type), it perform
* validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processTypeExit(TreeWalkListener listener,
GeneratedYangParser.TypeStatementContext ctx) {
@@ -107,7 +107,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPE_DATA, ctx.string().getText(), EXIT);
Parsable tmpData = listener.getParsedDataStack().peek();
- switch (tmpData.getParsableDataType()) {
+ switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
YangLeaf leaf = (YangLeaf) tmpData;
leaf.setDataType((YangType) type);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListener.java
index 6a83aaa..623b244 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListener.java
@@ -23,7 +23,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.UNITS_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.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;
@@ -57,8 +57,8 @@
* rule (units), performs validation and updates the data model
* tree.
*
- * @param listener listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processUnitsEntry(TreeWalkListener listener,
GeneratedYangParser.UnitsStatementContext ctx) {
@@ -67,7 +67,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, UNITS_DATA, ctx.string().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
- switch (tmpData.getParsableDataType()) {
+ switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
YangLeaf leaf = (YangLeaf) tmpData;
leaf.setUnits(ctx.string().getText());
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ValueListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ValueListener.java
index 7c050dc..80cf8a7 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ValueListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ValueListener.java
@@ -29,7 +29,7 @@
import org.onosproject.yangutils.datamodel.YangEnum;
import org.onosproject.yangutils.datamodel.YangEnumeration;
import org.onosproject.yangutils.parser.Parsable;
-import static org.onosproject.yangutils.parser.ParsableDataType.VALUE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.VALUE_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -55,8 +55,8 @@
* It is called when parser receives an input matching the grammar rule
* (value), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processValueEntry(TreeWalkListener listener, GeneratedYangParser.ValueStatementContext ctx) {
@@ -65,7 +65,7 @@
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case ENUM_DATA: {
YangEnum enumNode = (YangEnum) tmpNode;
if (!isEnumValueValid(listener, ctx)) {
@@ -86,8 +86,8 @@
/**
* Validates ENUM value uniqueness.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
* @return validation result
*/
private static boolean isEnumValueValid(TreeWalkListener listener, GeneratedYangParser.ValueStatementContext ctx) {
@@ -97,7 +97,7 @@
checkStackIsNotEmpty(listener, MISSING_HOLDER, VALUE_DATA, ctx.INTEGER().getText(), ENTRY);
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case ENUMERATION_DATA: {
YangEnumeration yangEnumeration = (YangEnumeration) tmpNode;
for (YangEnum curEnum : yangEnumeration.getEnumSet()) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/VersionListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/VersionListener.java
index 021ae0d..9b9a388 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/VersionListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/VersionListener.java
@@ -23,7 +23,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.VERSION_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.VERSION_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;
@@ -78,8 +78,8 @@
* It is called when parser receives an input matching the grammar rule
* (version), perform validations and update the data model tree.
*
- * @param listener Listener's object.
- * @param ctx context object of the grammar rule.
+ * @param listener Listener's object
+ * @param ctx context object of the grammar rule
*/
public static void processVersionEntry(TreeWalkListener listener,
GeneratedYangParser.YangVersionStatementContext ctx) {
@@ -89,7 +89,7 @@
Integer version = Integer.valueOf(ctx.INTEGER().getText());
if (!isVersionValid(version)) {
- ParserException parserException = new ParserException("Input version not supported");
+ ParserException parserException = new ParserException("YANG file error: Input version not supported");
parserException.setLine(ctx.INTEGER().getSymbol().getLine());
parserException.setCharPosition(ctx.INTEGER().getSymbol().getCharPositionInLine());
throw parserException;
@@ -97,7 +97,7 @@
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
- switch (tmpNode.getParsableDataType()) {
+ switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.setVersion((byte) 1);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerCollisionDetector.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerCollisionDetector.java
new file mode 100644
index 0000000..7697e6a
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerCollisionDetector.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.parserutils;
+
+import org.onosproject.yangutils.datamodel.CollisionDetector;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+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 org.onosproject.yangutils.utils.YangConstructType;
+
+/**
+ * Check the YANG construct collision in a YANG file.
+ */
+public final class ListenerCollisionDetector {
+
+ /**
+ * Creates a new listener collision.
+ */
+ private ListenerCollisionDetector() {
+ }
+
+ /**
+ * Detects that the identifiers of all these child nodes must be unique
+ * within all cases in a choice.
+ *
+ * @param listener listener's object
+ * @param line line of identifier in YANG file, required for error
+ * reporting
+ * @param charPosition character position of identifier in YANG file,
+ * required for error reporting
+ * @param identifierName name for which uniqueness is to be detected
+ * @param constructType type of YANG construct for which collision check is
+ * to be performed
+ * @throws ParserException if identifier is not unique
+ */
+ public static void detectCollidingChildUtil(TreeWalkListener listener, int line, int charPosition,
+ String identifierName, YangConstructType constructType)
+ throws ParserException {
+
+ if (listener.getParsedDataStack().peek() instanceof CollisionDetector) {
+ try {
+ ((CollisionDetector) listener.getParsedDataStack().peek()).detectCollidingChild(
+ identifierName, constructType);
+ } catch (DataModelException e) {
+ ParserException parserException = new ParserException(e.getMessage());
+ parserException.setLine(line);
+ parserException.setCharPosition(charPosition);
+ throw parserException;
+ }
+ } else {
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, constructType, identifierName,
+ EXIT));
+ }
+ }
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorLocation.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorLocation.java
index 4c3efd6..ee47115 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorLocation.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorLocation.java
@@ -33,8 +33,8 @@
/**
* Returns the message corresponding to listener error location.
*
- * @param errorLocation enum value for type of error.
- * @return message corresponding to listener error location.
+ * @param errorLocation enum value for type of error
+ * @return message corresponding to listener error location
*/
public static String getErrorLocationMessage(ListenerErrorLocation errorLocation) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorMessageConstruction.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorMessageConstruction.java
index 1ef25e3..538cb0e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorMessageConstruction.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorMessageConstruction.java
@@ -16,9 +16,9 @@
package org.onosproject.yangutils.parser.impl.parserutils;
-import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.utils.YangConstructType;
-import static org.onosproject.yangutils.parser.ParsableDataType.getParsableDataType;
+import static org.onosproject.yangutils.utils.YangConstructType.getYangConstructType;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.getErrorLocationMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.getErrorType;
@@ -37,21 +37,21 @@
* Constructs message for error with extended information and returns the
* same.
*
- * @param errorType error type needs to be set in error message.
- * @param parsableDataType type of parsable data in which error occurred.
+ * @param errorType error type needs to be set in error message
+ * @param yangConstructType type of parsable data in which error occurred
* @param parsableDataTypeName identifier/string of parsable data type in
- * which error occurred.
- * @param errorLocation location where error occurred.
- * @param extendedErrorInformation extended error information.
- * @return constructed error message.
+ * which error occurred
+ * @param errorLocation location where error occurred
+ * @param extendedErrorInformation extended error information
+ * @return constructed error message
*/
public static String constructExtendedListenerErrorMessage(ListenerErrorType errorType,
- ParsableDataType parsableDataType,
+ YangConstructType yangConstructType,
String parsableDataTypeName,
ListenerErrorLocation errorLocation,
String extendedErrorInformation) {
String newErrorMessage;
- newErrorMessage = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName,
+ newErrorMessage = constructListenerErrorMessage(errorType, yangConstructType, parsableDataTypeName,
errorLocation)
+ "\n"
+ "Error Information: "
@@ -63,22 +63,22 @@
* Constructs message for error during listener based tree walk and returns
* the same.
*
- * @param errorType error type needs to be set in error message.
- * @param parsableDataType type of parsable data in which error occurred.
+ * @param errorType error type needs to be set in error message
+ * @param yangConstructType type of parsable data in which error occurred
* @param parsableDataTypeName identifier/string of parsable data type in
- * which error occurred.
- * @param errorLocation location where error occurred.
- * @return constructed error message.
+ * which error occurred
+ * @param errorLocation location where error occurred
+ * @return constructed error message
*/
public static String constructListenerErrorMessage(ListenerErrorType errorType,
- ParsableDataType parsableDataType,
+ YangConstructType yangConstructType,
String parsableDataTypeName,
ListenerErrorLocation errorLocation) {
String errorMessage;
errorMessage = "Internal parser error detected: " + getErrorType(errorType) + " "
- + getParsableDataType(parsableDataType);
+ + getYangConstructType(yangConstructType);
if (!parsableDataTypeName.isEmpty()) {
errorMessage = errorMessage + " \"" + parsableDataTypeName + "\" ";
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorType.java
index 1d061d7..32620d5 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorType.java
@@ -60,6 +60,11 @@
INVALID_CONTENT(),
/**
+ * Represents that the identifier collision is detected.
+ */
+ IDENTIFIER_COLLISION(),
+
+ /**
* Represents that some of earlier parsed data is not handled correctly.
*/
UNHANDLED_PARSED_DATA();
@@ -67,8 +72,8 @@
/**
* Returns the message corresponding to listener error type.
*
- * @param errorType enum value for type of error.
- * @return message corresponding to listener error type.
+ * @param errorType enum value for type of error
+ * @return message corresponding to listener error type
*/
public static String getErrorType(ListenerErrorType errorType) {
@@ -87,6 +92,8 @@
return "Duplicate";
case INVALID_CONTENT:
return "Invalid content in";
+ case IDENTIFIER_COLLISION:
+ return "Identifier collision detected for";
case UNHANDLED_PARSED_DATA:
return "Unhandled parsed data at";
default:
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
index 26e4907..d460634 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
@@ -20,10 +20,13 @@
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import org.onosproject.yangutils.utils.YangConstructType;
+import static org.onosproject.yangutils.utils.YangConstructType.getYangConstructType;
+
+import java.util.List;
/**
* It's a utility to carry out listener validation.
@@ -39,15 +42,15 @@
/**
* Checks parsed data stack is not empty.
*
- * @param listener Listener's object.
- * @param errorType error type needs to be set in error message.
- * @param parsableDataType type of parsable data in which error occurred.
+ * @param listener Listener's object
+ * @param errorType error type needs to be set in error message
+ * @param yangConstructType type of parsable data in which error occurred
* @param parsableDataTypeName name of parsable data type in which error
- * occurred.
- * @param errorLocation location where error occurred.
+ * occurred
+ * @param errorLocation location where error occurred
*/
public static void checkStackIsNotEmpty(TreeWalkListener listener, ListenerErrorType errorType,
- ParsableDataType parsableDataType, String parsableDataTypeName,
+ YangConstructType yangConstructType, String parsableDataTypeName,
ListenerErrorLocation errorLocation) {
if (listener.getParsedDataStack().empty()) {
/*
@@ -55,7 +58,7 @@
* parsableDataTypeName will be null in case there is no name
* attached to parsable data type.
*/
- String message = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName,
+ String message = constructListenerErrorMessage(errorType, yangConstructType, parsableDataTypeName,
errorLocation);
throw new ParserException(message);
}
@@ -64,16 +67,15 @@
/**
* Checks parsed data stack is empty.
*
- * @param listener Listener's object.
- * @param errorType error type needs to be set in error message.
- * @param parsableDataType type of parsable data in which error occurred.
+ * @param listener Listener's object
+ * @param errorType error type needs to be set in error message
+ * @param yangConstructType type of parsable data in which error occurred
* @param parsableDataTypeName name of parsable data type in which error
- * occurred.
- * @param errorLocation location where error occurred.
+ * occurred
+ * @param errorLocation location where error occurred
*/
-
public static void checkStackIsEmpty(TreeWalkListener listener, ListenerErrorType errorType,
- ParsableDataType parsableDataType, String parsableDataTypeName,
+ YangConstructType yangConstructType, String parsableDataTypeName,
ListenerErrorLocation errorLocation) {
if (!listener.getParsedDataStack().empty()) {
@@ -82,7 +84,7 @@
* parsableDataTypeName will be null in case there is no name
* attached to parsable data type.
*/
- String message = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName,
+ String message = constructListenerErrorMessage(errorType, yangConstructType, parsableDataTypeName,
errorLocation);
throw new ParserException(message);
}
@@ -92,8 +94,8 @@
* Returns parent node config value, if top node does not specify a config statement
* then default value true is returned.
*
- * @param listener listener's object.
- * @return true/false parent's config value.
+ * @param listener listener's object
+ * @return true/false parent's config value
*/
public static boolean getParentNodeConfig(TreeWalkListener listener) {
YangNode parentNode;
@@ -108,4 +110,71 @@
}
return true;
}
+
+ /**
+ * Checks if a rule occurrences is as per the expected YANG grammar's
+ * cardinality.
+ *
+ * @param childContext child's context
+ * @param yangChildConstruct child construct for whom cardinality is to be
+ * validated
+ * @param yangParentConstruct parent construct
+ * @param parentName parent name
+ * @throws ParserException exception if cardinality check fails
+ */
+ public static void validateCardinality(List<?> childContext, YangConstructType yangChildConstruct,
+ YangConstructType yangParentConstruct, String parentName)
+ throws ParserException {
+
+ if (!childContext.isEmpty() && childContext.size() != 1) {
+ ParserException parserException = new ParserException("YANG file error: Invalid cardinality of "
+ + getYangConstructType(yangChildConstruct) + " in " + getYangConstructType(yangParentConstruct)
+ + " \"" + parentName + "\".");
+ throw parserException;
+ }
+ }
+
+ /**
+ * Checks if a rule occurrences is exactly 1.
+ *
+ * @param childContext child's context
+ * @param yangChildConstruct child construct for whom cardinality is to be
+ * validated
+ * @param yangParentConstruct parent construct
+ * @param parentName parent name
+ * @throws ParserException exception if cardinality check fails
+ */
+ public static void validateCardinalityEqualsOne(List<?> childContext, YangConstructType yangChildConstruct,
+ YangConstructType yangParentConstruct, String parentName)
+ throws ParserException {
+
+ if (childContext.isEmpty() || childContext.size() != 1) {
+ ParserException parserException = new ParserException("YANG file error: Invalid cardinality of "
+ + getYangConstructType(yangChildConstruct) + " in " + getYangConstructType(yangParentConstruct)
+ + " \"" + parentName + "\".");
+ throw parserException;
+ }
+ }
+
+ /**
+ * Checks if a rule occurrences is minimum 1.
+ *
+ * @param childContext child's context
+ * @param yangChildConstruct child construct for whom cardinality is to be
+ * validated
+ * @param yangParentConstruct parent construct
+ * @param parentName parent name
+ * @throws ParserException exception if cardinality check fails
+ */
+ public static void validateCardinalityNonNull(List<?> childContext, YangConstructType yangChildConstruct,
+ YangConstructType yangParentConstruct, String parentName)
+ throws ParserException {
+
+ if (childContext.isEmpty()) {
+ ParserException parserException = new ParserException("YANG file error: Invalid cardinality of "
+ + getYangConstructType(yangChildConstruct) + " in " + getYangConstructType(yangParentConstruct)
+ + " \"" + parentName + "\".");
+ throw parserException;
+ }
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/ParsableDataType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/YangConstructType.java
similarity index 93%
rename from utils/yangutils/src/main/java/org/onosproject/yangutils/parser/ParsableDataType.java
rename to utils/yangutils/src/main/java/org/onosproject/yangutils/utils/YangConstructType.java
index 046a214..626674d 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/ParsableDataType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/YangConstructType.java
@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.yangutils.parser;
+package org.onosproject.yangutils.utils;
/**
* ENUM to represent the type of data in parse tree.
*/
-public enum ParsableDataType {
+public enum YangConstructType {
/**
* Identifies the module parsed data.
*/
@@ -230,6 +230,11 @@
POSITION_DATA,
/**
+ * Identifies the YANG data definition statements.
+ */
+ DATA_DEF_DATA,
+
+ /**
* Identifies the derived data type.
*/
DERIVED;
@@ -237,12 +242,12 @@
/**
* Returns the YANG construct keyword corresponding to enum values.
*
- * @param parsableDataType enum value for parsable data type.
- * @return YANG construct keyword.
+ * @param yangConstructType enum value for parsable data type
+ * @return YANG construct keyword
*/
- public static String getParsableDataType(ParsableDataType parsableDataType) {
+ public static String getYangConstructType(YangConstructType yangConstructType) {
- switch (parsableDataType) {
+ switch (yangConstructType) {
case MODULE_DATA:
return "module";
case SUB_MODULE_DATA:
@@ -327,6 +332,8 @@
return "position";
case DEFAULT_DATA:
return "default";
+ case DATA_DEF_DATA:
+ return "data-def-substatements";
case DERIVED:
return "derived";
default:
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
index aa86c51..961e902 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
@@ -69,6 +69,42 @@
}
/**
+ * Checks if container identifier in module is duplicate.
+ */
+ @Test(expected = ParserException.class)
+ public void processModuleDuplicateContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleDuplicateContainer.yang");
+ }
+
+ /**
+ * Checks if container identifier in container is duplicate.
+ */
+ @Test(expected = ParserException.class)
+ public void processContainerDuplicateContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerDuplicateContainer.yang");
+ }
+
+ /**
+ * Checks if container identifier in list is duplicate.
+ */
+ @Test(expected = ParserException.class)
+ public void processListDuplicateContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListDuplicateContainer.yang");
+ }
+
+ /**
+ * Checks if container identifier collides with list at same level.
+ */
+ @Test(expected = ParserException.class)
+ public void processDuplicateContainerAndList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DuplicateContainerAndList.yang");
+ }
+
+ /**
* Checks container statement as sub-statement of container.
*/
@Test
@@ -170,7 +206,7 @@
@Test
public void processContainerSubStatementCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("Internal parser error detected: Invalid cardinality in reference before processing.");
+ thrown.expectMessage("YANG file error: Invalid cardinality of reference in container \"valid\".");
YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementCardinality.yang");
}
@@ -193,4 +229,4 @@
thrown.expectMessage("mismatched input '1valid' expecting IDENTIFIER");
YangNode node = manager.getDataModel("src/test/resources/ContainerInvalidIdentifier.yang");
}
-}
\ No newline at end of file
+}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
index 359b108..afa48da 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
@@ -120,7 +120,7 @@
@Test
public void processLeafListConfigInvalidCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("Internal parser error detected: Invalid cardinality in config before processing.");
+ thrown.expectMessage("YANG file error: Invalid cardinality of config in leaf-list \"invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/LeafListConfigInvalidCardinality.yang");
}
@@ -131,7 +131,7 @@
@Test
public void processLeafListUnitsInvalidCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("Internal parser error detected: Invalid cardinality in units before processing.");
+ thrown.expectMessage("YANG file error: Invalid cardinality of units in leaf-list \"invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/LeafListUnitsInvalidCardinality.yang");
}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
index df8f385..40afc03 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
@@ -120,7 +120,7 @@
@Test
public void processLeafConfigInvalidCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("Internal parser error detected: Invalid cardinality in config before processing.");
+ thrown.expectMessage("YANG file error: Invalid cardinality of config in leaf \"invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/LeafConfigInvalidCardinality.yang");
}
@@ -131,7 +131,7 @@
@Test
public void processLeafMandatoryInvalidCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("Internal parser error detected: Invalid cardinality in mandatory before processing.");
+ thrown.expectMessage("YANG file error: Invalid cardinality of mandatory in leaf \"invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/LeafMandatoryInvalidCardinality.yang");
}
@@ -173,6 +173,33 @@
}
/**
+ * Checks duplicate leaf statement as sub-statement of module.
+ */
+ @Test(expected = ParserException.class)
+ public void processModuleWithDuplicateLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleWithDuplicateLeaf.yang");
+ }
+
+ /**
+ * Checks duplicate leaf statement as sub-statement of container.
+ */
+ @Test(expected = ParserException.class)
+ public void processContainerWithDuplicateLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerWithDuplicateLeaf.yang");
+ }
+
+ /**
+ * Checks duplicate leaf statement as sub-statement of list.
+ */
+ @Test(expected = ParserException.class)
+ public void processListWithDuplicateLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListWithDuplicateLeaf.yang");
+ }
+
+ /**
* Checks leaf statement as sub-statement of list.
*/
@Test
@@ -207,4 +234,4 @@
assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
}
-}
\ No newline at end of file
+}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
index 0d2d29b..fdc2221 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
@@ -175,7 +175,7 @@
@Test
public void processListSubStatementsCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("Internal parser error detected: Invalid cardinality in reference before processing.");
+ thrown.expectMessage("YANG file error: Invalid cardinality of reference in list \"valid\".");
YangNode node = manager.getDataModel("src/test/resources/ListSubStatementsCardinality.yang");
}
@@ -185,7 +185,7 @@
@Test
public void processListStatementWithoutChild() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("Internal parser error detected: Invalid cardinality in list before processing.");
+ thrown.expectMessage("YANG file error: Invalid cardinality of data-def-substatements in list \"valid\".");
YangNode node = manager.getDataModel("src/test/resources/ListStatementWithoutChild.yang");
}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java
index f3f3876..f70dc96 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java
@@ -122,7 +122,7 @@
@Test
public void processMaxElementsCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("Internal parser error detected: Invalid cardinality in max-elements before processing.");
+ thrown.expectMessage("YANG file error: Invalid cardinality of max-elements in leaf-list \"invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/MaxElementsCardinality.yang");
}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java
index c8a5576..b197557 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java
@@ -133,8 +133,7 @@
@Test
public void processMinElementsInvalidCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage(
- "Internal parser error detected: Invalid cardinality in" + " min-elements before processing.");
+ thrown.expectMessage("YANG file error: Invalid cardinality of min-elements in leaf-list \"invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidCardinality.yang");
}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
index c4b9fa7..53611fe 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
@@ -157,7 +157,7 @@
@Test
public void processUnitsStatementCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("Internal parser error detected: Invalid cardinality in units before processing.");
+ thrown.expectMessage("YANG file error: Invalid cardinality of units in leaf \"invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/UnitsStatementCardinality.yang");
}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
index 2338604..e13e987 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
@@ -64,7 +64,7 @@
YangNode node = manager.getDataModel("src/test/resources/VersionNotPresent.yang");
// Checks for the version value in data model tree.
- assertThat(((YangModule) node).getVersion(), is((byte) 0));
+ assertThat(((YangModule) node).getVersion(), is((byte) 1));
}
/**
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java
index 0c1473e..9486f50 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java
@@ -20,7 +20,7 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-import static org.onosproject.yangutils.parser.ParsableDataType.CONTACT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.CONTACT_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java
index d39b0ae..e9843d6 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java
@@ -23,7 +23,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import static org.onosproject.yangutils.parser.ParsableDataType.YANGBASE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.YANGBASE_DATA;
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.MISSING_HOLDER;
diff --git a/utils/yangutils/src/test/resources/ContainerDuplicateContainer.yang b/utils/yangutils/src/test/resources/ContainerDuplicateContainer.yang
new file mode 100644
index 0000000..4928463
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerDuplicateContainer.yang
@@ -0,0 +1,23 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/ContainerWithDuplicateLeaf.yang b/utils/yangutils/src/test/resources/ContainerWithDuplicateLeaf.yang
new file mode 100644
index 0000000..3adaccd
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerWithDuplicateLeaf.yang
@@ -0,0 +1,34 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ leaf valid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ leaf valid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/DuplicateContainerAndList.yang b/utils/yangutils/src/test/resources/DuplicateContainerAndList.yang
new file mode 100644
index 0000000..74c7721
--- /dev/null
+++ b/utils/yangutils/src/test/resources/DuplicateContainerAndList.yang
@@ -0,0 +1,29 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ list valid {
+ key "process-id";
+ container interface {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ leaf process-id {
+ type "string";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/ListDuplicateContainer.yang b/utils/yangutils/src/test/resources/ListDuplicateContainer.yang
new file mode 100644
index 0000000..8c152b2
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListDuplicateContainer.yang
@@ -0,0 +1,27 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list ospf {
+ key "process-id";
+ container interface {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ leaf process-id {
+ type "string";
+ }
+ container interface {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/ListWithDuplicateLeaf.yang b/utils/yangutils/src/test/resources/ListWithDuplicateLeaf.yang
new file mode 100644
index 0000000..55a78f6
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListWithDuplicateLeaf.yang
@@ -0,0 +1,26 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/ModuleDuplicateContainer.yang b/utils/yangutils/src/test/resources/ModuleDuplicateContainer.yang
new file mode 100644
index 0000000..bc58896
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleDuplicateContainer.yang
@@ -0,0 +1,29 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ container invalid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/ModuleWithDuplicateLeaf.yang b/utils/yangutils/src/test/resources/ModuleWithDuplicateLeaf.yang
new file mode 100644
index 0000000..2c3ecbc
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleWithDuplicateLeaf.yang
@@ -0,0 +1,32 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ leaf valid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}