[ONOS-5102, 5103] Child schema map and namespace generation for nodes for YMS validation optimization.
Change-Id: Iea8eeeb9e6bb56aa33dad2d15ae9e0fe66104c92
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
index 84c3698..0f5a8b6 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.yangutils.datamodel;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
@@ -87,11 +88,6 @@
private static final long serialVersionUID = 806201602L;
/**
- * Augment target node.
- */
- private String name;
-
- /**
* Description of augment.
*/
private String description;
@@ -147,11 +143,46 @@
* Create a YANG augment node.
*/
public YangAugment() {
- super(YangNodeType.AUGMENT_NODE);
+ super(YangNodeType.AUGMENT_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
+ listOfLeaf = new LinkedList<>();
+ listOfLeafList = new LinkedList<>();
resolvableStatus = ResolvableStatus.UNRESOLVED;
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo) throws DataModelException {
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo1 = new YangSchemaNodeContextInfo();
+ yangSchemaNodeContextInfo1.setSchemaNode(yangSchemaNodeContextInfo.getSchemaNode());
+ yangSchemaNodeContextInfo1.setContextSwitchedNode(this);
+ getAugmentedNode().addToChildSchemaMap(schemaNodeIdentifier, yangSchemaNodeContextInfo1);
+ }
+
+ @Override
+ public void setNameSpaceAndAddToParentSchemaMap() {
+ // Get parent namespace.
+ YangNameSpace nameSpace = this.getParent().getNameSpace();
+ // Set namespace for self node.
+ setNameSpace(nameSpace);
+ /*
+ * Check if node contains leaf/leaf-list, if yes add namespace for leaf
+ * and leaf list.
+ */
+ setLeafNameSpaceAndAddToParentSchemaMap();
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
@@ -257,10 +288,6 @@
*/
@Override
public void addLeaf(YangLeaf leaf) {
- if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<>());
- }
-
getListOfLeaf().add(leaf);
}
@@ -291,13 +318,21 @@
*/
@Override
public void addLeafList(YangLeafList leafList) {
- if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<>());
- }
-
getListOfLeafList().add(leafList);
}
+ @Override
+ public void setLeafNameSpaceAndAddToParentSchemaMap() {
+ // Add namespace for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ // Add namespace for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ }
+
/**
* Returns the textual reference.
*
@@ -371,26 +406,6 @@
}
/**
- * Returns the target nodes name where the augmentation is being done.
- *
- * @return target nodes name where the augmentation is being done
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets the 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) {
- this.name = name;
- }
-
- /**
* Returns augmented node.
*
* @return augmented node
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
index 9e93a58..d2a4017 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
@@ -16,6 +16,7 @@
package org.onosproject.yangutils.datamodel;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
@@ -100,13 +101,6 @@
private static final long serialVersionUID = 806201603L;
/**
- * Case name.
- */
- private String name;
-
- // TODO: default field identification for the case
-
- /**
* Description of case.
*/
private String description;
@@ -147,12 +141,48 @@
* Creates a choice node.
*/
public YangCase() {
- super(YangNodeType.CASE_NODE);
+ super(YangNodeType.CASE_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
listOfLeaf = new LinkedList<>();
listOfLeafList = new LinkedList<>();
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo1 = new YangSchemaNodeContextInfo();
+ yangSchemaNodeContextInfo1.setSchemaNode(yangSchemaNodeContextInfo.getSchemaNode());
+ yangSchemaNodeContextInfo1.setContextSwitchedNode(this);
+ getParent().addToChildSchemaMap(schemaNodeIdentifier, yangSchemaNodeContextInfo1);
+ }
+
+ @Override
+ public void setNameSpaceAndAddToParentSchemaMap() {
+ // Get parent namespace.
+ YangNameSpace nameSpace = this.getParent().getNameSpace();
+ // Set namespace for self node.
+ setNameSpace(nameSpace);
+ /*
+ * Check if node contains leaf/leaf-list, if yes add namespace for leaf
+ * and leaf list.
+ */
+ setLeafNameSpaceAndAddToParentSchemaMap();
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ //For non data nodes, mandatory child to be added to parent node.
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ //For non data nodes, default child to be added to parent node.
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
@@ -178,26 +208,6 @@
}
/**
- * Returns the case name.
- *
- * @return case name
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets the case name.
- *
- * @param name case name
- */
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- /**
* Returns the description.
*
* @return the description
@@ -244,10 +254,6 @@
*/
@Override
public void addLeaf(YangLeaf leaf) {
- if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<>());
- }
-
getListOfLeaf().add(leaf);
}
@@ -278,10 +284,6 @@
*/
@Override
public void addLeafList(YangLeafList leafList) {
- if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<YangLeafList>());
- }
-
getListOfLeafList().add(leafList);
}
@@ -416,4 +418,16 @@
public List<YangAugmentedInfo> getAugmentedInfoList() {
return yangAugmentedInfo;
}
+
+ @Override
+ public void setLeafNameSpaceAndAddToParentSchemaMap() {
+ // Add namespace for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ // Add namespace for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ }
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
index b549d6c..0efcf56 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
@@ -16,6 +16,7 @@
package org.onosproject.yangutils.datamodel;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
@@ -73,11 +74,6 @@
private static final long serialVersionUID = 806201604L;
/**
- * Name of choice.
- */
- private String name;
-
- /**
* If the choice represents config data.
*/
private boolean isConfig;
@@ -165,7 +161,7 @@
* Create a choice node.
*/
public YangChoice() {
- super(YangNodeType.CHOICE_NODE);
+ super(YangNodeType.CHOICE_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
yangAppErrorInfo = new YangAppErrorInfo();
yangAppErrorInfo.setErrorTag(DATA_MISSING_ERROR_TAG);
yangAppErrorInfo.setErrorAppTag(MISSING_CHOICE_ERROR_APP_TAG);
@@ -173,6 +169,37 @@
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo1 = new YangSchemaNodeContextInfo();
+ yangSchemaNodeContextInfo1.setSchemaNode(yangSchemaNodeContextInfo.getSchemaNode());
+ yangSchemaNodeContextInfo1.setContextSwitchedNode(this);
+ getParent().addToChildSchemaMap(schemaNodeIdentifier, yangSchemaNodeContextInfo1);
+ }
+
+ @Override
+ public void setNameSpaceAndAddToParentSchemaMap() {
+ // Get parent namespace.
+ YangNameSpace nameSpace = this.getParent().getNameSpace();
+ // Set namespace for self node.
+ setNameSpace(nameSpace);
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ //For non data nodes, mandatory child to be added to parent node.
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ //For non data nodes, default child to be added to parent node.
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
@@ -198,26 +225,6 @@
}
/**
- * Returns the choice name.
- *
- * @return choice name
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets the choice name.
- *
- * @param name choice name
- */
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- /**
* Returns config flag.
*
* @return the config flag
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
index 940d598..7707b15 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
@@ -17,6 +17,7 @@
package org.onosproject.yangutils.datamodel;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
@@ -95,11 +96,6 @@
private static final long serialVersionUID = 806201605L;
/**
- * Name of the container.
- */
- private String name;
-
- /**
* If container maintains config data.
*/
private Boolean isConfig;
@@ -156,12 +152,28 @@
* Create a container node.
*/
public YangContainer() {
- super(YangNodeType.CONTAINER_NODE);
+ super(YangNodeType.CONTAINER_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
listOfLeaf = new LinkedList<>();
listOfLeafList = new LinkedList<>();
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo) {
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
}
@@ -187,26 +199,6 @@
}
/**
- * Returns the YANG name of container.
- *
- * @return the name of container as defined in YANG file
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets the YANG name of container.
- *
- * @param name the name of container as defined in YANG file
- */
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- /**
* Returns the config flag.
*
* @return the isConfig
@@ -271,11 +263,6 @@
*/
@Override
public void addLeaf(YangLeaf leaf) {
-
- if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<YangLeaf>());
- }
-
getListOfLeaf().add(leaf);
}
@@ -306,14 +293,10 @@
*/
@Override
public void addLeafList(YangLeafList leafList) {
-
- if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<YangLeafList>());
- }
-
getListOfLeafList().add(leafList);
}
+
/**
* Returns the presence string if present.
*
@@ -541,4 +524,16 @@
public List<YangAugmentedInfo> getAugmentedInfoList() {
return yangAugmentedInfo;
}
+
+ @Override
+ public void setLeafNameSpaceAndAddToParentSchemaMap() {
+ // Add namespace for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ // Add namespace for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ }
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
index b230b88..be86e8c 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
@@ -39,18 +39,32 @@
// Enumeration info set.
private SortedSet<YangEnum> enumSet;
- // Enumeration name.
- private String name;
-
/**
* Creates an enumeration object.
*/
public YangEnumeration() {
- super(YangNodeType.ENUMERATION_NODE);
+ super(YangNodeType.ENUMERATION_NODE, null);
setEnumSet(new TreeSet<YangEnum>());
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ // Do nothing.
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
@@ -87,26 +101,6 @@
}
/**
- * Returns enumeration name.
- *
- * @return the enumeration name
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets the enumeration name.
- *
- * @param name enumeration name
- */
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- /**
* Returns the type of the data.
*
* @return returns ENUMERATION_DATA
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java
index 08fc4bd..c728096 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java
@@ -83,11 +83,6 @@
private static final long serialVersionUID = 806201607L;
/**
- * Name of the grouping.
- */
- private String name;
-
- /**
* Description.
*/
private String description;
@@ -116,37 +111,34 @@
* Creates the grouping node.
*/
public YangGrouping() {
- super(YangNodeType.GROUPING_NODE);
+ super(YangNodeType.GROUPING_NODE, null);
listOfLeaf = new LinkedList<YangLeaf>();
listOfLeafList = new LinkedList<YangLeafList>();
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ // Do nothing, to be handled during linking.
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // Do nothing, to be handled during linking.
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // Do nothing, to be handled during linking.
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
/**
- * Returns YANG grouping name.
- *
- * @return YANG grouping name
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets YANG grouping name.
- *
- * @param name YANG grouping name
- */
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- /**
* Returns the description.
*
* @return the description
@@ -324,5 +316,17 @@
getName() + "\"");
}
}
+
+ @Override
+ public void setLeafNameSpaceAndAddToParentSchemaMap() {
+ // Add namespace for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ // Add namespace for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ }
// TODO A grouping MUST NOT reference itself, neither directly nor indirectly through a chain of other groupings.
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangIdentity.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangIdentity.java
index dc252b5..28bba80 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangIdentity.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangIdentity.java
@@ -50,9 +50,6 @@
private static final long serialVersionUID = 806201691L;
- //Name of the identity.
- private String name;
-
//Base node of identity.
private YangBase baseNode;
@@ -67,7 +64,24 @@
//Creates a identity type of node.
public YangIdentity() {
- super(YangNodeType.IDENTITY_NODE);
+ super(YangNodeType.IDENTITY_NODE, null);
+ }
+
+ @Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ // Do nothing.
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // TODO
}
@Override
@@ -75,24 +89,6 @@
return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
- /**
- * Returns the name of identity.
- *
- * @return the identity name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the name of identity.
- *
- * @param name the identity name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
@Override
public YangStatusType getStatus() {
return status;
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangIdentityRef.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangIdentityRef.java
index f6d4128..65a0545 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangIdentityRef.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangIdentityRef.java
@@ -63,12 +63,29 @@
// Creates a specific identityref of node.
public YangIdentityRef() {
- super(YangNodeType.IDENTITYREF_NODE);
+ super(YangNodeType.IDENTITYREF_NODE, null);
baseIdentity = new YangNodeIdentifier();
resolvableStatus = ResolvableStatus.UNRESOLVED;
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ // Do nothing.
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangInput.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangInput.java
index d3714be..4486feb 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangInput.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangInput.java
@@ -17,9 +17,9 @@
package org.onosproject.yangutils.datamodel;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
-
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.datamodel.utils.YangConstructType;
@@ -76,11 +76,6 @@
private static final long serialVersionUID = 806201608L;
/**
- * Name of the input.
- */
- private String name;
-
- /**
* List of leaves contained.
*/
private List<YangLeaf> listOfLeaf;
@@ -96,14 +91,50 @@
* Create a rpc input node.
*/
public YangInput() {
- super(YangNodeType.INPUT_NODE);
+ super(YangNodeType.INPUT_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
listOfLeaf = new LinkedList<>();
listOfLeafList = new LinkedList<>();
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo1 = new YangSchemaNodeContextInfo();
+ yangSchemaNodeContextInfo1.setSchemaNode(yangSchemaNodeContextInfo.getSchemaNode());
+ yangSchemaNodeContextInfo1.setContextSwitchedNode(this);
+ getParent().addToChildSchemaMap(schemaNodeIdentifier, yangSchemaNodeContextInfo1);
+ }
+
+ @Override
+ public void setNameSpaceAndAddToParentSchemaMap() {
+ // Get parent namespace.
+ YangNameSpace nameSpace = this.getParent().getNameSpace();
+ // Set namespace for self node.
+ setNameSpace(nameSpace);
+ /*
+ * Check if node contains leaf/leaf-list, if yes add namespace for leaf
+ * and leaf list.
+ */
+ setLeafNameSpaceAndAddToParentSchemaMap();
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ //For non data nodes, mandatory child to be added to parent node.
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ //For non data nodes, default child to be added to parent node.
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
- return YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
+ return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
@Override
@@ -170,16 +201,6 @@
}
@Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
public void addAugmentation(YangAugmentedInfo augmentInfo) {
yangAugmentedInfo.add(augmentInfo);
}
@@ -193,4 +214,16 @@
public List<YangAugmentedInfo> getAugmentedInfoList() {
return yangAugmentedInfo;
}
+
+ @Override
+ public void setLeafNameSpaceAndAddToParentSchemaMap() {
+ // Add namespace for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ // Add namespace for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ }
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
index bfdec10..c5115ee 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
@@ -20,7 +20,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.datamodel.utils.YangConstructType;
@@ -74,6 +73,11 @@
private String name;
/**
+ * Namespace of leaf.
+ */
+ private YangNameSpace namespace;
+
+ /**
* If the leaf is a config parameter.
*/
private Boolean isConfig;
@@ -430,9 +434,8 @@
}
@Override
- public Set<YangSchemaNode> getMandatoryChildSet(YangSchemaNodeIdentifier dataNodeIdentifier) {
- // Returns null as there is no child to leaf.
- return null;
+ public int getMandatoryChildCount() throws DataModelException {
+ throw new DataModelException("TODO");
}
@Override
@@ -446,4 +449,32 @@
return YangSchemaNodeType.YANG_SINGLE_INSTANCE_LEAF_NODE;
}
+ /**
+ * Returns namespace of node.
+ *
+ * @return namespace of node
+ */
+ public YangNameSpace getNamespace() {
+ return namespace;
+ }
+
+ /**
+ * Sets namespace of node.
+ *
+ * @param namespace namespace of node
+ */
+ public void setNamespace(YangNameSpace namespace) {
+ this.namespace = namespace;
+ }
+
+ /**
+ * Sets leaf namespace and add itself to parent child schema map.
+ *
+ * @param nameSpace namespace
+ */
+ public void setLeafNameSpaceAndAddToParentSchemaMap(YangNameSpace nameSpace) {
+ setNamespace(nameSpace);
+ // Process addition of leaf to schema node map.
+ ((YangNode) getContainedIn()).processAdditionOfSchemaNodeToCurNodeMap(getName(), getNamespace().getUri(), this);
+ }
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
index 358fc32..b3d4bdd 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
@@ -20,7 +20,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.datamodel.utils.YangConstructType;
@@ -70,6 +69,11 @@
private String name;
/**
+ * Namespace of leaf-list.
+ */
+ private YangNameSpace namespace;
+
+ /**
* If the leaf-list is a config parameter.
*/
private Boolean isConfig;
@@ -448,9 +452,8 @@
}
@Override
- public Set<YangSchemaNode> getMandatoryChildSet(YangSchemaNodeIdentifier dataNodeIdentifier) {
- // Returns null as there is no child to leaf list.
- return null;
+ public int getMandatoryChildCount() throws DataModelException {
+ throw new DataModelException("TODO");
}
@Override
@@ -463,4 +466,33 @@
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_MULTI_INSTANCE_LEAF_NODE;
}
+
+ /**
+ * Returns namespace of node.
+ *
+ * @return namespace of node
+ */
+ public YangNameSpace getNamespace() {
+ return namespace;
+ }
+
+ /**
+ * Sets namespace of node.
+ *
+ * @param namespace namespace of node
+ */
+ public void setNamespace(YangNameSpace namespace) {
+ this.namespace = namespace;
+ }
+
+ /**
+ * Sets leaf namespace and add itself to parent child schema map.
+ *
+ * @param nameSpace namespace
+ */
+ public void setLeafNameSpaceAndAddToParentSchemaMap(YangNameSpace nameSpace) {
+ setNamespace(nameSpace);
+ // Process addition of leaf to schema node map.
+ ((YangNode) getContainedIn()).processAdditionOfSchemaNodeToCurNodeMap(getName(), getNamespace().getUri(), this);
+ }
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java
index a21ed34..79f1cae 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java
@@ -66,4 +66,11 @@
* @param leafList the leaf-list to be added
*/
void addLeafList(YangLeafList leafList);
+
+ /**
+ * Adds namespace for leafs and leaf-list, this is used in case of
+ * submodule.
+ *
+ */
+ void setLeafNameSpaceAndAddToParentSchemaMap();
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangList.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
index 683a492..a915226 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
@@ -17,6 +17,7 @@
package org.onosproject.yangutils.datamodel;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
@@ -77,11 +78,6 @@
private static final long serialVersionUID = 806201609L;
/**
- * Name of the YANG list.
- */
- private String name;
-
- /**
* If list maintains config data.
*/
private Boolean isConfig;
@@ -216,12 +212,28 @@
* Creates a YANG list object.
*/
public YangList() {
- super(YangNodeType.LIST_NODE);
+ super(YangNodeType.LIST_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
listOfLeaf = new LinkedList<>();
listOfLeafList = new LinkedList<>();
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo) {
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_MULTI_INSTANCE_LEAF_NODE;
}
@@ -265,26 +277,6 @@
}
/**
- * Returns the YANG list name.
- *
- * @return YANG list name
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets the YANG list name.
- *
- * @param name YANG list name
- */
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- /**
* Returns the config flag.
*
* @return the isConfig
@@ -423,10 +415,6 @@
*/
@Override
public void addLeaf(YangLeaf leaf) {
- if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<YangLeaf>());
- }
-
getListOfLeaf().add(leaf);
}
@@ -457,10 +445,6 @@
*/
@Override
public void addLeafList(YangLeafList leafList) {
- if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<YangLeafList>());
- }
-
getListOfLeafList().add(leafList);
}
@@ -791,4 +775,16 @@
public List<YangAugmentedInfo> getAugmentedInfoList() {
return yangAugmentedInfo;
}
+
+ @Override
+ public void setLeafNameSpaceAndAddToParentSchemaMap() {
+ // Add namespace for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ // Add namespace for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ }
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
index be59305..4e6654f 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
@@ -15,11 +15,11 @@
*/
package org.onosproject.yangutils.datamodel;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.datamodel.utils.YangConstructType;
@@ -79,13 +79,8 @@
private static final long serialVersionUID = 806201610L;
/**
- * Name of the module.
- */
- private String name;
-
- /**
* Reference:RFC 6020.
- *
+ * <p>
* The "contact" statement provides contact information for the module. The
* argument is a string that is used to specify contact information for the
* person or persons to whom technical queries concerning this module should
@@ -96,7 +91,7 @@
/**
* Reference:RFC 6020.
- *
+ * <p>
* The "description" statement takes as an argument a string that contains a
* human-readable textual description of this definition. The text is
* provided in a language (or languages) chosen by the module developer; for
@@ -130,13 +125,8 @@
private List<YangFeature> listOfFeature;
/**
- * Name space of the module.
- */
- private YangNameSpace nameSpace;
-
- /**
* Reference:RFC 6020.
- *
+ * <p>
* The "organization" statement defines the party responsible for this
* module. The argument is a string that is used to specify a textual
* description of the organization(s) under whose auspices this module was
@@ -245,7 +235,7 @@
*/
public YangModule() {
- super(YangNodeType.MODULE_NODE);
+ super(YangNodeType.MODULE_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
derivedTypeResolutionList = new LinkedList<>();
augmentResolutionList = new LinkedList<>();
usesResolutionList = new LinkedList<>();
@@ -262,31 +252,27 @@
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo) {
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
}
/**
- * Returns name of the module.
- *
- * @return module name
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets module name.
- *
- * @param moduleName module name
- */
- @Override
- public void setName(String moduleName) {
- name = moduleName;
- }
-
- /**
* Returns the contact details of the module owner.
*
* @return the contact details of YANG owner
@@ -444,24 +430,6 @@
}
/**
- * Returns the name space of module elements.
- *
- * @return the nameSpace
- */
- public YangNameSpace getNameSpace() {
- return nameSpace;
- }
-
- /**
- * Sets the name space of module elements.
- *
- * @param nameSpace the nameSpace to set
- */
- public void setNameSpace(YangNameSpace nameSpace) {
- this.nameSpace = nameSpace;
- }
-
- /**
* Returns the modules organization.
*
* @return the organization
@@ -744,4 +712,16 @@
}
}
}
+
+ @Override
+ public void setLeafNameSpaceAndAddToParentSchemaMap() {
+ // Add namespace for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ // Add namespace for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ }
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
index 6e470b3..9aaf61b 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
@@ -17,7 +17,6 @@
import java.io.Serializable;
import java.util.Map;
-import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
@@ -36,6 +35,16 @@
private static final long serialVersionUID = 806201601L;
/**
+ * Name of a node.
+ */
+ private String name;
+
+ /**
+ * Namespace of a node.
+ */
+ private YangNameSpace nameSpace;
+
+ /**
* Type of node.
*/
private YangNodeType nodeType;
@@ -76,9 +85,9 @@
private Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> ysnContextInfoMap;
/**
- * Set of mandatory YANG schema nodes.
+ * Count of mandatory YANG schema nodes.
*/
- private Set<YangSchemaNode> mandatoryChildSet;
+ private int mandatoryChildCount;
/**
* Map of default schema nodes.
@@ -108,14 +117,18 @@
*
* @return nodes name
*/
- public abstract String getName();
+ public String getName() {
+ return name;
+ }
/**
* Sets the nodes name.
*
* @param name nodes name
*/
- public abstract void setName(String name);
+ public void setName(String name) {
+ this.name = name;
+ }
/**
* Creates a YANG node object.
@@ -130,8 +143,9 @@
*
* @param type of YANG node
*/
- protected YangNode(YangNodeType type) {
+ protected YangNode(YangNodeType type, Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> ysnContextInfoMap) {
setNodeType(type);
+ this.ysnContextInfoMap = ysnContextInfoMap;
}
/**
@@ -258,21 +272,69 @@
/* First child to be added */
if (getChild() == null) {
setChild(newChild);
- return;
+ } else {
+
+ YangNode curNode;
+ curNode = getChild();
+
+ // Get the predecessor child of new child
+ while (curNode.getNextSibling() != null) {
+ curNode = curNode.getNextSibling();
+ }
+
+ // If the new node needs to be the last child
+ if (curNode.getNextSibling() == null) {
+ curNode.setNextSibling(newChild);
+ newChild.setPreviousSibling(curNode);
+ }
}
+ }
- YangNode curNode;
- curNode = getChild();
+ /**
+ * Processes addition of schema node child to parent map.
+ *
+ * @param name name of the node
+ * @param namespace namespace of the node
+ */
+ protected void processAdditionOfSchemaNodeToParentMap(String name, String namespace) {
+ processAdditionOfSchemaNodeToMap(getName(), getNameSpace().getUri(), this, getParent());
+ }
- // Get the predecessor child of new child
- while (curNode.getNextSibling() != null) {
- curNode = curNode.getNextSibling();
- }
+ /**
+ * Processes addition of schema node child to parent map.
+ *
+ * @param name name of the node
+ * @param namespace namespace of the node
+ * @param yangSchemaNode YANG schema node
+ */
+ public void processAdditionOfSchemaNodeToCurNodeMap(String name, String namespace, YangSchemaNode
+ yangSchemaNode) {
+ processAdditionOfSchemaNodeToMap(getName(), getNameSpace().getUri(), this, this);
+ }
- // If the new node needs to be the last child
- if (curNode.getNextSibling() == null) {
- curNode.setNextSibling(newChild);
- newChild.setPreviousSibling(curNode);
+ /**
+ * Processes addition of schema node child to map.
+ *
+ * @param name name of the node
+ * @param namespace namespace of the node
+ * @param yangSchemaNode YANG schema node
+ * @param childSchemaMapHolder child schema map holder
+ */
+ private void processAdditionOfSchemaNodeToMap(String name, String namespace, YangSchemaNode yangSchemaNode,
+ YangNode childSchemaMapHolder) {
+ // Addition of node to schema node map.
+ // Create YANG schema node identifier with child node name.
+ YangSchemaNodeIdentifier yangSchemaNodeIdentifier = new YangSchemaNodeIdentifier();
+ yangSchemaNodeIdentifier.setName(name);
+ yangSchemaNodeIdentifier.setNamespace(namespace);
+ // Create YANG schema node context info and set child node.
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo = new YangSchemaNodeContextInfo();
+ yangSchemaNodeContextInfo.setSchemaNode(yangSchemaNode);
+ // Invoke parent method to add the created entry.
+ try {
+ childSchemaMapHolder.addToChildSchemaMap(yangSchemaNodeIdentifier, yangSchemaNodeContextInfo);
+ } catch (DataModelException e) {
+ //TODO
}
}
@@ -495,8 +557,8 @@
}
@Override
- public Set<YangSchemaNode> getMandatoryChildSet(YangSchemaNodeIdentifier dataNodeIdentifier) {
- return mandatoryChildSet;
+ public int getMandatoryChildCount() throws DataModelException {
+ return mandatoryChildCount;
}
@Override
@@ -505,23 +567,29 @@
}
/**
- * Adds child schema in child schema map.
+ * Adds child schema in child schema map, this is used to add the schema
+ * to the map in case of leaf as a child.
*
* @param schemaNodeIdentifier YANG schema node identifier
* @param yangSchemaNodeContextInfo YANG data node context information
+ * @throws DataModelException a violation in data model rule
*/
- public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
- YangSchemaNodeContextInfo yangSchemaNodeContextInfo) {
- getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
- }
+ public abstract void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException;
/**
- * Adds mandatory child information to set.
- *
- * @param yangSchemaNode YANG schema node
+ * Increments mandatory child count.
*/
- public void addToMandatoryChildSet(YangSchemaNode yangSchemaNode) {
- mandatoryChildSet.add(yangSchemaNode);
+ public abstract void incrementMandatoryChildCount();
+
+ /**
+ * Sets mandatory child count.
+ *
+ * @param mandatoryChildCount value of mandatory child count
+ */
+ public void setMandatoryChildCount(int mandatoryChildCount) {
+ this.mandatoryChildCount = mandatoryChildCount;
}
/**
@@ -530,9 +598,8 @@
* @param yangSchemaNodeIdentifier YANG schema node identifier
* @param yangSchemaNode YANG schema node
*/
- public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
- getDefaultChildMap().put(yangSchemaNodeIdentifier, yangSchemaNode);
- }
+ public abstract void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier,
+ YangSchemaNode yangSchemaNode);
/**
* Returns default child map.
@@ -555,5 +622,44 @@
@Override
public abstract YangSchemaNodeType getYangSchemaNodeType();
+ /**
+ * Returns the name space of module elements.
+ *
+ * @return the nameSpace
+ */
+ public YangNameSpace getNameSpace() {
+ return nameSpace;
+ }
+ /**
+ * Sets the name space of module elements.
+ *
+ * @param nameSpace the nameSpace to set
+ */
+ public void setNameSpace(YangNameSpace nameSpace) {
+ this.nameSpace = nameSpace;
+ }
+
+ /**
+ * Adds namespace for self, next sibling and first child. This is used
+ * after obtaining namespace in case of submodule after performing
+ * linking.
+ */
+ public void setNameSpaceAndAddToParentSchemaMap() {
+ // Get parent namespace.
+ if (this.getParent() != null) {
+ YangNameSpace nameSpace = this.getParent().getNameSpace();
+ // Set namespace for self node.
+ setNameSpace(nameSpace);
+ // Process addition of leaf to the child schema map of parent.
+ processAdditionOfSchemaNodeToParentMap(getName(), getNameSpace().getUri());
+ }
+ /*
+ * Check if node contains leaf/leaf-list, if yes add namespace for leaf
+ * and leaf list.
+ */
+ if (this instanceof YangLeavesHolder) {
+ ((YangLeavesHolder) this).setLeafNameSpaceAndAddToParentSchemaMap();
+ }
+ }
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNotification.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNotification.java
index a3302b7..ea82cc6 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNotification.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNotification.java
@@ -17,9 +17,9 @@
package org.onosproject.yangutils.datamodel;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
-
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.datamodel.utils.YangConstructType;
@@ -83,11 +83,6 @@
private static final long serialVersionUID = 806201611L;
/**
- * Name of the notification.
- */
- private String name;
-
- /**
* Description of notification.
*/
private String description;
@@ -123,12 +118,29 @@
* Create a notification node.
*/
public YangNotification() {
- super(YangNodeType.NOTIFICATION_NODE);
+ super(YangNodeType.NOTIFICATION_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
listOfLeaf = new LinkedList<>();
listOfLeafList = new LinkedList<>();
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
}
@@ -207,16 +219,6 @@
}
@Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
public String getReference() {
return reference;
}
@@ -268,4 +270,16 @@
public List<YangAugmentedInfo> getAugmentedInfoList() {
return yangAugmentedInfo;
}
+
+ @Override
+ public void setLeafNameSpaceAndAddToParentSchemaMap() {
+ // Add namespace for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ // Add namespace for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ }
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangOutput.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangOutput.java
index 8340601..2693b1f 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangOutput.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangOutput.java
@@ -17,6 +17,7 @@
package org.onosproject.yangutils.datamodel;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
@@ -74,11 +75,6 @@
private static final long serialVersionUID = 806201612L;
/**
- * Name of the output.
- */
- private String name;
-
- /**
* List of leaves contained.
*/
private List<YangLeaf> listOfLeaf;
@@ -94,14 +90,50 @@
* Create a rpc output node.
*/
public YangOutput() {
- super(YangNodeType.OUTPUT_NODE);
+ super(YangNodeType.OUTPUT_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
listOfLeaf = new LinkedList<>();
listOfLeafList = new LinkedList<>();
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo1 = new YangSchemaNodeContextInfo();
+ yangSchemaNodeContextInfo1.setSchemaNode(yangSchemaNodeContextInfo.getSchemaNode());
+ yangSchemaNodeContextInfo1.setContextSwitchedNode(this);
+ getParent().addToChildSchemaMap(schemaNodeIdentifier, yangSchemaNodeContextInfo1);
+ }
+
+ @Override
+ public void setNameSpaceAndAddToParentSchemaMap() {
+ // Get parent namespace.
+ YangNameSpace nameSpace = this.getParent().getNameSpace();
+ // Set namespace for self node.
+ setNameSpace(nameSpace);
+ /*
+ * Check if node contains leaf/leaf-list, if yes add namespace for leaf
+ * and leaf list.
+ */
+ setLeafNameSpaceAndAddToParentSchemaMap();
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // For non data nodes, mandatory child to be added to parent node.
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // For non data nodes, default child to be added to parent node.
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
- return YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
+ return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
@Override
@@ -168,16 +200,6 @@
}
@Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
public void addAugmentation(YangAugmentedInfo augmentInfo) {
yangAugmentedInfo.add(augmentInfo);
}
@@ -191,4 +213,16 @@
public List<YangAugmentedInfo> getAugmentedInfoList() {
return yangAugmentedInfo;
}
+
+ @Override
+ public void setLeafNameSpaceAndAddToParentSchemaMap() {
+ // Add namespace for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ // Add namespace for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ }
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRpc.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRpc.java
index d6e71d3..96abbe6 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRpc.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRpc.java
@@ -16,6 +16,7 @@
package org.onosproject.yangutils.datamodel;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
@@ -64,11 +65,6 @@
private static final long serialVersionUID = 806201613L;
/**
- * Name of the rpc.
- */
- private String name;
-
- /**
* Description of rpc.
*/
private String description;
@@ -92,7 +88,37 @@
* Create a rpc node.
*/
public YangRpc() {
- super(YangNodeType.RPC_NODE);
+ super(YangNodeType.RPC_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
+ }
+
+ @Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ /*
+ * This will maintain all child schema which are there inside input and
+ * output as input/output is non data node.
+ */
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ /*
+ * This will maintain all mandatory child which are there inside input and
+ * output as input/output is non data node.
+ */
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier,
+ YangSchemaNode yangSchemaNode) {
+ /*
+ * This will maintain all default child which are there inside input and
+ * output as input/output is non data node.
+ */
+ // TODO
}
@Override
@@ -101,16 +127,6 @@
}
@Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
// Detect colliding child.
detectCollidingChildUtil(identifierName, dataType, this);
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java
index 3c5241c..8a48637 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java
@@ -17,7 +17,7 @@
package org.onosproject.yangutils.datamodel;
import java.util.Map;
-import java.util.Set;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
/**
* Abstraction of YANG data node, used by YMS to abstractly refer the data
@@ -42,13 +42,13 @@
YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier);
/**
- * Returns set of mandatory child nodes, this is used by YMS to identify whether
+ * Returns count of mandatory child nodes, this is used by YMS to identify whether
* in request all mandatory child nodes are available.
*
- * @param dataNodeIdentifier YANG data node identifier
- * @return set of YANG schema nodes
+ * @return count of YANG schema nodes
+ * @throws DataModelException a violation in data model rule
*/
- Set<YangSchemaNode> getMandatoryChildSet(YangSchemaNodeIdentifier dataNodeIdentifier);
+ int getMandatoryChildCount() throws DataModelException;
/**
* Returns map of default child nodes, this is used by YMS to identify whether
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
index fb0316a..1022db9 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.yangutils.datamodel;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -86,11 +87,6 @@
private static final long serialVersionUID = 806201614L;
/**
- * Name of sub module.
- */
- private String name;
-
- /**
* Module to which it belongs to.
*/
private YangBelongsTo belongsTo;
@@ -241,7 +237,7 @@
* Creates a sub module node.
*/
public YangSubModule() {
- super(YangNodeType.SUB_MODULE_NODE);
+ super(YangNodeType.SUB_MODULE_NODE, new HashMap<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo>());
derivedTypeResolutionList = new LinkedList<>();
augmentResolutionList = new LinkedList<>();
usesResolutionList = new LinkedList<>();
@@ -259,31 +255,27 @@
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo) {
+ getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
}
/**
- * Returns the YANG name of the sub module.
- *
- * @return YANG name of the sub module
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets YANG name of the sub module.
- *
- * @param subModuleName YANG name of the sub module
- */
- @Override
- public void setName(String subModuleName) {
- name = subModuleName;
- }
-
- /**
* Returns the module info.
*
* @return the belongs to info
@@ -661,6 +653,7 @@
public void linkWithModule(Set<YangNode> yangNodeSet)
throws DataModelException {
getBelongsTo().linkWithModule(yangNodeSet);
+ setNameSpace(getBelongsTo().getModuleNode().getNameSpace());
}
@Override
@@ -734,4 +727,17 @@
public void setExtensionList(List<YangExtension> extensionList) {
this.extensionList = extensionList;
}
+
+ @Override
+ public void setLeafNameSpaceAndAddToParentSchemaMap() {
+ // Add namespace for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ // Add namespace for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
+ }
+ }
+
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
index cda165e..a786e98 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
@@ -83,11 +83,6 @@
private YangStatusType status;
/**
- * Name of the typedef.
- */
- private String name;
-
- /**
* Units of the data type.
*/
private String units;
@@ -102,11 +97,30 @@
* Creates a typedef node.
*/
public YangTypeDef() {
- super(YangNodeType.TYPEDEF_NODE);
+ super(YangNodeType.TYPEDEF_NODE, null);
typeList = new LinkedList<>();
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ // Do nothing.
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // Do nothing, to be handled during linking.
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // Do nothing, to be handled during linking.
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
@@ -260,26 +274,6 @@
}
}
- /**
- * Returns the YANG name of the typedef.
- *
- * @return YANG name of the typedef
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets YANG name of the typedef.
- *
- * @param name YANG name of the typedef
- */
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
@Override
public List<YangType<?>> getTypeList() {
return typeList;
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java
index 49a4fc9..eac0ff1 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java
@@ -55,9 +55,6 @@
// List of YANG type.
private List<YangType<?>> typeList;
- // Name of union.
- private String name;
-
// Current child union number.
private transient int childUnionNumber;
@@ -65,12 +62,31 @@
* Creates a YANG union node.
*/
public YangUnion() {
- super(YangNodeType.UNION_NODE);
+ super(YangNodeType.UNION_NODE, null);
typeList = new LinkedList<>();
childUnionNumber = 1;
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ // Do nothing.
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // Do nothing, as leaf can't come directly or indirectly below this construct.
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+ // Do nothing, as leaf can't come directly or indirectly below this construct.
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
@@ -122,26 +138,6 @@
getTypeList().add(yangType);
}
- /**
- * Returns union name.
- *
- * @return the union name
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Sets the union name.
- *
- * @param name union name
- */
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
@Override
public YangConstructType getYangConstructType() {
return YangConstructType.UNION_DATA;
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
index 855b7d1..db0eeb9 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
@@ -144,7 +144,7 @@
* Creates an YANG uses node.
*/
public YangUses() {
- super(YangNodeType.USES_NODE);
+ super(YangNodeType.USES_NODE, null);
nodeIdentifier = new YangNodeIdentifier();
resolvableStatus = ResolvableStatus.UNRESOLVED;
resolvedGroupingNodes = new LinkedList<YangNode>();
@@ -153,6 +153,26 @@
}
@Override
+ public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ throws DataModelException {
+ // Do nothing.
+ }
+
+ @Override
+ public void incrementMandatoryChildCount() {
+ // Do nothing.
+ // TODO
+ }
+
+ @Override
+ public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier,
+ YangSchemaNode yangSchemaNode) {
+ // Do nothing.
+ // TODO
+ }
+
+ @Override
public YangSchemaNodeType getYangSchemaNodeType() {
return YangSchemaNodeType.YANG_NON_DATA_NODE;
}
@@ -319,16 +339,6 @@
// TODO auto-generated method stub, to be implemented by parser
}
- @Override
- public String getName() {
- return nodeIdentifier.getName();
- }
-
- @Override
- public void setName(String name) {
- nodeIdentifier.setName(name);
- }
-
/**
* Returns node identifier.
*
@@ -673,12 +683,31 @@
this.ifFeatureList = ifFeatureList;
}
+ /**
+ * Sets the current grouping depth.
+ *
+ * @param currentGroupingDepth current grouping depth
+ */
public void setCurrentGroupingDepth(int currentGroupingDepth) {
this.currentGroupingDepth = currentGroupingDepth;
}
+ /**
+ * Returns the current grouping depth.
+ *
+ * @return current grouping depth
+ */
public int getCurrentGroupingDepth() {
return currentGroupingDepth;
}
+ @Override
+ public String getName() {
+ return nodeIdentifier.getName();
+ }
+
+ @Override
+ public void setName(String name) {
+ nodeIdentifier.setName(name);
+ }
}
diff --git a/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java b/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
index 815f220..17c3238 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
@@ -21,7 +21,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-
import org.onosproject.yangutils.datamodel.ResolvableType;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangReferenceResolver;
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java
index 6d3a97e..6850c62 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java
@@ -36,8 +36,7 @@
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.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;
@@ -91,10 +90,10 @@
* (leaf-list), performs validation and updates the data model tree.
*
* @param listener listener's object
- * @param ctx context object of the grammar rule
+ * @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);
@@ -131,10 +130,10 @@
* validation and updates the data model tree.
*
* @param listener listener's object
- * @param ctx context object of the grammar rule
+ * @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);
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java
index ad59e12..ed100a0 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java
@@ -40,10 +40,9 @@
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.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CONTENT;
+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.ListenerUtil.getValidIdentifier;
@@ -95,10 +94,10 @@
* (leaf), performs validation and updates the data model tree.
*
* @param listener listener's object
- * @param ctx context object of the grammar rule
+ * @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);
@@ -136,10 +135,10 @@
* validation and updates the data model tree.
*
* @param listener listener's object
- * @param ctx context object of the grammar rule
+ * @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);
@@ -150,7 +149,7 @@
leafNode.validateDataOnExit();
} catch (DataModelException e) {
throw new ParserException(constructListenerErrorMessage(INVALID_CONTENT, LEAF_DATA,
- ctx.identifier().getText(), EXIT));
+ ctx.identifier().getText(), EXIT));
}
listener.getParsedDataStack().pop();
} else {
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
index 6f0fe42..f9a95bd 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
@@ -19,7 +19,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-
import org.onosproject.yangutils.datamodel.TraversalType;
import org.onosproject.yangutils.datamodel.YangAugment;
import org.onosproject.yangutils.datamodel.YangCase;
@@ -31,9 +30,9 @@
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangOutput;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.utils.io.YangPluginConfig;
import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException;
import org.onosproject.yangutils.translator.exception.TranslatorException;
+import org.onosproject.yangutils.utils.io.YangPluginConfig;
import static org.onosproject.yangutils.datamodel.TraversalType.CHILD;
import static org.onosproject.yangutils.datamodel.TraversalType.PARENT;
@@ -115,6 +114,7 @@
setCurNode(codeGenNode);
try {
generateCodeEntry(codeGenNode, yangPlugin);
+ codeGenNode.setNameSpaceAndAddToParentSchemaMap();
} catch (InvalidNodeForTranslatorException e) {
if (codeGenNode.getNextSibling() != null) {
curTraversal = SIBILING;