[ONOS-3902, ONOS-3903, ONOS-3904] string type, integer type derrived type
Change-Id: I8279e93fcb7dfb82491cc09057c9d75165add68d
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangAppErrorInfo.java b/src/main/java/org/onosproject/yangutils/datamodel/YangAppErrorInfo.java
new file mode 100644
index 0000000..9b3ba3f
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangAppErrorInfo.java
@@ -0,0 +1,47 @@
+/*Copyright 2016.year 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;
+
+/**
+ * Abstraction of error message and application info processing.
+ */
+public interface YangAppErrorInfo {
+ /**
+ * Get the application's error message for data error.
+ *
+ * @return application's error message for data error.
+ */
+ String getGetErrorMessage();
+
+ /**
+ * Set the application's error message for data error.
+ *
+ * @param errorMessage application's error message for data error.
+ */
+ void setErrorMessage(String errorMessage);
+
+ /**
+ * Get the application's error tag for data error.
+ *
+ * @return application's error tag for data error.
+ */
+ String getGetErrorAppTag();
+
+ /**
+ * Set the application's error tag for data error.
+ *
+ * @param errorMessage application's error tag for data error.
+ */
+ void setErrorAppTag(String errorMessage);
+}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java b/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
index 3f34922..378eaf4 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
@@ -92,12 +92,12 @@
/**
* List of leaves.
*/
- private List<YangLeaf<?>> listOfLeaf;
+ private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists.
*/
- private List<YangLeafList<?>> listOfLeafList;
+ private List<YangLeafList> listOfLeafList;
/**
* reference.
@@ -110,6 +110,11 @@
private YangStatusType status;
/**
+ * package of the generated java code.
+ */
+ private String pkg;
+
+ /**
* Create a YANG augment node.
*/
public YangAugment() {
@@ -160,7 +165,7 @@
* @return the list of leaves.
*/
@Override
- public List<YangLeaf<?>> getListOfLeaf() {
+ public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
@@ -169,7 +174,7 @@
*
* @param leafsList the list of leaf to set.
*/
- private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
+ private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
@@ -179,9 +184,9 @@
* @param leaf the leaf to be added.
*/
@Override
- public void addLeaf(YangLeaf<?> leaf) {
+ public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<YangLeaf<?>>());
+ setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
@@ -193,7 +198,7 @@
* @return the list of leaf-list.
*/
@Override
- public List<YangLeafList<?>> getListOfLeafList() {
+ public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
@@ -202,7 +207,7 @@
*
* @param listOfLeafList the list of leaf-list to set.
*/
- private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
+ private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
@@ -212,9 +217,9 @@
* @param leafList the leaf-list to be added.
*/
@Override
- public void addLeafList(YangLeafList<?> leafList) {
+ public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<YangLeafList<?>>());
+ setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
@@ -290,44 +295,51 @@
// TODO auto-generated method stub, to be implemented by parser
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getName()
+ /**
+ * Get the target nodes name where the augmentation is being done.
+ *
+ * @return target nodes name where the augmentation is being done.
*/
@Override
public String getName() {
- // TODO Auto-generated method stub
- return null;
+ return targetNode;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
+ /**
+ * Set 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) {
- // TODO Auto-generated method stub
+ targetNode = name;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
+ /**
+ * Get the mapped java package.
+ *
+ * @return the java package
*/
@Override
public String getPackage() {
- // TODO Auto-generated method stub
- return null;
+ return pkg;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
+ /**
+ * Set the mapped java package.
+ *
+ * @param pakg the package to set
*/
@Override
- public void setPackage(String pkg) {
- // TODO Auto-generated method stub
+ public void setPackage(String pakg) {
+ pkg = pakg;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
+ /**
+ * Prepare the information for java code generation corresponding to YANG
+ * grouping info.
*/
@Override
public void generateJavaCodeEntry() {
@@ -335,8 +347,8 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
+ /**
+ * Create a java file using the YANG grouping info.
*/
@Override
public void generateJavaCodeExit() {
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java b/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java
index 0dbc7ed..a4a5cae 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java
@@ -114,6 +114,7 @@
*
* @return ParsedDataType returns BELONGS_TO_DATA
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.BELONGS_TO_DATA;
}
@@ -123,6 +124,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
@@ -132,6 +134,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangBit.java b/src/main/java/org/onosproject/yangutils/datamodel/YangBit.java
index 722f239..5e33e36 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangBit.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangBit.java
@@ -101,6 +101,7 @@
*
* @return the description.
*/
+ @Override
public String getDescription() {
return description;
}
@@ -110,6 +111,7 @@
*
* @param description set the description.
*/
+ @Override
public void setDescription(String description) {
this.description = description;
}
@@ -119,6 +121,7 @@
*
* @return the reference.
*/
+ @Override
public String getReference() {
return reference;
}
@@ -128,6 +131,7 @@
*
* @param reference the reference to set.
*/
+ @Override
public void setReference(String reference) {
this.reference = reference;
}
@@ -137,6 +141,7 @@
*
* @return the status.
*/
+ @Override
public YangStatusType getStatus() {
return status;
}
@@ -146,6 +151,7 @@
*
* @param status the status to set.
*/
+ @Override
public void setStatus(YangStatusType status) {
this.status = status;
}
@@ -173,6 +179,7 @@
*
* @return ParsedDataType returns BIT_DATA
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.BIT_DATA;
}
@@ -182,6 +189,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
@@ -191,6 +199,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangBits.java b/src/main/java/org/onosproject/yangutils/datamodel/YangBits.java
index d158e4c..d519925 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangBits.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangBits.java
@@ -77,6 +77,7 @@
*
* @return ParsedDataType returns BITS_DATA
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.BITS_DATA;
}
@@ -86,6 +87,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
@@ -95,6 +97,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java b/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
index bcfa70c..dc9f36b 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
@@ -89,7 +89,8 @@
/**
* Data model node to maintain information defined in YANG case.
*/
-public class YangCase extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
+public class YangCase extends YangNode
+ implements YangLeavesHolder, YangCommonInfo, Parsable {
/**
* Case name.
@@ -106,12 +107,12 @@
/**
* List of leaves.
*/
- private List<YangLeaf<?>> listOfLeaf;
+ private List<YangLeaf> listOfLeaf;
/**
* List of leaf lists.
*/
- private List<YangLeafList<?>> listOfLeafList;
+ private List<YangLeafList> listOfLeafList;
/**
* Reference of the module.
@@ -124,22 +125,31 @@
private YangStatusType status;
/**
+ * package of the generated java code.
+ */
+ private String pkg;
+
+ /**
* Create a choice node.
*/
public YangCase() {
super(YangNodeType.CASE_NODE);
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getName()
+ /**
+ * Get the case name.
+ *
+ * @return case name.
*/
@Override
public String getName() {
return name;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
+ /**
+ * Set the case name.
+ *
+ * @param name case name.
*/
@Override
public void setName(String name) {
@@ -172,7 +182,7 @@
* @return the list of leaves.
*/
@Override
- public List<YangLeaf<?>> getListOfLeaf() {
+ public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
@@ -181,7 +191,7 @@
*
* @param leafsList the list of leaf to set.
*/
- private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
+ private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
@@ -191,9 +201,9 @@
* @param leaf the leaf to be added.
*/
@Override
- public void addLeaf(YangLeaf<?> leaf) {
+ public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<YangLeaf<?>>());
+ setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
@@ -205,7 +215,7 @@
* @return the list of leaf-list.
*/
@Override
- public List<YangLeafList<?>> getListOfLeafList() {
+ public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
@@ -214,7 +224,7 @@
*
* @param listOfLeafList the list of leaf-list to set.
*/
- private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
+ private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
@@ -224,9 +234,9 @@
* @param leafList the leaf-list to be added.
*/
@Override
- public void addLeafList(YangLeafList<?> leafList) {
+ public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<YangLeafList<?>>());
+ setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
@@ -302,26 +312,29 @@
// TODO auto-generated method stub, to be implemented by parser
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
+ /**
+ * Get the mapped java package.
+ *
+ * @return the java package
*/
@Override
public String getPackage() {
- // TODO Auto-generated method stub
- return null;
+ return pkg;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
+ /**
+ * Set the mapped java package.
+ *
+ * @param pakg the package to set
*/
@Override
- public void setPackage(String pkg) {
- // TODO Auto-generated method stub
+ public void setPackage(String pakg) {
+ pkg = pakg;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
+ /**
+ * Generate the code corresponding to YANG case info.
*/
@Override
public void generateJavaCodeEntry() {
@@ -329,8 +342,9 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
+ /**
+ * Free resource used for generating code and generate valid java files
+ * corresponding to YANG case info.
*/
@Override
public void generateJavaCodeExit() {
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java b/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
index 62a589a..7957a1a 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
@@ -109,12 +109,12 @@
/**
* List of leaves contained.
*/
- private List<YangLeaf<?>> listOfLeaf;
+ private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists contained.
*/
- private List<YangLeafList<?>> listOfLeafList;
+ private List<YangLeafList> listOfLeafList;
/**
* If it is a presence container, then the textual documentation of presence
@@ -130,7 +130,7 @@
/**
* Status of the node.
*/
- private YangStatusType status;
+ private YangStatusType status = YangStatusType.CURRENT;
/**
* Package of the generated java code.
@@ -149,16 +149,20 @@
super(YangNodeType.CONTAINER_NODE);
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getName()
+ /**
+ * Get the YANG name of container.
+ *
+ * @return the name of container as defined in YANG file.
*/
@Override
public String getName() {
return name;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
+ /**
+ * Set the YANG name of container.
+ *
+ * @param name the name of container as defined in YANG file.
*/
@Override
public void setName(String name) {
@@ -209,7 +213,7 @@
* @return the list of leaves.
*/
@Override
- public List<YangLeaf<?>> getListOfLeaf() {
+ public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
@@ -218,7 +222,7 @@
*
* @param leafsList the list of leaf to set.
*/
- private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
+ private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
@@ -228,9 +232,9 @@
* @param leaf the leaf to be added.
*/
@Override
- public void addLeaf(YangLeaf<?> leaf) {
+ public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<YangLeaf<?>>());
+ setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
@@ -242,7 +246,7 @@
* @return the list of leaf-list.
*/
@Override
- public List<YangLeafList<?>> getListOfLeafList() {
+ public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
@@ -251,7 +255,7 @@
*
* @param listOfLeafList the list of leaf-list to set.
*/
- private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
+ private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
@@ -261,9 +265,9 @@
* @param leafList the leaf-list to be added.
*/
@Override
- public void addLeafList(YangLeafList<?> leafList) {
+ public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<YangLeafList<?>>());
+ setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
@@ -397,6 +401,11 @@
pkg = pcg;
}
+ /**
+ * Generate the java code corresponding to YANG container.
+ *
+ * @throws IOException when fails to generate the source files.
+ */
@Override
public void generateJavaCodeEntry() throws IOException {
YangNode parent = getParent();
@@ -416,8 +425,6 @@
/**
* Adds current node attribute to parent file.
- *
- * @param pkg java file package path
*/
private void addAttributeInParent() {
if (getParent() != null) {
@@ -439,9 +446,9 @@
*/
private void addLeavesAttributes() {
- List<YangLeaf<?>> leaves = getListOfLeaf();
+ List<YangLeaf> leaves = getListOfLeaf();
if (leaves != null) {
- for (YangLeaf<?> leaf : leaves) {
+ for (YangLeaf leaf : leaves) {
getFileHandle().addAttributeInfo(leaf.getDataType(), leaf.getLeafName(), false);
}
}
@@ -451,9 +458,9 @@
* Adds leaf list's attributes in generated files.
*/
private void addLeafListAttributes() {
- List<YangLeafList<?>> leavesList = getListOfLeafList();
+ List<YangLeafList> leavesList = getListOfLeafList();
if (leavesList != null) {
- for (YangLeafList<?> leafList : leavesList) {
+ for (YangLeafList leafList : leavesList) {
getFileHandle().addAttributeInfo(leafList.getDataType(), leafList.getLeafName(), true);
}
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangEnum.java b/src/main/java/org/onosproject/yangutils/datamodel/YangEnum.java
index be3f845..59da354 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangEnum.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangEnum.java
@@ -105,6 +105,7 @@
*
* @return the description.
*/
+ @Override
public String getDescription() {
return description;
}
@@ -114,6 +115,7 @@
*
* @param description set the description.
*/
+ @Override
public void setDescription(String description) {
this.description = description;
}
@@ -123,6 +125,7 @@
*
* @return the reference.
*/
+ @Override
public String getReference() {
return reference;
}
@@ -132,6 +135,7 @@
*
* @param reference the reference to set.
*/
+ @Override
public void setReference(String reference) {
this.reference = reference;
}
@@ -141,6 +145,7 @@
*
* @return the status.
*/
+ @Override
public YangStatusType getStatus() {
return status;
}
@@ -150,6 +155,7 @@
*
* @param status the status to set.
*/
+ @Override
public void setStatus(YangStatusType status) {
this.status = status;
}
@@ -177,6 +183,7 @@
*
* @return ParsedDataType returns ENUM_DATA
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.ENUM_DATA;
}
@@ -186,6 +193,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
@@ -195,6 +203,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java b/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java
index 8dc0123..4e3061d 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangGrouping.java
@@ -76,7 +76,8 @@
/**
* Data model node to maintain information defined in YANG grouping.
*/
-public class YangGrouping extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
+public class YangGrouping extends YangNode
+ implements YangLeavesHolder, YangCommonInfo, Parsable {
/**
* Name of the grouping.
@@ -91,12 +92,12 @@
/**
* List of leaves.
*/
- private List<YangLeaf<?>> listOfLeaf;
+ private List<YangLeaf> listOfLeaf;
/**
* List of leaf lists.
*/
- private List<YangLeafList<?>> listOfLeafList;
+ private List<YangLeafList> listOfLeafList;
/**
* Reference of the module.
@@ -109,22 +110,31 @@
private YangStatusType status;
/**
+ * package of the generated java code.
+ */
+ private String pkg;
+
+ /**
* Creates the grouping node.
*/
public YangGrouping() {
super(YangNodeType.GROUPING_NODE);
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getName()
+ /**
+ * Get YANG grouping name.
+ *
+ * @return YANG grouping name.
*/
@Override
public String getName() {
return name;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
+ /**
+ * Set YANG grouping name.
+ *
+ * @param name YANG grouping name.
*/
@Override
public void setName(String name) {
@@ -157,7 +167,7 @@
* @return the list of leaves.
*/
@Override
- public List<YangLeaf<?>> getListOfLeaf() {
+ public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
@@ -166,7 +176,7 @@
*
* @param leafsList the list of leaf to set.
*/
- private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
+ private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
@@ -176,9 +186,9 @@
* @param leaf the leaf to be added.
*/
@Override
- public void addLeaf(YangLeaf<?> leaf) {
+ public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<YangLeaf<?>>());
+ setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
@@ -190,7 +200,7 @@
* @return the list of leaf-list.
*/
@Override
- public List<YangLeafList<?>> getListOfLeafList() {
+ public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
@@ -199,7 +209,7 @@
*
* @param listOfLeafList the list of leaf-list to set.
*/
- private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
+ private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
@@ -209,9 +219,9 @@
* @param leafList the leaf-list to be added.
*/
@Override
- public void addLeafList(YangLeafList<?> leafList) {
+ public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<YangLeafList<?>>());
+ setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
@@ -287,8 +297,8 @@
// TODO auto-generated method stub, to be implemented by parser
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
+ /**
+ * Generate the code for YANG grouping.
*/
@Override
public void generateJavaCodeEntry() {
@@ -296,8 +306,9 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
+ /**
+ * Free the resources used to generate java files corresponding to YANG
+ * grouping info and generate valid java files.
*/
@Override
public void generateJavaCodeExit() {
@@ -305,21 +316,24 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
+ /**
+ * Get the mapped java package.
+ *
+ * @return the java package
*/
@Override
public String getPackage() {
- // TODO Auto-generated method stub
- return null;
+ return pkg;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
+ /**
+ * Set the mapped java package.
+ *
+ * @param pakg the package to set
*/
@Override
- public void setPackage(String pkg) {
- // TODO Auto-generated method stub
+ public void setPackage(String pakg) {
+ pkg = pakg;
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java b/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
index cf18a62..83f978e 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
@@ -76,6 +76,7 @@
/**
* Reference:RFC 6020.
+ *
* The import's "revision-date" statement is used to specify the exact
* version of the module to import. The "revision-date" statement MUST match
* the most recent "revision" statement in the imported module. organization
@@ -150,6 +151,7 @@
*
* @return returns IMPORT_DATA
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.IMPORT_DATA;
}
@@ -159,6 +161,7 @@
*
* @throws DataModelException a violation of data model rules
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
@@ -169,6 +172,7 @@
*
* @throws DataModelException a violation of data model rules
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java b/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
index de7355c..a506847 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
@@ -97,6 +97,7 @@
*
* @return returns INCLUDE_DATA
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.INCLUDE_DATA;
}
@@ -106,6 +107,7 @@
*
* @throws DataModelException a violation of data model rules
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
@@ -116,6 +118,7 @@
*
* @throws DataModelException a violation of data model rules
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java b/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
index d2837da..764f498 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
@@ -56,9 +56,8 @@
/**
* Leaf data represented in YANG.
*
- * @param <T> YANG data type
*/
-public class YangLeaf<T> implements YangCommonInfo, Parsable {
+public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Name of leaf.
@@ -88,7 +87,7 @@
/**
* Status of leaf in YANG definition.
*/
- private YangStatusType status;
+ private YangStatusType status = YangStatusType.CURRENT;
/**
* Textual units info.
@@ -98,7 +97,7 @@
/**
* Data type of the leaf.
*/
- private YangType<T> dataType;
+ private YangType<?> dataType;
/**
* Default constructor to create a YANG leaf.
@@ -121,7 +120,7 @@
* @param leafName the leaf name to set.
*/
public void setLeafName(String leafName) {
- this.name = leafName;
+ name = leafName;
}
/**
@@ -147,6 +146,7 @@
*
* @return the description.
*/
+ @Override
public String getDescription() {
return description;
}
@@ -156,6 +156,7 @@
*
* @param description set the description.
*/
+ @Override
public void setDescription(String description) {
this.description = description;
}
@@ -183,6 +184,7 @@
*
* @return the reference.
*/
+ @Override
public String getReference() {
return reference;
}
@@ -192,6 +194,7 @@
*
* @param reference the reference to set.
*/
+ @Override
public void setReference(String reference) {
this.reference = reference;
}
@@ -201,6 +204,7 @@
*
* @return the status.
*/
+ @Override
public YangStatusType getStatus() {
return status;
}
@@ -210,6 +214,7 @@
*
* @param status the status to set.
*/
+ @Override
public void setStatus(YangStatusType status) {
this.status = status;
}
@@ -237,7 +242,7 @@
*
* @return the data type.
*/
- public YangType<T> getDataType() {
+ public YangType<?> getDataType() {
return dataType;
}
@@ -246,7 +251,7 @@
*
* @param dataType the data type to set.
*/
- public void setDataType(YangType<T> dataType) {
+ public void setDataType(YangType<?> dataType) {
this.dataType = dataType;
}
@@ -255,6 +260,7 @@
*
* @return returns LEAF_DATA.
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.LEAF_DATA;
}
@@ -264,6 +270,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
@@ -274,6 +281,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java b/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
index d005458..18653d2 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
@@ -51,10 +51,8 @@
*/
/**
* Leaf-list data represented in YANG.
- *
- * @param <T> YANG data type
*/
-public class YangLeafList<T> implements YangCommonInfo, Parsable {
+public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Name of leaf-list.
@@ -73,6 +71,7 @@
/**
* Reference:RFC 6020.
+ *
* The "max-elements" statement, which is optional, takes as an argument a
* positive integer or the string "unbounded", which puts a constraint on
* valid list entries. A valid leaf-list or list always has at most
@@ -80,10 +79,11 @@
*
* If no "max-elements" statement is present, it defaults to "unbounded".
*/
- private int maxElelements;
+ private int maxElelements = Integer.MAX_VALUE;
/**
* Reference:RFC 6020.
+ *
* The "min-elements" statement, which is optional, takes as an argument a
* non-negative integer that puts a constraint on valid list entries. A
* valid leaf-list or list MUST have at least min-elements entries.
@@ -99,7 +99,7 @@
*
* o Otherwise, it is enforced if the ancestor node exists.
*/
- private int minElements;
+ private int minElements = 0;
/**
* The textual reference to this leaf-list.
@@ -109,7 +109,7 @@
/**
* Status of the leaf-list in the YANG definition.
*/
- private YangStatusType status;
+ private YangStatusType status = YangStatusType.CURRENT;
/**
* Textual units.
@@ -119,7 +119,7 @@
/**
* Data type of leaf-list.
*/
- private YangType<T> dataType;
+ private YangType<?> dataType;
/**
* Default Constructor to create a YANG leaf-list.
@@ -142,7 +142,7 @@
* @param leafListName the leaf-list name to set.
*/
public void setLeafName(String leafListName) {
- this.name = leafListName;
+ name = leafListName;
}
/**
@@ -168,6 +168,7 @@
*
* @return the description.
*/
+ @Override
public String getDescription() {
return description;
}
@@ -177,6 +178,7 @@
*
* @param description set the description.
*/
+ @Override
public void setDescription(String description) {
this.description = description;
}
@@ -222,6 +224,7 @@
*
* @return the reference.
*/
+ @Override
public String getReference() {
return reference;
}
@@ -231,6 +234,7 @@
*
* @param reference the reference to set.
*/
+ @Override
public void setReference(String reference) {
this.reference = reference;
}
@@ -240,6 +244,7 @@
*
* @return the status.
*/
+ @Override
public YangStatusType getStatus() {
return status;
}
@@ -249,6 +254,7 @@
*
* @param status the status to set.
*/
+ @Override
public void setStatus(YangStatusType status) {
this.status = status;
}
@@ -276,7 +282,7 @@
*
* @return the data type.
*/
- public YangType<T> getDataType() {
+ public YangType<?> getDataType() {
return dataType;
}
@@ -285,7 +291,7 @@
*
* @param dataType the data type to set.
*/
- public void setDataType(YangType<T> dataType) {
+ public void setDataType(YangType<?> dataType) {
this.dataType = dataType;
}
@@ -294,6 +300,7 @@
*
* @return returns LEAF_LIST_DATA.
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.LEAF_LIST_DATA;
}
@@ -303,6 +310,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
@@ -313,6 +321,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java b/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java
index ba42bfc..f8fc6b6 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java
@@ -27,26 +27,26 @@
*
* @return the list of leaves.
*/
- public List<YangLeaf<?>> getListOfLeaf();
+ public List<YangLeaf> getListOfLeaf();
/**
* Add a leaf in data holder like container / list.
*
* @param leaf the leaf to be added.
*/
- void addLeaf(YangLeaf<?> leaf);
+ void addLeaf(YangLeaf leaf);
/**
* Get the list of leaf-list from data holder like container / list.
*
* @return the list of leaf-list.
*/
- List<YangLeafList<?>> getListOfLeafList();
+ List<YangLeafList> getListOfLeafList();
/**
* Add a leaf-list in data holder like container / list.
*
* @param leafList the leaf-list to be added.
*/
- void addLeafList(YangLeafList<?> leafList);
+ void addLeafList(YangLeafList leafList);
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangList.java b/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
index 577e160..8a328e0 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
@@ -66,7 +66,8 @@
/**
* List data represented in YANG.
*/
-public class YangList extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
+public class YangList extends YangNode
+ implements YangLeavesHolder, YangCommonInfo, Parsable {
/**
* name of the YANG list.
@@ -113,12 +114,12 @@
/**
* List of leaves.
*/
- private List<YangLeaf<?>> listOfLeaf;
+ private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists.
*/
- private List<YangLeafList<?>> listOfLeafList;
+ private List<YangLeafList> listOfLeafList;
/**
* The "max-elements" statement, which is optional, takes as an argument a
@@ -128,7 +129,7 @@
*
* If no "max-elements" statement is present, it defaults to "unbounded".
*/
- private int maxElelements;
+ private int maxElelements = Integer.MAX_VALUE;
/**
* The "min-elements" statement, which is optional, takes as an argument a
@@ -146,7 +147,7 @@
*
* o Otherwise, it is enforced if the ancestor node exists.
*/
- private int minElements;
+ private int minElements = 0;
/**
* reference.
@@ -157,7 +158,12 @@
* Status of the node.
*/
- private YangStatusType status;
+ private YangStatusType status = YangStatusType.CURRENT;
+
+ /**
+ * package of the generated java code.
+ */
+ private String pkg;
/**
* Constructor.
@@ -168,16 +174,20 @@
super(type);
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getName()
+ /**
+ * Get the YANG list name.
+ *
+ * @return YANG list name.
*/
@Override
public String getName() {
return name;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
+ /**
+ * Set the YANG list name.
+ *
+ * @param name YANG list name.
*/
@Override
public void setName(String name) {
@@ -249,7 +259,6 @@
if (getKeyList() == null) {
setKeyList(new LinkedList<String>());
}
-
getKeyList().add(key);
}
@@ -259,7 +268,7 @@
* @return the list of leaves.
*/
@Override
- public List<YangLeaf<?>> getListOfLeaf() {
+ public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
@@ -268,7 +277,7 @@
*
* @param leafsList the list of leaf to set.
*/
- private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
+ private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
@@ -278,9 +287,9 @@
* @param leaf the leaf to be added.
*/
@Override
- public void addLeaf(YangLeaf<?> leaf) {
+ public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<YangLeaf<?>>());
+ setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
@@ -292,7 +301,7 @@
* @return the list of leaf-list.
*/
@Override
- public List<YangLeafList<?>> getListOfLeafList() {
+ public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
@@ -301,7 +310,7 @@
*
* @param listOfLeafList the list of leaf-list to set.
*/
- private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
+ private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
@@ -311,9 +320,9 @@
* @param leafList the leaf-list to be added.
*/
@Override
- public void addLeafList(YangLeafList<?> leafList) {
+ public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<YangLeafList<?>>());
+ setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
@@ -434,8 +443,9 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
+ /**
+ * Free the resources used to generate the java file corresponding to YANG
+ * list info.
*/
@Override
public void generateJavaCodeExit() {
@@ -443,21 +453,24 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
+ /**
+ * Get the mapped java package.
+ *
+ * @return the java package
*/
@Override
public String getPackage() {
- // TODO Auto-generated method stub
- return null;
+ return pkg;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
+ /**
+ * Set the mapped java package.
+ *
+ * @param pakg the package to set
*/
@Override
- public void setPackage(String pkg) {
- // TODO Auto-generated method stub
+ public void setPackage(String pakg) {
+ pkg = pakg;
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java b/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
index d1d3c7e..836ad77 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
@@ -71,7 +71,8 @@
/**
* Data model node to maintain information defined in YANG module.
*/
-public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, YangReference, Parsable, CodeGenerator {
+public class YangModule extends YangNode
+ implements YangLeavesHolder, YangDesc, YangReference, Parsable, CodeGenerator {
/**
* Name of the module.
@@ -112,12 +113,12 @@
/**
* List of leaves at root level in the module.
*/
- private List<YangLeaf<?>> listOfLeaf;
+ private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists at root level in the module.
*/
- private List<YangLeafList<?>> listOfLeafList;
+ private List<YangLeafList> listOfLeafList;
/**
* Name space of the module.
@@ -298,7 +299,7 @@
* @return the list of leaves.
*/
@Override
- public List<YangLeaf<?>> getListOfLeaf() {
+ public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
@@ -307,7 +308,7 @@
*
* @param leafsList the list of leaf to set.
*/
- private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
+ private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
@@ -317,9 +318,9 @@
* @param leaf the leaf to be added.
*/
@Override
- public void addLeaf(YangLeaf<?> leaf) {
+ public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<YangLeaf<?>>());
+ setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
@@ -331,7 +332,7 @@
* @return the list of leaf-list.
*/
@Override
- public List<YangLeafList<?>> getListOfLeafList() {
+ public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
@@ -340,7 +341,7 @@
*
* @param listOfLeafList the list of leaf-list to set.
*/
- private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
+ private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
@@ -350,9 +351,9 @@
* @param leafList the leaf-list to be added.
*/
@Override
- public void addLeafList(YangLeafList<?> leafList) {
+ public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<YangLeafList<?>>());
+ setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
@@ -525,7 +526,10 @@
*/
@Override
public void validateDataOnEntry() throws DataModelException {
- // TODO auto-generated method stub, to be implemented by parser
+ /*
+ * Module is root in the data model tree, hence there is no entry
+ * validation
+ */
}
/**
@@ -535,7 +539,10 @@
*/
@Override
public void validateDataOnExit() throws DataModelException {
- // TODO auto-generated method stub, to be implemented by parser
+ /*
+ * TODO: perform symbol linking for the imported or included YANG info.
+ * TODO: perform symbol resolution for referred YANG entities.
+ */
}
/**
@@ -572,9 +579,9 @@
*/
private void addLeavesAttributes() {
- List<YangLeaf<?>> leaves = getListOfLeaf();
+ List<YangLeaf> leaves = getListOfLeaf();
if (leaves != null) {
- for (YangLeaf<?> leaf : leaves) {
+ for (YangLeaf leaf : leaves) {
getFileHandle().addAttributeInfo(leaf.getDataType(), leaf.getLeafName(), false);
}
}
@@ -584,9 +591,9 @@
* Adds leaf list's attributes in generated files.
*/
private void addLeafListAttributes() {
- List<YangLeafList<?>> leavesList = getListOfLeafList();
+ List<YangLeafList> leavesList = getListOfLeafList();
if (leavesList != null) {
- for (YangLeafList<?> leafList : leavesList) {
+ for (YangLeafList leafList : leavesList) {
getFileHandle().addAttributeInfo(leafList.getDataType(), leafList.getLeafName(), true);
}
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java b/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java
index 92a1da3..63430c1 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java
@@ -92,6 +92,7 @@
*
* @return the description.
*/
+ @Override
public String getDescription() {
return description;
}
@@ -101,6 +102,7 @@
*
* @param description set the description.
*/
+ @Override
public void setDescription(String description) {
this.description = description;
}
@@ -110,6 +112,7 @@
*
* @return the reference.
*/
+ @Override
public String getReference() {
return reference;
}
@@ -119,6 +122,7 @@
*
* @param reference the reference to set.
*/
+ @Override
public void setReference(String reference) {
this.reference = reference;
}
@@ -128,6 +132,7 @@
*
* @return returns MUST_DATA
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.MUST_DATA;
}
@@ -137,6 +142,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
@@ -146,6 +152,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangNameSpace.java b/src/main/java/org/onosproject/yangutils/datamodel/YangNameSpace.java
index 03779bd..2d79a6f 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangNameSpace.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangNameSpace.java
@@ -65,6 +65,7 @@
*
* @return returns NAMESPACE_DATA.
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.NAMESPACE_DATA;
}
@@ -74,6 +75,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
@@ -84,6 +86,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangPatternRestriction.java b/src/main/java/org/onosproject/yangutils/datamodel/YangPatternRestriction.java
new file mode 100644
index 0000000..dca527e
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangPatternRestriction.java
@@ -0,0 +1,102 @@
+/*Copyright 2016.year 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 java.util.List;
+
+/*-
+ * Reference RFC 6020.
+ *
+ * The pattern Statement
+ *
+ * The "pattern" statement, which is an optional sub-statement to the
+ * "type" statement, takes as an argument a regular expression string.
+ * It is used to restrict the built-in type "string", or types derived
+ * from "string", to values that match the pattern.
+ *
+ * If the type has multiple "pattern" statements, the expressions are
+ * ANDed together, i.e., all such expressions have to match.
+ *
+ * If a pattern restriction is applied to an already pattern-restricted
+ * type, values must match all patterns in the base type, in addition to
+ * the new patterns.
+ * The pattern's sub-statements
+ *
+ * +---------------+---------+-------------+
+ * | substatement | section | cardinality |
+ * +---------------+---------+-------------+
+ * | description | 7.19.3 | 0..1 |
+ * | error-app-tag | 7.5.4.2 | 0..1 |
+ * | error-message | 7.5.4.1 | 0..1 |
+ * | reference | 7.19.4 | 0..1 |
+ * +---------------+---------+-------------+
+ */
+/**
+ * Pattern restriction information. The regular expression restriction on string
+ * data type.
+ */
+public class YangPatternRestriction {
+
+ /**
+ * Pattern restriction defined for the current type.
+ */
+ private List<String> pattern;
+
+ /**
+ * Effective pattern restriction that needs inherited from base type.
+ */
+ private List<String> basePattern;
+
+ /**
+ * Default constructor.
+ */
+ public YangPatternRestriction() {
+ }
+
+ /**
+ * Get the pattern restriction defined for the current type.
+ *
+ * @return pattern restriction defined for the current type.
+ */
+ public List<String> getPattern() {
+ return pattern;
+ }
+
+ /**
+ * Set the pattern restriction defined for the current type.
+ *
+ * @param pattern pattern restriction defined for the current type..
+ */
+ public void setPattern(List<String> pattern) {
+ this.pattern = pattern;
+ }
+
+ /**
+ * Get the pattern restriction defined in base type.
+ *
+ * @return pattern restriction defined in base type.
+ */
+ public List<String> getBasePattern() {
+ return basePattern;
+ }
+
+ /**
+ * Set the pattern restriction defined in base type.
+ *
+ * @param basePattern pattern restriction defined in base type.
+ */
+ public void setBasePattern(List<String> basePattern) {
+ this.basePattern = basePattern;
+ }
+}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangRangeInterval.java b/src/main/java/org/onosproject/yangutils/datamodel/YangRangeInterval.java
new file mode 100644
index 0000000..d3061a7
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangRangeInterval.java
@@ -0,0 +1,75 @@
+/*Copyright 2016.year 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;
+
+/**
+ * Single interval information of a range.
+ *
+ * @param <T> range type based on the data type.
+ */
+public class YangRangeInterval<T extends Comparable<T>> {
+
+ /**
+ * Starting value of the range interval.
+ */
+ private T startValue;
+
+ /**
+ * Last value of the range interval.
+ */
+ private T endValue;
+
+ /**
+ * Default constructor.
+ */
+ public YangRangeInterval() {
+ }
+
+ /**
+ * Get the starting value of the range interval.
+ *
+ * @return the starting value of the range interval.
+ */
+ public T getStartValue() {
+ return startValue;
+ }
+
+ /**
+ * Set the starting value of the range interval.
+ *
+ * @param startValue the starting value of the range interval.
+ */
+ public void setStartValue(T startValue) {
+ this.startValue = startValue;
+ }
+
+ /**
+ * Get the last value of the range interval.
+ *
+ * @return last value of the range interval.
+ */
+ public T getEndValue() {
+ return endValue;
+ }
+
+ /**
+ * Set the last value of the range interval.
+ *
+ * @param endValue last value of the range interval.
+ */
+ public void setEndValue(T endValue) {
+ this.endValue = endValue;
+ }
+
+}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java b/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java
new file mode 100644
index 0000000..abbc6c2
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java
@@ -0,0 +1,253 @@
+/*Copyright 2016.year 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 java.util.LinkedList;
+import java.util.List;
+
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/*-
+ * Reference RFC 6020.
+ *
+ * The range Statement
+ *
+ * The "range" statement, which is an optional sub-statement to the
+ * "type" statement, takes as an argument a range expression string. It
+ * is used to restrict integer and decimal built-in types, or types
+ * derived from those.
+ *
+ * A range consists of an explicit value, or a lower-inclusive bound,
+ * two consecutive dots "..", and an upper-inclusive bound. Multiple
+ * values or ranges can be given, separated by "|". If multiple values
+ * or ranges are given, they all MUST be disjoint and MUST be in
+ * ascending order. If a range restriction is applied to an already
+ * range-restricted type, the new restriction MUST be equal or more
+ * limiting, that is raising the lower bounds, reducing the upper
+ * bounds, removing explicit values or ranges, or splitting ranges into
+ * multiple ranges with intermediate gaps. Each explicit value and
+ * range boundary value given in the range expression MUST match the
+ * type being restricted, or be one of the special values "min" or
+ * "max". "min" and "max" mean the minimum and maximum value accepted
+ * for the type being restricted, respectively.
+ */
+/**
+ * Ascending range restriction information.
+ *
+ * @param <T> range type (data type)
+ */
+public class YangRangeRestriction<T extends Comparable<T>> implements YangDesc, YangReference, YangAppErrorInfo {
+
+ /**
+ * Ascending list of range interval restriction. If the restriction is a
+ * single value, the start and end length of the range is same.
+ */
+ private List<YangRangeInterval<T>> ascendingRangeIntervals;
+
+ /**
+ * Textual reference.
+ */
+ private String reference;
+
+ /**
+ * Application's error message, to be used for data error.
+ */
+ private String errorMessage;
+
+ /**
+ * Application's error tag, to be filled in data validation error response.
+ */
+ private String errorAppTag;
+
+ /**
+ * Textual description.
+ */
+ private String description;
+
+ /**
+ * Default constructor.
+ */
+ public YangRangeRestriction() {
+ }
+
+ /**
+ * Get the list of range interval restriction in ascending order.
+ *
+ * @return list of range interval restriction in ascending order.
+ */
+ public List<YangRangeInterval<T>> getAscendingRangeIntervals() {
+ return ascendingRangeIntervals;
+ }
+
+ /**
+ * Set the list of range interval restriction in ascending order.
+ *
+ * @param rangeList list of range interval restriction in ascending order.
+ */
+ private void setAscendingRangeIntervals(List<YangRangeInterval<T>> rangeList) {
+ ascendingRangeIntervals = rangeList;
+ }
+
+ /**
+ * Get the minimum valid value as per the restriction.
+ *
+ * @throws DataModelException data model exception for minimum restriction.
+ *
+ * @return minimum restricted value.
+ */
+ public T getMinRestrictedvalue() throws DataModelException {
+ if (getAscendingRangeIntervals() == null) {
+ throw new DataModelException("No range restriction info");
+ }
+ if (getAscendingRangeIntervals().size() == 0) {
+ throw new DataModelException("No range interval info");
+ }
+ return getAscendingRangeIntervals().get(0).getStartValue();
+ }
+
+ /**
+ * Get the maximum valid value as per the restriction.
+ *
+ * @throws DataModelException data model exception for maximum restriction.
+ *
+ * @return minimum maximum value.
+ */
+ public T getMaxRestrictedvalue() throws DataModelException {
+ if (getAscendingRangeIntervals() == null) {
+ throw new DataModelException("No range restriction info");
+ }
+ if (getAscendingRangeIntervals().size() == 0) {
+ throw new DataModelException("No range interval info");
+ }
+ return getAscendingRangeIntervals()
+ .get(getAscendingRangeIntervals().size() - 1).getEndValue();
+ }
+
+ /**
+ * Add new interval to extend its range in the last. i.e. newly added
+ * interval needs to be bigger than the biggest interval in the list.
+ *
+ * @param newInterval restricted length interval.
+ * @throws DataModelException data model exception for range restriction.
+ */
+ public void addLenghtRestrictionInterval(YangRangeInterval<T> newInterval) throws DataModelException {
+
+ checkNotNull(newInterval);
+ checkNotNull(newInterval.getStartValue());
+
+ if (getAscendingRangeIntervals() == null) {
+ /*
+ * First interval that is being added, and it must be the smallest
+ * interval.
+ */
+ setAscendingRangeIntervals(new LinkedList<YangRangeInterval<T>>());
+ getAscendingRangeIntervals().add(newInterval);
+ return;
+ }
+
+ T curMaxvalue = getMaxRestrictedvalue();
+
+ if (newInterval.getStartValue().compareTo(curMaxvalue) != 1) {
+ throw new DataModelException(
+ "New added range interval is lesser than the old interval(s)");
+ }
+
+ getAscendingRangeIntervals()
+ .add(getAscendingRangeIntervals().size(), newInterval);
+ }
+
+ /**
+ * Get the textual reference of the length restriction.
+ *
+ * @return textual reference of the length restriction.
+ */
+ @Override
+ public String getReference() {
+ return reference;
+ }
+
+ /**
+ * Set the textual reference of the length restriction.
+ *
+ * @param ref textual reference of the length restriction.
+ */
+ @Override
+ public void setReference(String ref) {
+ reference = ref;
+ }
+
+ /**
+ * Get the description of the length restriction.
+ *
+ * @return description of the length restriction.
+ */
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Set the description of the length restriction.
+ *
+ * @param desc description of the length restriction.
+ */
+ @Override
+ public void setDescription(String desc) {
+ description = desc;
+
+ }
+
+ /**
+ * Get application's error message, to be used for data error.
+ *
+ * @return Application's error message, to be used for data error.
+ */
+ @Override
+ public String getGetErrorMessage() {
+ return errorMessage;
+ }
+
+ /**
+ * Set Application's error message, to be used for data error.
+ *
+ * @param errMsg Application's error message, to be used for data error.
+ */
+ @Override
+ public void setErrorMessage(String errMsg) {
+ errorMessage = errMsg;
+
+ }
+
+ /**
+ * Get application's error tag, to be used for data error.
+ *
+ * @return application's error tag, to be used for data error.
+ */
+ @Override
+ public String getGetErrorAppTag() {
+ return errorAppTag;
+ }
+
+ /**
+ * Set application's error tag, to be used for data error.
+ *
+ * @param errTag application's error tag, to be used for data error.
+ */
+ @Override
+ public void setErrorAppTag(String errTag) {
+ errorAppTag = errTag;
+ }
+}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangRevision.java b/src/main/java/org/onosproject/yangutils/datamodel/YangRevision.java
index 7fb293d..8989262 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangRevision.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangRevision.java
@@ -88,6 +88,7 @@
*
* @return the description.
*/
+ @Override
public String getDescription() {
return description;
}
@@ -97,6 +98,7 @@
*
* @param description set the description.
*/
+ @Override
public void setDescription(String description) {
this.description = description;
}
@@ -106,6 +108,7 @@
*
* @return the reference.
*/
+ @Override
public String getReference() {
return reference;
}
@@ -115,6 +118,7 @@
*
* @param reference the reference to set.
*/
+ @Override
public void setReference(String reference) {
this.reference = reference;
}
@@ -124,6 +128,7 @@
*
* @return returns REVISION_DATA.
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.REVISION_DATA;
}
@@ -133,6 +138,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
@@ -143,6 +149,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java b/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java
new file mode 100644
index 0000000..9cccaee
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java
@@ -0,0 +1,115 @@
+/*Copyright 2016.year 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 java.math.BigInteger;
+
+/*-
+ * Reference RFC 6020.
+ *
+ * A string can be restricted with the "length" and "pattern" statements.
+ *
+ */
+/**
+ * The restriction for string data type.
+ */
+public class YangStringRestriction {
+
+ /*-
+ * Reference RFC 6020.
+ * The length Statement
+ *
+ * The "length" statement, which is an optional sub-statement to the
+ * "type" statement, takes as an argument a length expression string.
+ * It is used to restrict the built-in type "string", or types derived
+ * from "string".
+ * A "length" statement restricts the number of unicode characters in
+ * the string.
+ * A length range consists of an explicit value, or a lower bound, two
+ * consecutive dots "..", and an upper bound. Multiple values or ranges
+ * can be given, separated by "|". Length-restricting values MUST NOT
+ * be negative. If multiple values or ranges are given, they all MUST
+ * be disjoint and MUST be in ascending order. If a length restriction
+ * is applied to an already length-restricted type, the new restriction
+ * MUST be equal or more limiting, that is, raising the lower bounds,
+ * reducing the upper bounds, removing explicit length values or ranges,
+ * or splitting ranges into multiple ranges with intermediate gaps. A
+ * length value is a non-negative integer, or one of the special values
+ * "min" or "max". "min" and "max" mean the minimum and maximum length
+ * accepted for the type being restricted, respectively. An
+ * implementation is not required to support a length value larger than
+ * 18446744073709551615.
+ * The length's sub-statements
+ *
+ * +---------------+---------+-------------+-----------------+
+ * | substatement | section | cardinality | mapped data type|
+ * +---------------+---------+-------------+-----------------+
+ * | description | 7.19.3 | 0..1 | string |
+ * | error-app-tag | 7.5.4.2 | 0..1 | string |
+ * | error-message | 7.5.4.1 | 0..1 | string |
+ * | reference | 7.19.4 | 0..1 | string |
+ * +---------------+---------+-------------+-----------------+
+ */
+ /**
+ * Length restriction information.
+ */
+ private YangRangeRestriction<BigInteger> lengthRestriction;
+
+ /**
+ * Effective pattern restriction for the type.
+ */
+ private YangPatternRestriction patternRestriction;
+
+ /**
+ * Default constructor.
+ */
+ public YangStringRestriction() {
+ }
+
+ /**
+ * Get the length restriction on the string data.
+ *
+ * @return length restriction on the string data.
+ */
+ public YangRangeRestriction<BigInteger> getLengthRestriction() {
+ return lengthRestriction;
+ }
+
+ /**
+ * Set the length restriction on the string data.
+ *
+ * @param lengthRestriction length restriction on the string data.
+ */
+ public void setLengthRestriction(YangRangeRestriction<BigInteger> lengthRestriction) {
+ this.lengthRestriction = lengthRestriction;
+ }
+
+ /**
+ * Get the pattern restriction for the type.
+ *
+ * @return pattern restriction for the type.
+ */
+ public YangPatternRestriction getPatternRestriction() {
+ return patternRestriction;
+ }
+
+ /**
+ * Set the pattern restriction for the type.
+ *
+ * @param patternRestriction pattern restriction for the type.
+ */
+ public void setPatternRestriction(YangPatternRestriction patternRestriction) {
+ this.patternRestriction = patternRestriction;
+ }
+}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java b/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
index 04b7cfb..467217e 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
@@ -73,7 +73,8 @@
/**
* Data model node to maintain information defined in YANG sub-module.
*/
-public class YangSubModule extends YangNode implements YangLeavesHolder, YangDesc, YangReference, Parsable {
+public class YangSubModule extends YangNode
+ implements YangLeavesHolder, YangDesc, YangReference, Parsable {
/**
* Name of sub module.
@@ -114,12 +115,12 @@
/**
* List of leaves at root level in the sub-module.
*/
- private List<YangLeaf<?>> listOfLeaf;
+ private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists at root level in the sub-module.
*/
- private List<YangLeafList<?>> listOfLeafList;
+ private List<YangLeafList> listOfLeafList;
/**
* organization owner of the sub-module.
@@ -142,22 +143,31 @@
private byte version;
/**
+ * package of the generated java code.
+ */
+ private String pkg;
+
+ /**
* Create a sub module node.
*/
public YangSubModule() {
super(YangNodeType.SUB_MODULE_NODE);
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getName()
+ /**
+ * Get the YANG name of the sub module.
+ *
+ * @return YANG name of the sub module
*/
@Override
public String getName() {
return name;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
+ /**
+ * Set YANG name of the sub module.
+ *
+ * @param subModuleName YANG name of the sub module
*/
@Override
public void setName(String subModuleName) {
@@ -293,7 +303,7 @@
* @return the list of leaves.
*/
@Override
- public List<YangLeaf<?>> getListOfLeaf() {
+ public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
@@ -302,7 +312,7 @@
*
* @param leafsList the list of leaf to set.
*/
- private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
+ private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
@@ -312,9 +322,9 @@
* @param leaf the leaf to be added.
*/
@Override
- public void addLeaf(YangLeaf<?> leaf) {
+ public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
- setListOfLeaf(new LinkedList<YangLeaf<?>>());
+ setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
@@ -326,7 +336,7 @@
* @return the list of leaf-list.
*/
@Override
- public List<YangLeafList<?>> getListOfLeafList() {
+ public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
@@ -335,7 +345,7 @@
*
* @param listOfLeafList the list of leaf-list to set.
*/
- private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
+ private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
@@ -345,9 +355,9 @@
* @param leafList the leaf-list to be added.
*/
@Override
- public void addLeafList(YangLeafList<?> leafList) {
+ public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
- setListOfLeafList(new LinkedList<YangLeafList<?>>());
+ setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
@@ -457,17 +467,16 @@
// TODO auto-generated method stub, to be implemented by parser
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
+ /**
+ * Generates java code for sub-module.
*/
@Override
public void generateJavaCodeEntry() {
// TODO Auto-generated method stub
-
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
+ /**
+ * Free resources used to generate code.
*/
@Override
public void generateJavaCodeExit() {
@@ -475,22 +484,24 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
+ /**
+ * Get the mapped java package.
+ *
+ * @return the java package
*/
@Override
public String getPackage() {
- // TODO Auto-generated method stub
- return null;
+ return pkg;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
+ /**
+ * Set the mapped java package.
+ *
+ * @param pakg the package to set
*/
@Override
- public void setPackage(String pkg) {
- // TODO Auto-generated method stub
-
+ public void setPackage(String pakg) {
+ pkg = pakg;
}
@Override
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangType.java b/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
index d09a1e5..723319d 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
@@ -61,7 +61,12 @@
*/
private YangDataTypes dataType;
- private T dataTypeInfo;
+ /**
+ * Additional information about data type, example restriction info, named
+ * values, etc. The extra information is based on the data type. Based on
+ * the data type, the extended info can vary.
+ */
+ private T dataTypeExtendedInfo;
/**
* Default constructor.
@@ -110,8 +115,8 @@
*
* @return the data type meta data.
*/
- public T getDataTypeInfo() {
- return dataTypeInfo;
+ public T getDataTypeExtendedInfo() {
+ return dataTypeExtendedInfo;
}
/**
@@ -119,8 +124,8 @@
*
* @param dataTypeInfo the meta data to set
*/
- public void setDataTypeInfo(T dataTypeInfo) {
- this.dataTypeInfo = dataTypeInfo;
+ public void setDataTypeExtendedInfo(T dataTypeInfo) {
+ this.dataTypeExtendedInfo = dataTypeInfo;
}
/**
@@ -128,6 +133,7 @@
*
* @return returns TYPE_DATA.
*/
+ @Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.TYPE_DATA;
}
@@ -137,6 +143,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
@@ -147,6 +154,7 @@
*
* @throws DataModelException a violation of data model rules.
*/
+ @Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java b/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
index a1abb0d..0ce074e 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
@@ -81,10 +81,14 @@
private YangStatusType status;
/**
- * Derived data type.
+ * Derived data type. The type will be set when the parser detects the type
+ * parsing. Hence it is of raw type and it not know at the time of creation
+ * of the object. i.e. in entry parse, it will not be know, in the exit
+ * parse we may know the type implicitly based on the restriction. We must
+ * know and validate the base built in type, by the linking phase. It is a
+ * RAW type and it usage needs to be validate in linking phase.
*/
- @SuppressWarnings("rawtypes")
- private YangType derivedType;
+ private YangType<?> derivedType;
/**
* Units of the data type.
@@ -92,6 +96,16 @@
private String units;
/**
+ * YANG base built in data type.
+ */
+ private YangDataTypes baseBuiltInType;
+
+ /**
+ * package of the generated java code.
+ */
+ private String pkg;
+
+ /**
* Create a typedef node.
*/
public YangTypeDef() {
@@ -199,8 +213,7 @@
*
* @return the referenced type.
*/
- @SuppressWarnings("rawtypes")
- public YangType getDerivedType() {
+ public YangType<?> getDerivedType() {
return derivedType;
}
@@ -209,8 +222,7 @@
*
* @param derivedType the referenced type.
*/
- @SuppressWarnings("rawtypes")
- public void setDerivedType(YangType derivedType) {
+ public void setDerivedType(YangType<?> derivedType) {
this.derivedType = derivedType;
}
@@ -233,6 +245,24 @@
}
/**
+ * Get the base built in YANG data type.
+ *
+ * @return base built in YANG data type.
+ */
+ public YangDataTypes getBaseBuiltInType() {
+ return baseBuiltInType;
+ }
+
+ /**
+ * Set the base built in YANG data type.
+ *
+ * @param baseBuiltInType base built in YANG data type.
+ */
+ public void setBaseBuiltInType(YangDataTypes baseBuiltInType) {
+ this.baseBuiltInType = baseBuiltInType;
+ }
+
+ /**
* Returns the type of the data.
*
* @return returns TYPEDEF_DATA
@@ -262,17 +292,20 @@
// TODO auto-generated method stub, to be implemented by parser
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getName()
+ /**
+ * Get the YANG name of the typedef.
+ *
+ * @return YANG name of the typedef.
*/
@Override
public String getName() {
- // TODO Auto-generated method stub
- return null;
+ return derivedName;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
+ /**
+ * Set YANG name of the typedef.
+ *
+ * @param name YANG name of the typedef.
*/
@Override
public void setName(String name) {
@@ -280,8 +313,8 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
+ /**
+ * Generate java code snippet corresponding to YANG typedef.
*/
@Override
public void generateJavaCodeEntry() {
@@ -289,8 +322,8 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
+ /**
+ * Free resource used for code generation of YANG typedef.
*/
@Override
public void generateJavaCodeExit() {
@@ -298,30 +331,43 @@
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
+ /**
+ * Get the mapped java package.
+ *
+ * @return the java package
*/
@Override
public String getPackage() {
- // TODO Auto-generated method stub
- return null;
+ return pkg;
}
- /* (non-Javadoc)
- * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
+ /**
+ * Set the mapped java package.
+ *
+ * @param pakg mapped java package.
*/
@Override
- public void setPackage(String pkg) {
- // TODO Auto-generated method stub
+ public void setPackage(String pakg) {
+ pkg = pakg;
}
+ /**
+ * Get the file handle of the cached file used during code generation.
+ *
+ * @return cached file handle.
+ */
@Override
public CachedFileHandle getFileHandle() {
// TODO Auto-generated method stub
return null;
}
+ /**
+ * Set the file handle to be used used for code generation.
+ *
+ * @param fileHandle cached file handle.
+ */
@Override
public void setFileHandle(CachedFileHandle fileHandle) {
// TODO Auto-generated method stub