[ONOS-4670] Removal of Data Model dependencies on Linker
Change-Id: I3f9c5af30198ea31d743e06cea1764dcb306ec32
diff --git a/src/main/java/org/onosproject/yangutils/linker/ResolvableType.java b/src/main/java/org/onosproject/yangutils/datamodel/ResolvableType.java
similarity index 94%
rename from src/main/java/org/onosproject/yangutils/linker/ResolvableType.java
rename to src/main/java/org/onosproject/yangutils/datamodel/ResolvableType.java
index ff0778f..9521f41 100644
--- a/src/main/java/org/onosproject/yangutils/linker/ResolvableType.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/ResolvableType.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.linker;
+package org.onosproject.yangutils.datamodel;
/**
* Type of the resolvable info.
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java b/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java
index 694df32..adf23ba 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangBelongsTo.java
@@ -18,7 +18,6 @@
import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode;
@@ -194,13 +193,13 @@
/**
* Links the belongs to with a module.
*
- * @param yangFileInfoSet YANG file information set
+ * @param yangNodeSet YANG file information set
* @throws DataModelException a violation in data model rule
*/
- public void linkWithModule(Set<YangFileInfo> yangFileInfoSet)
+ public void linkWithModule(Set<YangNode> yangNodeSet)
throws DataModelException {
String belongsToModuleName = getBelongsToModuleName();
- YangNode moduleNode = findReferredNode(yangFileInfoSet, belongsToModuleName);
+ YangNode moduleNode = findReferredNode(yangNodeSet, belongsToModuleName);
if (moduleNode != null) {
if (moduleNode instanceof YangModule) {
setModuleNode(moduleNode);
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java b/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java
index 3cfdc38..0cfff23 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java
@@ -33,9 +33,9 @@
import static org.onosproject.yangutils.datamodel.YangDataTypes.UNION;
import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
-import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType;
-import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction;
-import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRestriction;
+import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.isOfRangeRestrictedType;
+import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.processLengthRestriction;
+import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.processRangeRestriction;
/**
* Represents the derived information.
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangEntityToResolveInfo.java b/src/main/java/org/onosproject/yangutils/datamodel/YangEntityToResolveInfo.java
new file mode 100644
index 0000000..77323f1
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangEntityToResolveInfo.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present 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 information about entity being resolved.
+ *
+ * @param <T> type of entity being resolved, uses / grouping
+ */
+public interface YangEntityToResolveInfo<T> {
+
+ /**
+ * Retrieves the entity to be resolved.
+ *
+ * @return entity to be resolved
+ */
+ T getEntityToResolve();
+
+ /**
+ * Sets entity to be resolved.
+ *
+ * @param entityToResolve entity to be resolved
+ */
+ void setEntityToResolve(T entityToResolve);
+
+ /**
+ * Retrieves the parent node which contains the entity to be resolved.
+ *
+ * @return parent node which contains the entity to be resolved
+ */
+ YangNode getHolderOfEntityToResolve();
+
+ /**
+ * Sets parent node which contains the entity to be resolved.
+ *
+ * @param holderOfEntityToResolve parent node which contains the entity to
+ * be resolved
+ */
+ void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve);
+}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java b/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
index ef5d25a..73c5670 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
@@ -18,7 +18,6 @@
import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode;
@@ -237,10 +236,10 @@
/**
* Adds reference to an import.
*
- * @param yangFileInfoSet YANG file info set
+ * @param yangNodeSet YANG file info set
* @throws DataModelException a violation of data model rules
*/
- public void addReferenceToImport(Set<YangFileInfo> yangFileInfoSet) throws DataModelException {
+ public void addReferenceToImport(Set<YangNode> yangNodeSet) throws DataModelException {
String importedModuleName = getModuleName();
String importedModuleRevision = getRevision();
YangNode moduleNode = null;
@@ -250,7 +249,7 @@
*/
if (importedModuleRevision != null) {
String importedModuleNameWithRevision = importedModuleName + "@" + importedModuleRevision;
- moduleNode = findReferredNode(yangFileInfoSet, importedModuleNameWithRevision);
+ moduleNode = findReferredNode(yangNodeSet, importedModuleNameWithRevision);
}
/*
@@ -258,7 +257,7 @@
* without revision if can't find with revision.
*/
if (moduleNode == null) {
- moduleNode = findReferredNode(yangFileInfoSet, importedModuleName);
+ moduleNode = findReferredNode(yangNodeSet, importedModuleName);
}
if (moduleNode != null) {
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java b/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
index d331a72..c979469 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
@@ -18,7 +18,6 @@
import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode;
@@ -173,11 +172,11 @@
/**
* Adds reference to an include.
*
- * @param yangFileInfoSet YANG file info set
+ * @param yangNodeSet YANG node set
* @return YANG sub module node
* @throws DataModelException a violation of data model rules
*/
- public YangSubModule addReferenceToInclude(Set<YangFileInfo> yangFileInfoSet) throws DataModelException {
+ public YangSubModule addReferenceToInclude(Set<YangNode> yangNodeSet) throws DataModelException {
String includedSubModuleName = getSubModuleName();
String includedSubModuleRevision = getRevision();
YangNode subModuleNode = null;
@@ -188,7 +187,7 @@
*/
if (includedSubModuleRevision != null) {
String includedSubModuleNameWithRevision = includedSubModuleName + "@" + includedSubModuleRevision;
- subModuleNode = findReferredNode(yangFileInfoSet, includedSubModuleNameWithRevision);
+ subModuleNode = findReferredNode(yangNodeSet, includedSubModuleNameWithRevision);
}
/*
@@ -196,7 +195,7 @@
* without revision if can't find with revision.
*/
if (subModuleNode == null) {
- subModuleNode = findReferredNode(yangFileInfoSet, includedSubModuleName);
+ subModuleNode = findReferredNode(yangNodeSet, includedSubModuleName);
}
if (subModuleNode != null) {
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangLengthRestriction.java b/src/main/java/org/onosproject/yangutils/datamodel/YangLengthRestriction.java
index 8556445..fa50bf7 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangLengthRestriction.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangLengthRestriction.java
@@ -26,7 +26,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.utils.YangConstructType;
-import org.onosproject.yangutils.utils.builtindatatype.YangUint64;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
/**
* Represents the restriction for length data type.
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java b/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
index 11b089d..4eab4c3 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
@@ -19,14 +19,8 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.exceptions.LinkerException;
-import org.onosproject.yangutils.linker.ResolvableType;
-import org.onosproject.yangutils.linker.YangReferenceResolver;
-import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
@@ -88,7 +82,7 @@
/**
* 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
@@ -99,7 +93,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
@@ -134,7 +128,7 @@
/**
* 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
@@ -209,8 +203,8 @@
public YangModule() {
super(YangNodeType.MODULE_NODE);
- derivedTypeResolutionList = new LinkedList<YangResolutionInfo>();
- usesResolutionList = new LinkedList<YangResolutionInfo>();
+ derivedTypeResolutionList = new LinkedList<>();
+ usesResolutionList = new LinkedList<>();
importList = new LinkedList<YangImport>();
includeList = new LinkedList<YangInclude>();
listOfLeaf = new LinkedList<YangLeaf>();
@@ -569,7 +563,7 @@
@Override
public void addToResolutionList(YangResolutionInfo resolutionInfo,
- ResolvableType type) {
+ ResolvableType type) {
if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
derivedTypeResolutionList.add(resolutionInfo);
} else if (type == ResolvableType.YANG_USES) {
@@ -579,7 +573,7 @@
@Override
public void setResolutionList(List<YangResolutionInfo> resolutionList,
- ResolvableType type) {
+ ResolvableType type) {
if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
derivedTypeResolutionList = resolutionList;
} else if (type == ResolvableType.YANG_USES) {
@@ -589,40 +583,32 @@
}
@Override
- public void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet)
- throws LinkerException {
+ public void addReferencesToImportList(Set<YangNode> yangNodeSet)
+ throws DataModelException {
Iterator<YangImport> importInfoIterator = getImportList().iterator();
// Run through the imported list to add references.
while (importInfoIterator.hasNext()) {
YangImport yangImport = importInfoIterator.next();
- try {
- yangImport.addReferenceToImport(yangFileInfoSet);
- } catch (DataModelException e) {
- throw new LinkerException(e.getMessage());
- }
+ yangImport.addReferenceToImport(yangNodeSet);
}
}
@Override
- public void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet)
- throws LinkerException {
+ public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
+ throws DataModelException {
Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
// Run through the included list to add references.
while (includeInfoIterator.hasNext()) {
YangInclude yangInclude = includeInfoIterator.next();
YangSubModule subModule = null;
try {
- subModule = yangInclude.addReferenceToInclude(yangFileInfoSet);
+ subModule = yangInclude.addReferenceToInclude(yangNodeSet);
} catch (DataModelException e) {
- throw new LinkerException(e.getMessage());
+ throw e;
}
// Check if the referred sub-modules parent is self
if (!(subModule.getBelongsTo().getModuleNode() == this)) {
- try {
- yangInclude.reportIncludeError();
- } catch (DataModelException e) {
- throw new LinkerException(e.getMessage());
- }
+ yangInclude.reportIncludeError();
}
}
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangRangeInterval.java b/src/main/java/org/onosproject/yangutils/datamodel/YangRangeInterval.java
index 9ccd5ff..9914a51 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangRangeInterval.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangRangeInterval.java
@@ -13,7 +13,7 @@
limitations under the License.*/
package org.onosproject.yangutils.datamodel;
-import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangBuiltInDataTypeInfo;
/**
* Represents single interval information of a range.
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java b/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java
index d645010..c624623 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java
@@ -21,9 +21,9 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.utils.YangConstructType;
-import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangBuiltInDataTypeInfo;
-import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString;
+import static org.onosproject.yangutils.datamodel.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString;
import static com.google.common.base.Preconditions.checkNotNull;
/*-
diff --git a/src/main/java/org/onosproject/yangutils/linker/YangReferenceResolver.java b/src/main/java/org/onosproject/yangutils/datamodel/YangReferenceResolver.java
similarity index 81%
rename from src/main/java/org/onosproject/yangutils/linker/YangReferenceResolver.java
rename to src/main/java/org/onosproject/yangutils/datamodel/YangReferenceResolver.java
index 307675d..8be3242 100644
--- a/src/main/java/org/onosproject/yangutils/linker/YangReferenceResolver.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangReferenceResolver.java
@@ -14,17 +14,11 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.linker;
+package org.onosproject.yangutils.datamodel;
import java.util.List;
import java.util.Set;
-
-import org.onosproject.yangutils.datamodel.YangImport;
-import org.onosproject.yangutils.datamodel.YangInclude;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.exceptions.LinkerException;
-import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
/**
* Abstraction of YANG dependency resolution information. Abstracted to obtain the
@@ -133,18 +127,18 @@
/**
* Adds references to include.
*
- * @param yangFileInfoSet YANG file info set
- * @throws LinkerException a violation of linker rules
+ * @param yangNodeSet YANG node info set
+ * @throws DataModelException a violation of data model rules
*/
- void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet)
- throws LinkerException;
+ void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
+ throws DataModelException;
/**
* Adds references to import.
*
- * @param yangFileInfoSet YANG file info set
- * @throws LinkerException a violation of linker rules
+ * @param yangNodeSet YANG node info set
+ * @throws DataModelException a violation of data model rules
*/
- void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet)
- throws LinkerException;
+ void addReferencesToImportList(Set<YangNode> yangNodeSet)
+ throws DataModelException;
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangResolutionInfo.java b/src/main/java/org/onosproject/yangutils/datamodel/YangResolutionInfo.java
new file mode 100644
index 0000000..c63e832
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangResolutionInfo.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.datamodel;
+
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+
+/**
+ * Abstraction of resolution object which will be resolved by linker.
+ *
+ * @param <T> type of resolution entity uses / type
+ */
+public interface YangResolutionInfo<T> extends LocationInfo {
+
+ /**
+ * Resolves linking with all the ancestors node for a resolution info.
+ *
+ * @param dataModelRootNode module/sub-module node
+ * @throws DataModelException DataModelException a violation of data model
+ * rules
+ */
+ void resolveLinkingForResolutionInfo(YangReferenceResolver dataModelRootNode)
+ throws DataModelException;
+
+ /**
+ * Retrieves information about the entity that needs to be resolved.
+ *
+ * @return information about the entity that needs to be resolved
+ */
+ YangEntityToResolveInfo<T> getEntityToResolveInfo();
+
+ /**
+ * Performs inter file linking of uses/type referring to typedef/grouping
+ * of other YANG file.
+ *
+ * @param dataModelRootNode module/sub-module node
+ * @throws DataModelException a violation in data model rule
+ */
+ void linkInterFile(YangReferenceResolver dataModelRootNode)
+ throws DataModelException;
+}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java b/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java
index 2a2ebf4..a701b64 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java
@@ -19,7 +19,7 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.utils.YangConstructType;
-import org.onosproject.yangutils.utils.builtindatatype.YangUint64;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
/*-
* Reference RFC 6020.
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java b/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
index 89c49dd..b7f9223 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
@@ -19,14 +19,8 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.exceptions.LinkerException;
-import org.onosproject.yangutils.linker.ResolvableType;
-import org.onosproject.yangutils.linker.YangReferenceResolver;
-import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
@@ -206,8 +200,8 @@
*/
public YangSubModule() {
super(YangNodeType.SUB_MODULE_NODE);
- derivedTypeResolutionList = new LinkedList<YangResolutionInfo>();
- usesResolutionList = new LinkedList<YangResolutionInfo>();
+ derivedTypeResolutionList = new LinkedList<>();
+ usesResolutionList = new LinkedList<>();
importList = new LinkedList<YangImport>();
includeList = new LinkedList<YangInclude>();
listOfLeaf = new LinkedList<YangLeaf>();
@@ -548,7 +542,7 @@
@Override
public void addToResolutionList(YangResolutionInfo resolutionInfo,
- ResolvableType type) {
+ ResolvableType type) {
if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
derivedTypeResolutionList.add(resolutionInfo);
} else if (type == ResolvableType.YANG_USES) {
@@ -558,7 +552,7 @@
@Override
public void setResolutionList(List<YangResolutionInfo> resolutionList,
- ResolvableType type) {
+ ResolvableType type) {
if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
derivedTypeResolutionList = resolutionList;
} else if (type == ResolvableType.YANG_USES) {
@@ -570,50 +564,38 @@
/**
* Links the sub-module with module.
*
- * @param yangFileInfoSet YANG file information set
+ * @param yangNodeSet YANG file information set
* @throws DataModelException a violation in data model rule
*/
- public void linkWithModule(Set<YangFileInfo> yangFileInfoSet)
+ public void linkWithModule(Set<YangNode> yangNodeSet)
throws DataModelException {
- getBelongsTo().linkWithModule(yangFileInfoSet);
+ getBelongsTo().linkWithModule(yangNodeSet);
}
@Override
- public void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet)
- throws LinkerException {
+ public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
+ throws DataModelException {
Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
// Run through the included list to add references.
while (includeInfoIterator.hasNext()) {
YangInclude yangInclude = includeInfoIterator.next();
YangSubModule subModule = null;
- try {
- subModule = yangInclude.addReferenceToInclude(yangFileInfoSet);
- } catch (DataModelException e) {
- throw new LinkerException(e.getMessage());
- }
+ subModule = yangInclude.addReferenceToInclude(yangNodeSet);
// Check if the referred sub-modules parent is self
if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) {
- try {
- yangInclude.reportIncludeError();
- } catch (DataModelException e) {
- throw new LinkerException(e.getMessage());
- }
+ yangInclude.reportIncludeError();
}
}
}
@Override
- public void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet)
- throws LinkerException {
+ public void addReferencesToImportList(Set<YangNode> yangNodeSet)
+ throws DataModelException {
Iterator<YangImport> importInfoIterator = getImportList().iterator();
// Run through the imported list to add references.
while (importInfoIterator.hasNext()) {
YangImport yangImport = importInfoIterator.next();
- try {
- yangImport.addReferenceToImport(yangFileInfoSet);
- } catch (DataModelException e) {
- throw new LinkerException(e.getMessage());
- }
+ yangImport.addReferenceToImport(yangNodeSet);
}
}
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangType.java b/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
index 41e07e4..d5cc8ff 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
@@ -19,7 +19,6 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.linker.Resolvable;
import org.onosproject.yangutils.linker.ResolvableStatus;
-import org.onosproject.yangutils.linker.exceptions.LinkerException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.utils.YangConstructType;
@@ -248,25 +247,25 @@
@Override
public void resolve()
- throws LinkerException {
+ throws DataModelException {
/*
* Check whether the data type is derived.
*/
if (getDataType() != DERIVED) {
- throw new LinkerException("Linker Error: Resolve should only be called for derived data types.");
+ throw new DataModelException("Linker Error: Resolve should only be called for derived data types.");
}
// Check if the derived info is present.
YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) getDataTypeExtendedInfo();
if (derivedInfo == null) {
- throw new LinkerException("Linker Error: Derived information is missing.");
+ throw new DataModelException("Linker Error: Derived information is missing.");
}
// Initiate the resolution
try {
setResolvableStatus(derivedInfo.resolve());
} catch (DataModelException e) {
- throw new LinkerException(e.getMessage());
+ throw new DataModelException(e.getMessage());
}
}
}
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java b/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
index d2d8bc2..c3bab5f 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
@@ -17,11 +17,9 @@
import java.util.LinkedList;
import java.util.List;
-
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.linker.Resolvable;
import org.onosproject.yangutils.linker.ResolvableStatus;
-import org.onosproject.yangutils.linker.exceptions.LinkerException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.utils.YangConstructType;
@@ -283,18 +281,18 @@
@Override
public void resolve()
- throws LinkerException {
+ throws DataModelException {
YangGrouping referredGrouping = getRefGroup();
if (referredGrouping == null) {
- throw new LinkerException("Linker Exception: YANG uses linker error, cannot resolve uses");
+ throw new DataModelException("YANG uses linker error, cannot resolve uses");
}
YangNode usesParentNode = getParentNodeInGenCode(this);
if (!(usesParentNode instanceof YangLeavesHolder)
|| !(usesParentNode instanceof CollisionDetector)) {
- throw new LinkerException("Linker Exception: YANG uses holder construct is wrong");
+ throw new DataModelException("YANG uses holder construct is wrong");
}
YangLeavesHolder usesParentLeavesHolder = (YangLeavesHolder) usesParentNode;
@@ -343,7 +341,7 @@
* @param usesHolder holder of uses
*/
private void addResolvedUsesInfoOfGrouping(YangUses usesInGrouping,
- YangLeavesHolder usesHolder) {
+ YangLeavesHolder usesHolder) throws DataModelException {
for (YangNode usesResolvedNode :
usesInGrouping.getUsesResolvedNodeList()) {
addNodeOfGrouping(usesResolvedNode);
@@ -367,11 +365,12 @@
* @param listOfLeaves list of leaves to be cloned
* @param usesParentNode parent of the cloned location
* @return cloned list of leaves
+ * @throws DataModelException a violation in data model rule
*/
private List<YangLeaf> cloneLeavesList(List<YangLeaf> listOfLeaves,
- YangLeavesHolder usesParentNode) {
+ YangLeavesHolder usesParentNode) throws DataModelException {
if ((listOfLeaves == null) || listOfLeaves.size() == 0) {
- throw new LinkerException("No leaves to clone");
+ throw new DataModelException("No leaves to clone");
}
List<YangLeaf> newLeavesList = new LinkedList<YangLeaf>();
@@ -382,7 +381,7 @@
YangConstructType.LEAF_DATA);
clonedLeaf = leaf.clone();
} catch (CloneNotSupportedException | DataModelException e) {
- throw new LinkerException(e.getMessage());
+ throw new DataModelException(e.getMessage());
}
clonedLeaf.setContainedIn(usesParentNode);
@@ -400,9 +399,9 @@
* @return cloned list of leaf list
*/
private List<YangLeafList> cloneListOfLeafList(List<YangLeafList> listOfLeafList,
- YangLeavesHolder usesParentNode) {
+ YangLeavesHolder usesParentNode) throws DataModelException {
if ((listOfLeafList == null) || listOfLeafList.size() == 0) {
- throw new LinkerException("No leaf lists to clone");
+ throw new DataModelException("No leaf lists to clone");
}
List<YangLeafList> newListOfLeafList = new LinkedList<YangLeafList>();
@@ -413,7 +412,7 @@
YangConstructType.LEAF_LIST_DATA);
clonedLeafList = leafList.clone();
} catch (CloneNotSupportedException | DataModelException e) {
- throw new LinkerException(e.getMessage());
+ throw new DataModelException(e.getMessage());
}
clonedLeafList.setContainedIn(usesParentNode);
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
index 29d384b..97c7327 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
@@ -18,20 +18,18 @@
import java.util.List;
import java.util.Set;
-
import org.onosproject.yangutils.datamodel.CollisionDetector;
+import org.onosproject.yangutils.datamodel.ResolvableType;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangLeavesHolder;
import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangReferenceResolver;
+import org.onosproject.yangutils.datamodel.YangResolutionInfo;
import org.onosproject.yangutils.datamodel.YangRpc;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.ResolvableType;
-import org.onosproject.yangutils.linker.YangReferenceResolver;
-import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
import org.onosproject.yangutils.utils.YangConstructType;
/**
@@ -179,7 +177,7 @@
* @throws DataModelException a violation of data model rules
*/
public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList,
- YangReferenceResolver dataModelRootNode)
+ YangReferenceResolver dataModelRootNode)
throws DataModelException {
for (YangResolutionInfo resolutionInfo : resolutionList) {
@@ -195,7 +193,7 @@
* @throws DataModelException a violation of data model rules
*/
public static void linkInterFileReferences(List<YangResolutionInfo> resolutionList,
- YangReferenceResolver dataModelRootNode)
+ YangReferenceResolver dataModelRootNode)
throws DataModelException {
/*
* Run through the resolution list, find type/uses referring to
@@ -226,19 +224,18 @@
/**
* Returns referred node in a given set.
*
- * @param yangFileInfoSet YANG file info set
- * @param refNodeName name of the node which is referred
+ * @param yangNodeSet YANG node set
+ * @param refNodeName name of the node which is referred
* @return referred node's reference
*/
- public static YangNode findReferredNode(Set<YangFileInfo> yangFileInfoSet, String refNodeName) {
+ public static YangNode findReferredNode(Set<YangNode> yangNodeSet, String refNodeName) {
/*
* Run through the YANG files to see which YANG file matches the
* referred node name.
*/
- for (YangFileInfo yangFileInfo : yangFileInfoSet) {
- YangNode yangNode = yangFileInfo.getRootNode();
+ for (YangNode yangNode : yangNodeSet) {
if (yangNode.getName().equals(refNodeName)) {
- return yangFileInfo.getRootNode();
+ return yangNode;
}
}
return null;
diff --git a/src/main/java/org/onosproject/yangutils/utils/RestrictionResolver.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/RestrictionResolver.java
similarity index 77%
rename from src/main/java/org/onosproject/yangutils/utils/RestrictionResolver.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/RestrictionResolver.java
index 41a8fef..4148278 100644
--- a/src/main/java/org/onosproject/yangutils/utils/RestrictionResolver.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/RestrictionResolver.java
@@ -14,16 +14,15 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils;
+package org.onosproject.yangutils.datamodel.utils;
import java.util.regex.Pattern;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangRangeInterval;
import org.onosproject.yangutils.datamodel.YangRangeRestriction;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.parser.exceptions.ParserException;
-import org.onosproject.yangutils.utils.builtindatatype.DataTypeException;
-import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo;
+import org.onosproject.yangutils.utils.YangConstructType;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangBuiltInDataTypeInfo;
import static org.onosproject.yangutils.datamodel.YangDataTypes.DECIMAL64;
import static org.onosproject.yangutils.datamodel.YangDataTypes.INT16;
@@ -34,13 +33,11 @@
import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT32;
import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT64;
import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT8;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
+import static org.onosproject.yangutils.utils.UtilConstants.ADD;
+import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.YangConstructType.LENGTH_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.RANGE_DATA;
-import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString;
+import static org.onosproject.yangutils.datamodel.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString;
/**
* Represents restriction resolver which provide common utility used by parser
@@ -71,11 +68,13 @@
* @param curRangeString caller type's range string
* @param effectiveType effective type, when called from linker
* @return YANG range restriction
+ * @throws DataModelException a violation in data model rule
*/
public static YangRangeRestriction processRangeRestriction(YangRangeRestriction refRangeRestriction,
int lineNumber, int charPositionInLine,
boolean hasReferredRestriction,
- String curRangeString, YangDataTypes effectiveType) {
+ String curRangeString, YangDataTypes effectiveType)
+ throws DataModelException {
YangBuiltInDataTypeInfo<?> startValue;
YangBuiltInDataTypeInfo<?> endValue;
YangRangeRestriction rangeRestriction = new YangRangeRestriction();
@@ -90,12 +89,12 @@
String[] rangeBoundary = rangePart.trim().split(Pattern.quote(INTERVAL));
if (rangeBoundary.length > MAX_RANGE_BOUNDARY) {
- ParserException parserException = new ParserException("YANG file error : " +
+ DataModelException dataModelException = new DataModelException("YANG file error : " +
YangConstructType.getYangConstructType(RANGE_DATA) + " " + rangeArgument +
" is not valid.");
- parserException.setLine(lineNumber);
- parserException.setCharPosition(charPositionInLine);
- throw parserException;
+ dataModelException.setLine(lineNumber);
+ dataModelException.setCharPosition(charPositionInLine);
+ throw dataModelException;
}
if (rangeBoundary.length == MIN_RANGE_BOUNDARY) {
@@ -125,11 +124,11 @@
} else {
endValue = getDataObjectFromString(endInterval, effectiveType);
}
- } catch (DataTypeException | DataModelException e) {
- ParserException parserException = new ParserException(e.getMessage());
- parserException.setLine(lineNumber);
- parserException.setCharPosition(charPositionInLine);
- throw parserException;
+ } catch (Exception e) {
+ DataModelException dataModelException = new DataModelException(e.getMessage());
+ dataModelException.setLine(lineNumber);
+ dataModelException.setCharPosition(charPositionInLine);
+ throw dataModelException;
}
rangeInterval.setStartValue(startValue);
@@ -137,12 +136,10 @@
try {
rangeRestriction.addRangeRestrictionInterval(rangeInterval);
- } catch (DataModelException e) {
- ParserException parserException = new ParserException(constructExtendedListenerErrorMessage(
- UNHANDLED_PARSED_DATA, RANGE_DATA, rangeArgument, ENTRY, e.getMessage()));
- parserException.setLine(lineNumber);
- parserException.setCharPosition(charPositionInLine);
- throw parserException;
+ } catch (DataModelException dataModelException) {
+ dataModelException.setLine(lineNumber);
+ dataModelException.setCharPosition(charPositionInLine);
+ throw dataModelException;
}
}
return rangeRestriction;
@@ -157,11 +154,12 @@
* @param hasReferredRestriction whether has referred restriction
* @param curLengthString caller type's length string
* @return YANG range restriction
+ * @throws DataModelException a violation in data model rule
*/
public static YangRangeRestriction processLengthRestriction(YangRangeRestriction refLengthRestriction,
int lineNumber, int charPositionInLine,
boolean hasReferredRestriction,
- String curLengthString) {
+ String curLengthString) throws DataModelException {
YangBuiltInDataTypeInfo<?> startValue;
YangBuiltInDataTypeInfo<?> endValue;
@@ -177,12 +175,12 @@
String[] rangeBoundary = rangePart.trim().split(Pattern.quote(INTERVAL));
if (rangeBoundary.length > MAX_RANGE_BOUNDARY) {
- ParserException parserException = new ParserException("YANG file error : " +
+ DataModelException dataModelException = new DataModelException("YANG file error : " +
YangConstructType.getYangConstructType(LENGTH_DATA) + " " + rangeArgument +
" is not valid.");
- parserException.setLine(lineNumber);
- parserException.setCharPosition(charPositionInLine);
- throw parserException;
+ dataModelException.setLine(lineNumber);
+ dataModelException.setCharPosition(charPositionInLine);
+ throw dataModelException;
}
if (rangeBoundary.length == MIN_RANGE_BOUNDARY) {
@@ -212,11 +210,11 @@
} else {
endValue = getDataObjectFromString(endInterval, YangDataTypes.UINT64);
}
- } catch (DataTypeException | DataModelException e) {
- ParserException parserException = new ParserException(e.getMessage());
- parserException.setLine(lineNumber);
- parserException.setCharPosition(charPositionInLine);
- throw parserException;
+ } catch (Exception e) {
+ DataModelException dataModelException = new DataModelException(e.getMessage());
+ dataModelException.setLine(lineNumber);
+ dataModelException.setCharPosition(charPositionInLine);
+ throw dataModelException;
}
rangeInterval.setStartValue(startValue);
@@ -224,12 +222,10 @@
try {
lengthRestriction.addRangeRestrictionInterval(rangeInterval);
- } catch (DataModelException e) {
- ParserException parserException = new ParserException(constructExtendedListenerErrorMessage(
- UNHANDLED_PARSED_DATA, LENGTH_DATA, rangeArgument, ENTRY, e.getMessage()));
- parserException.setLine(lineNumber);
- parserException.setCharPosition(charPositionInLine);
- throw parserException;
+ } catch (DataModelException dataModelException) {
+ dataModelException.setLine(lineNumber);
+ dataModelException.setCharPosition(charPositionInLine);
+ throw dataModelException;
}
}
return lengthRestriction;
@@ -252,4 +248,21 @@
|| dataType == UINT64
|| dataType == DECIMAL64);
}
+
+ /**
+ * Removes doubles quotes and concatenates if string has plus symbol.
+ *
+ * @param yangStringData string from yang file
+ * @return concatenated string after removing double quotes
+ */
+ private static String removeQuotesAndHandleConcat(String yangStringData) {
+
+ yangStringData = yangStringData.replace("\"", EMPTY_STRING);
+ String[] tmpData = yangStringData.split(Pattern.quote(ADD));
+ StringBuilder builder = new StringBuilder();
+ for (String yangString : tmpData) {
+ builder.append(yangString);
+ }
+ return builder.toString();
+ }
}
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/BuiltInTypeObjectFactory.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/BuiltInTypeObjectFactory.java
similarity index 88%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/BuiltInTypeObjectFactory.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/BuiltInTypeObjectFactory.java
index 7002129..4c2d79b 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/BuiltInTypeObjectFactory.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/BuiltInTypeObjectFactory.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import org.onosproject.yangutils.datamodel.YangDataTypes;
@@ -32,13 +32,13 @@
* Given the value represented in string return the corresponding types
* object with the value initialized.
*
- * @param valueInStr value represented in string
+ * @param valueInStr value represented in string
* @param builtInType built in data type
+ * @param <T> the data type of the target object
* @return the target data type object with the value initialized
- * @param <T> the data type of the target object
*/
public static <T extends YangBuiltInDataTypeInfo<?>> T getDataObjectFromString(String valueInStr,
- YangDataTypes builtInType) {
+ YangDataTypes builtInType) {
switch (builtInType) {
case INT8: {
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/DataTypeException.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/DataTypeException.java
similarity index 92%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/DataTypeException.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/DataTypeException.java
index 4cad2cd..8c24d6c 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/DataTypeException.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/DataTypeException.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
/**
* Base class for exceptions in data type.
@@ -43,7 +43,7 @@
* Creates a new data type exception from given message and cause.
*
* @param message the detail of exception in string
- * @param cause underlying cause of the error
+ * @param cause underlying cause of the error
*/
public DataTypeException(final String message, final Throwable cause) {
super(message, cause);
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBinary.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangBinary.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBinary.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangBinary.java
index 51747f3..a93379b 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBinary.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangBinary.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import java.util.Objects;
-
import com.google.common.base.MoreObjects;
/**
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBits.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangBits.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBits.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangBits.java
index 60b0c32..f2c05f7 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBits.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangBits.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import java.util.Objects;
-
import com.google.common.base.MoreObjects;
/**
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBuiltInDataTypeInfo.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangBuiltInDataTypeInfo.java
similarity index 93%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBuiltInDataTypeInfo.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangBuiltInDataTypeInfo.java
index 437fe0f..b082c16 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBuiltInDataTypeInfo.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangBuiltInDataTypeInfo.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import org.onosproject.yangutils.datamodel.YangDataTypes;
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangDecimal64.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangDecimal64.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangDecimal64.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangDecimal64.java
index 8b3a0eb..ca45073 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangDecimal64.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangDecimal64.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import java.util.Objects;
-
import com.google.common.base.MoreObjects;
/**
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt16.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt16.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt16.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt16.java
index f9055e8..2a660c1 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt16.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt16.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import org.onosproject.yangutils.datamodel.YangDataTypes;
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt32.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt32.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt32.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt32.java
index 2f48f33..6774b37 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt32.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt32.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import org.onosproject.yangutils.datamodel.YangDataTypes;
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt64.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt64.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt64.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt64.java
index 6b0b685..6a426d1 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt64.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt64.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import org.onosproject.yangutils.datamodel.YangDataTypes;
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt8.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt8.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt8.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt8.java
index b2823e5..df3221d 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangInt8.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangInt8.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import org.onosproject.yangutils.datamodel.YangDataTypes;
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint16.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint16.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint16.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint16.java
index 53c3a50..8a4fa93 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint16.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint16.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import org.onosproject.yangutils.datamodel.YangDataTypes;
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint32.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint32.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint32.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint32.java
index 79d1c6d..f3dc7ec 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint32.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint32.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import org.onosproject.yangutils.datamodel.YangDataTypes;
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint64.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint64.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint64.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint64.java
index cc16a7a..bc66d59 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint64.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint64.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import java.math.BigInteger;
import java.util.regex.Pattern;
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint8.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint8.java
similarity index 97%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint8.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint8.java
index b9abf4c..dd4901f 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangUint8.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/YangUint8.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
import org.onosproject.yangutils.datamodel.YangDataTypes;
diff --git a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/package-info.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/package-info.java
similarity index 90%
rename from src/main/java/org/onosproject/yangutils/utils/builtindatatype/package-info.java
rename to src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/package-info.java
index 9d3aa33..d1ceae5 100644
--- a/src/main/java/org/onosproject/yangutils/utils/builtindatatype/package-info.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/builtindatatype/package-info.java
@@ -17,4 +17,4 @@
/**
* Utilities for YANG built in data types.
*/
-package org.onosproject.yangutils.utils.builtindatatype;
+package org.onosproject.yangutils.datamodel.utils.builtindatatype;
diff --git a/src/main/java/org/onosproject/yangutils/linker/Resolvable.java b/src/main/java/org/onosproject/yangutils/linker/Resolvable.java
index 975c3f4..8fb10ad 100644
--- a/src/main/java/org/onosproject/yangutils/linker/Resolvable.java
+++ b/src/main/java/org/onosproject/yangutils/linker/Resolvable.java
@@ -16,7 +16,7 @@
package org.onosproject.yangutils.linker;
-import org.onosproject.yangutils.linker.exceptions.LinkerException;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
/**
* Abstraction of YANG resolvable information. Abstracted to obtain the
@@ -47,8 +47,8 @@
/**
* Resolves the linking.
*
- * @throws LinkerException linker error
+ * @throws DataModelException data model exception
*/
void resolve()
- throws LinkerException;
+ throws DataModelException;
}
diff --git a/src/main/java/org/onosproject/yangutils/linker/impl/YangEntityToResolveInfo.java b/src/main/java/org/onosproject/yangutils/linker/impl/YangEntityToResolveInfoImpl.java
similarity index 77%
rename from src/main/java/org/onosproject/yangutils/linker/impl/YangEntityToResolveInfo.java
rename to src/main/java/org/onosproject/yangutils/linker/impl/YangEntityToResolveInfoImpl.java
index f239692..b8f63eb 100644
--- a/src/main/java/org/onosproject/yangutils/linker/impl/YangEntityToResolveInfo.java
+++ b/src/main/java/org/onosproject/yangutils/linker/impl/YangEntityToResolveInfoImpl.java
@@ -15,17 +15,18 @@
*/
package org.onosproject.yangutils.linker.impl;
+import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.YangUses;
import org.onosproject.yangutils.linker.exceptions.LinkerException;
/**
- * Represents information about entity being resolved.
+ * Represents implementation of information about entity being resolved.
*
* @param <T> type of entity being resolved, uses / grouping
*/
-public class YangEntityToResolveInfo<T> {
+public class YangEntityToResolveInfoImpl<T> implements YangEntityToResolveInfo<T> {
// Parsable node for which resolution is to be performed.
private T entityToResolve;
@@ -33,39 +34,22 @@
// Holder of the YANG construct for which resolution has to be carried out.
private YangNode holderOfEntityToResolve;
- /**
- * Retrieves the entity to be resolved.
- *
- * @return entity to be resolved
- */
+ @Override
public T getEntityToResolve() {
return entityToResolve;
}
- /**
- * Sets entity to be resolved.
- *
- * @param entityToResolve entity to be resolved
- */
+ @Override
public void setEntityToResolve(T entityToResolve) {
this.entityToResolve = entityToResolve;
}
- /**
- * Retrieves the parent node which contains the entity to be resolved.
- *
- * @return parent node which contains the entity to be resolved
- */
+ @Override
public YangNode getHolderOfEntityToResolve() {
return holderOfEntityToResolve;
}
- /**
- * Sets parent node which contains the entity to be resolved.
- *
- * @param holderOfEntityToResolve parent node which contains the entity to
- * be resolved
- */
+ @Override
public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) {
this.holderOfEntityToResolve = holderOfEntityToResolve;
}
diff --git a/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java b/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
index deaebb2..4e8a60a 100644
--- a/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
+++ b/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
@@ -16,14 +16,14 @@
package org.onosproject.yangutils.linker.impl;
+import java.util.HashSet;
import java.util.Set;
-
+import org.onosproject.yangutils.datamodel.ResolvableType;
import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangReferenceResolver;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.ResolvableType;
import org.onosproject.yangutils.linker.YangLinker;
-import org.onosproject.yangutils.linker.YangReferenceResolver;
import org.onosproject.yangutils.linker.exceptions.LinkerException;
import org.onosproject.yangutils.plugin.manager.YangFileInfo;
@@ -34,9 +34,39 @@
*/
public class YangLinkerManager
implements YangLinker {
+
+ /*
+ * Set of all the YANG nodes, corresponding to the YANG files parsed by
+ * parser.
+ */
+ Set<YangNode> yangNodeSet = new HashSet<>();
+
+ /**
+ * Returns set of YANG node.
+ *
+ * @return set of YANG node
+ */
+ public Set<YangNode> getYangNodeSet() {
+ return yangNodeSet;
+ }
+
+ /**
+ * Creates YANG nodes set.
+ *
+ * @param yangFileInfoSet YANG file information set
+ */
+ public void createYangNodeSet(Set<YangFileInfo> yangFileInfoSet) {
+ for (YangFileInfo yangFileInfo : yangFileInfoSet) {
+ getYangNodeSet().add(yangFileInfo.getRootNode());
+ }
+ }
+
@Override
public void resolveDependencies(Set<YangFileInfo> yangFileInfoSet) {
+ // Create YANG node set.
+ createYangNodeSet(yangFileInfoSet);
+
// Carry out linking of sub module with module.
linkSubModulesToParentModule(yangFileInfoSet);
@@ -64,7 +94,7 @@
YangNode yangNode = yangFileInfo.getRootNode();
if (yangNode instanceof YangSubModule) {
try {
- ((YangSubModule) yangNode).linkWithModule(yangFileInfoSet);
+ ((YangSubModule) yangNode).linkWithModule(getYangNodeSet());
} catch (DataModelException e) {
String errorInfo = "YANG file error: " + yangFileInfo.getYangFileName() + " at line: "
+ e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE
@@ -85,7 +115,14 @@
for (YangFileInfo yangFileInfo : yangFileInfoSet) {
YangNode yangNode = yangFileInfo.getRootNode();
if (yangNode instanceof YangReferenceResolver) {
- ((YangReferenceResolver) yangNode).addReferencesToImportList(yangFileInfoSet);
+ try {
+ ((YangReferenceResolver) yangNode).addReferencesToImportList(getYangNodeSet());
+ } catch (DataModelException e) {
+ String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: "
+ + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE
+ + e.getMessage();
+ throw new LinkerException(errorInfo);
+ }
}
}
}
@@ -100,7 +137,14 @@
for (YangFileInfo yangFileInfo : yangFileInfoSet) {
YangNode yangNode = yangFileInfo.getRootNode();
if (yangNode instanceof YangReferenceResolver) {
- ((YangReferenceResolver) yangNode).addReferencesToIncludeList(yangFileInfoSet);
+ try {
+ ((YangReferenceResolver) yangNode).addReferencesToIncludeList(getYangNodeSet());
+ } catch (DataModelException e) {
+ String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: "
+ + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE
+ + e.getMessage();
+ throw new LinkerException(errorInfo);
+ }
}
}
}
diff --git a/src/main/java/org/onosproject/yangutils/linker/impl/YangResolutionInfo.java b/src/main/java/org/onosproject/yangutils/linker/impl/YangResolutionInfoImpl.java
similarity index 94%
rename from src/main/java/org/onosproject/yangutils/linker/impl/YangResolutionInfo.java
rename to src/main/java/org/onosproject/yangutils/linker/impl/YangResolutionInfoImpl.java
index 83b11c4..0d43293 100644
--- a/src/main/java/org/onosproject/yangutils/linker/impl/YangResolutionInfo.java
+++ b/src/main/java/org/onosproject/yangutils/linker/impl/YangResolutionInfoImpl.java
@@ -17,14 +17,14 @@
package org.onosproject.yangutils.linker.impl;
import java.util.Stack;
-
-import org.onosproject.yangutils.datamodel.LocationInfo;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangDerivedInfo;
import org.onosproject.yangutils.datamodel.YangGrouping;
import org.onosproject.yangutils.datamodel.YangImport;
import org.onosproject.yangutils.datamodel.YangInclude;
import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangReferenceResolver;
+import org.onosproject.yangutils.datamodel.YangResolutionInfo;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.YangUses;
@@ -32,7 +32,6 @@
import org.onosproject.yangutils.linker.Resolvable;
import org.onosproject.yangutils.linker.ResolvableStatus;
import org.onosproject.yangutils.linker.YangLinkingPhase;
-import org.onosproject.yangutils.linker.YangReferenceResolver;
import static org.onosproject.yangutils.linker.ResolvableStatus.INTER_FILE_LINKED;
import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
@@ -41,21 +40,22 @@
import static org.onosproject.yangutils.linker.ResolvableStatus.UNRESOLVED;
import static org.onosproject.yangutils.linker.YangLinkingPhase.INTER_FILE;
import static org.onosproject.yangutils.linker.YangLinkingPhase.INTRA_FILE;
-import static org.onosproject.yangutils.utils.UtilConstants.TYPEDEF_LINKER_ERROR;
import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERROR;
+import static org.onosproject.yangutils.utils.UtilConstants.TYPEDEF_LINKER_ERROR;
/**
- * Represents resolution object which will be resolved by linker.
+ * Represents implementation of resolution object which will be resolved by
+ * linker.
*
* @param <T> type of resolution entity uses / type
*/
-public class YangResolutionInfo<T>
- implements LocationInfo {
+public class YangResolutionInfoImpl<T>
+ implements YangResolutionInfo<T> {
/**
* Information about the entity that needs to be resolved.
*/
- private YangEntityToResolveInfo<T> entityToResolveInfo;
+ private YangEntityToResolveInfoImpl<T> entityToResolveInfo;
/**
* Error line number.
@@ -77,14 +77,14 @@
* Stack for type/uses is maintained for hierarchical references, this is
* used during resolution.
*/
- private Stack<YangEntityToResolveInfo<T>> partialResolvedStack;
+ private Stack<YangEntityToResolveInfoImpl<T>> partialResolvedStack;
/**
* It is private to ensure the overloaded method be invoked to create an
* object.
*/
@SuppressWarnings("unused")
- private YangResolutionInfo() {
+ private YangResolutionInfoImpl() {
}
@@ -96,8 +96,8 @@
* @param lineNumber error line number
* @param charPositionInLine error character position in line
*/
- public YangResolutionInfo(T dataNode, YangNode holderNode, int lineNumber, int charPositionInLine) {
- setEntityToResolveInfo(new YangEntityToResolveInfo<>());
+ public YangResolutionInfoImpl(T dataNode, YangNode holderNode, int lineNumber, int charPositionInLine) {
+ setEntityToResolveInfo(new YangEntityToResolveInfoImpl<>());
getEntityToResolveInfo().setEntityToResolve(dataNode);
getEntityToResolveInfo().setHolderOfEntityToResolve(holderNode);
this.setLineNumber(lineNumber);
@@ -105,13 +105,7 @@
setPartialResolvedStack(new Stack<>());
}
- /**
- * Resolves linking with all the ancestors node for a resolution info.
- *
- * @param dataModelRootNode module/sub-module node
- * @throws DataModelException DataModelException a violation of data model
- * rules
- */
+ @Override
public void resolveLinkingForResolutionInfo(YangReferenceResolver dataModelRootNode)
throws DataModelException {
@@ -431,11 +425,12 @@
if (((YangTypeDef) referredNode).getTypeDefBaseType().getDataType()
== YangDataTypes.DERIVED) {
- YangEntityToResolveInfo<YangType<?>> unResolvedEntityInfo = new YangEntityToResolveInfo<>();
+ YangEntityToResolveInfoImpl<YangType<?>> unResolvedEntityInfo
+ = new YangEntityToResolveInfoImpl<>();
unResolvedEntityInfo.setEntityToResolve(((YangTypeDef) referredNode)
.getTypeDefBaseType());
unResolvedEntityInfo.setHolderOfEntityToResolve(referredNode);
- addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo);
+ addInPartialResolvedStack((YangEntityToResolveInfoImpl<T>) unResolvedEntityInfo);
}
} else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
@@ -462,10 +457,10 @@
YangNode curNode = node.getChild();
while (curNode != null) {
if (curNode instanceof YangUses) {
- YangEntityToResolveInfo<YangUses> unResolvedEntityInfo = new YangEntityToResolveInfo<>();
+ YangEntityToResolveInfoImpl<YangUses> unResolvedEntityInfo = new YangEntityToResolveInfoImpl<>();
unResolvedEntityInfo.setEntityToResolve((YangUses) curNode);
unResolvedEntityInfo.setHolderOfEntityToResolve(node);
- addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo);
+ addInPartialResolvedStack((YangEntityToResolveInfoImpl<T>) unResolvedEntityInfo);
}
curNode = curNode.getNextSibling();
@@ -478,7 +473,7 @@
*
* @return partial resolved YANG construct stack
*/
- private Stack<YangEntityToResolveInfo<T>> getPartialResolvedStack() {
+ private Stack<YangEntityToResolveInfoImpl<T>> getPartialResolvedStack() {
return partialResolvedStack;
}
@@ -487,7 +482,7 @@
*
* @param partialResolvedStack partial resolved YANG construct stack
*/
- private void setPartialResolvedStack(Stack<YangEntityToResolveInfo<T>> partialResolvedStack) {
+ private void setPartialResolvedStack(Stack<YangEntityToResolveInfoImpl<T>> partialResolvedStack) {
this.partialResolvedStack = partialResolvedStack;
}
@@ -496,7 +491,7 @@
*
* @param partialResolvedInfo partial resolved YANG construct stack
*/
- private void addInPartialResolvedStack(YangEntityToResolveInfo<T> partialResolvedInfo) {
+ private void addInPartialResolvedStack(YangEntityToResolveInfoImpl<T> partialResolvedInfo) {
getPartialResolvedStack().push(partialResolvedInfo);
}
@@ -510,12 +505,8 @@
return getPartialResolvedStack().peek().getEntityToResolve();
}
- /**
- * Retrieves information about the entity that needs to be resolved.
- *
- * @return information about the entity that needs to be resolved
- */
- public YangEntityToResolveInfo<T> getEntityToResolveInfo() {
+ @Override
+ public YangEntityToResolveInfoImpl<T> getEntityToResolveInfo() {
return entityToResolveInfo;
}
@@ -525,7 +516,7 @@
* @param entityToResolveInfo information about the entity that needs to be
* resolved
*/
- private void setEntityToResolveInfo(YangEntityToResolveInfo<T> entityToResolveInfo) {
+ private void setEntityToResolveInfo(YangEntityToResolveInfoImpl<T> entityToResolveInfo) {
this.entityToResolveInfo = entityToResolveInfo;
}
@@ -569,13 +560,7 @@
this.curReferenceResolver = curReferenceResolver;
}
- /**
- * Performs inter file linking of uses/type referring to typedef/grouping
- * of other YANG file.
- *
- * @param dataModelRootNode module/sub-module node
- * @throws DataModelException a violation in data model rule
- */
+ @Override
public void linkInterFile(YangReferenceResolver dataModelRootNode)
throws DataModelException {
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListener.java
index c78aa1e..ce1922f 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListener.java
@@ -20,6 +20,7 @@
import org.onosproject.yangutils.datamodel.YangRangeRestriction;
import org.onosproject.yangutils.datamodel.YangStringRestriction;
import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
@@ -29,6 +30,7 @@
import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY;
import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.processLengthRestriction;
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;
@@ -36,7 +38,6 @@
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
-import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction;
import static org.onosproject.yangutils.utils.YangConstructType.LENGTH_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
@@ -125,8 +126,16 @@
throw parserException;
}
- YangRangeRestriction lengthRestriction = processLengthRestriction(null, ctx.getStart().getLine(),
- ctx.getStart().getCharPositionInLine(), false, ctx.length().getText());
+ YangRangeRestriction lengthRestriction = null;
+ try {
+ lengthRestriction = processLengthRestriction(null, ctx.getStart().getLine(),
+ ctx.getStart().getCharPositionInLine(), false, ctx.length().getText());
+ } catch (DataModelException e) {
+ ParserException parserException = new ParserException(e.getMessage());
+ parserException.setCharPosition(e.getCharPositionInLine());
+ parserException.setLine(e.getLineNumber());
+ throw parserException;
+ }
if (type.getDataType() == STRING) {
YangStringRestriction stringRestriction = (YangStringRestriction) type.getDataTypeExtendedInfo();
@@ -151,7 +160,7 @@
* @param ctx context object of the grammar rule
*/
public static void processLengthRestrictionExit(TreeWalkListener listener,
- GeneratedYangParser.LengthStatementContext ctx) {
+ GeneratedYangParser.LengthStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, LENGTH_DATA, ctx.length().getText(), EXIT);
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
index afa9acd..b7536a6 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
@@ -16,11 +16,12 @@
package org.onosproject.yangutils.parser.impl.listeners;
+import org.onosproject.yangutils.datamodel.ResolvableType;
import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangReferenceResolver;
import org.onosproject.yangutils.datamodel.YangRevision;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.ResolvableType;
-import org.onosproject.yangutils.linker.YangReferenceResolver;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -29,8 +30,7 @@
import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangModuleNode;
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;
@@ -75,7 +75,7 @@
* (module), perform validations and update 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 processModuleEntry(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
@@ -106,7 +106,7 @@
* validations and update 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 processModuleExit(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
@@ -123,10 +123,10 @@
((YangReferenceResolver) listener.getParsedDataStack()
.peek()).resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
} catch (DataModelException e) {
- ParserException parserException = new ParserException(e.getMessage());
- parserException.setLine(e.getLineNumber());
- parserException.setCharPosition(e.getCharPositionInLine());
- throw parserException;
+ LinkerException linkerException = new LinkerException(e.getMessage());
+ linkerException.setLine(e.getLineNumber());
+ linkerException.setCharPosition(e.getCharPositionInLine());
+ throw linkerException;
}
}
}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListener.java
index b0387ae..a3b9a6a 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListener.java
@@ -19,12 +19,15 @@
import org.onosproject.yangutils.datamodel.YangDerivedInfo;
import org.onosproject.yangutils.datamodel.YangRangeRestriction;
import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
+import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.isOfRangeRestrictedType;
+import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.processRangeRestriction;
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;
@@ -32,8 +35,6 @@
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
-import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType;
-import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRestriction;
import static org.onosproject.yangutils.utils.YangConstructType.RANGE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
@@ -95,8 +96,8 @@
* Sets the range restriction to type.
*
* @param listener listener's object
- * @param type YANG type for which range restriction to be added
- * @param ctx context object of the grammar rule
+ * @param type YANG type for which range restriction to be added
+ * @param ctx context object of the grammar rule
*/
private static void setRangeRestriction(TreeWalkListener listener, YangType type,
GeneratedYangParser.RangeStatementContext ctx) {
@@ -119,8 +120,16 @@
throw parserException;
}
- YangRangeRestriction rangeRestriction = processRangeRestriction(null, ctx.getStart().getLine(),
- ctx.getStart().getCharPositionInLine(), false, ctx.range().getText(), type.getDataType());
+ YangRangeRestriction rangeRestriction = null;
+ try {
+ rangeRestriction = processRangeRestriction(null, ctx.getStart().getLine(),
+ ctx.getStart().getCharPositionInLine(), false, ctx.range().getText(), type.getDataType());
+ } catch (DataModelException e) {
+ ParserException parserException = new ParserException(e.getMessage());
+ parserException.setCharPosition(e.getCharPositionInLine());
+ parserException.setLine(e.getLineNumber());
+ throw parserException;
+ }
if (rangeRestriction != null) {
type.setDataTypeExtendedInfo(rangeRestriction);
@@ -133,10 +142,10 @@
* It is called when parser exits from grammar rule (range).
*
* @param listener listener's object
- * @param ctx context object of the grammar rule
+ * @param ctx context object of the grammar rule
*/
public static void processRangeRestrictionExit(TreeWalkListener listener,
- GeneratedYangParser.RangeStatementContext ctx) {
+ GeneratedYangParser.RangeStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, RANGE_DATA, ctx.range().getText(), EXIT);
@@ -152,4 +161,4 @@
ctx.range().getText(), EXIT));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
index 048e635..f489ecd 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
@@ -16,11 +16,12 @@
package org.onosproject.yangutils.parser.impl.listeners;
+import org.onosproject.yangutils.datamodel.ResolvableType;
+import org.onosproject.yangutils.datamodel.YangReferenceResolver;
import org.onosproject.yangutils.datamodel.YangRevision;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.ResolvableType;
-import org.onosproject.yangutils.linker.YangReferenceResolver;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -29,8 +30,7 @@
import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangSubModuleNode;
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;
@@ -76,10 +76,10 @@
* module), perform validations and update 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 processSubModuleEntry(TreeWalkListener listener,
- GeneratedYangParser.SubModuleStatementContext ctx) {
+ GeneratedYangParser.SubModuleStatementContext ctx) {
// Check if stack is empty.
checkStackIsEmpty(listener, INVALID_HOLDER, SUB_MODULE_DATA, ctx.identifier().getText(),
@@ -109,10 +109,10 @@
* validations and update 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 processSubModuleExit(TreeWalkListener listener,
- GeneratedYangParser.SubModuleStatementContext ctx) {
+ GeneratedYangParser.SubModuleStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, SUB_MODULE_DATA, ctx.identifier().getText(),
@@ -128,10 +128,10 @@
((YangReferenceResolver) listener.getParsedDataStack().peek())
.resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
} catch (DataModelException e) {
- ParserException parserException = new ParserException(e.getMessage());
- parserException.setLine(e.getLineNumber());
- parserException.setCharPosition(e.getCharPositionInLine());
- throw parserException;
+ LinkerException linkerException = new LinkerException(e.getMessage());
+ linkerException.setLine(e.getLineNumber());
+ linkerException.setCharPosition(e.getCharPositionInLine());
+ throw linkerException;
}
}
}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
index 6e386da..73f91df 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
@@ -26,7 +26,7 @@
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.YangUnion;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
+import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
@@ -131,7 +131,7 @@
type.setResolvableStatus(UNRESOLVED);
// Add resolution information to the list
- YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type,
+ YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangType>(type,
(YangNode) parentNodeOfLeaf, errorLine, errorPosition);
addToResolutionList(resolutionInfo, ctx);
}
@@ -161,8 +161,8 @@
((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
// Add resolution information to the list
- YangResolutionInfo resolutionInfo =
- new YangResolutionInfo<YangType>(type, (YangNode) parentNodeOfLeafList, errorLine,
+ YangResolutionInfoImpl resolutionInfo =
+ new YangResolutionInfoImpl<YangType>(type, (YangNode) parentNodeOfLeafList, errorLine,
errorPosition);
addToResolutionList(resolutionInfo, ctx);
}
@@ -191,8 +191,8 @@
type.setResolvableStatus(UNRESOLVED);
// Add resolution information to the list
- YangResolutionInfo resolutionInfo =
- new YangResolutionInfo<YangType>(type, unionNode, errorLine, errorPosition);
+ YangResolutionInfoImpl resolutionInfo =
+ new YangResolutionInfoImpl<YangType>(type, unionNode, errorLine, errorPosition);
addToResolutionList(resolutionInfo, ctx);
}
@@ -214,8 +214,8 @@
type.setResolvableStatus(UNRESOLVED);
// Add resolution information to the list
- YangResolutionInfo resolutionInfo =
- new YangResolutionInfo<YangType>(type, typeDef, errorLine, errorPosition);
+ YangResolutionInfoImpl resolutionInfo =
+ new YangResolutionInfoImpl<YangType>(type, typeDef, errorLine, errorPosition);
addToResolutionList(resolutionInfo, ctx);
}
break;
@@ -256,7 +256,7 @@
* @param resolutionInfo resolution information
* @param ctx context object of the grammar rule
*/
- private static void addToResolutionList(YangResolutionInfo<YangType> resolutionInfo,
+ private static void addToResolutionList(YangResolutionInfoImpl<YangType> resolutionInfo,
GeneratedYangParser.TypeStatementContext ctx) {
try {
addResolutionInfo(resolutionInfo);
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UsesListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UsesListener.java
index fd6523f..48c2c3b 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UsesListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UsesListener.java
@@ -26,10 +26,10 @@
import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
import org.onosproject.yangutils.datamodel.YangNotification;
import org.onosproject.yangutils.datamodel.YangOutput;
-import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.datamodel.YangUses;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
@@ -110,7 +110,7 @@
* validations 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 processUsesEntry(TreeWalkListener listener, GeneratedYangParser.UsesStatementContext ctx) {
@@ -160,7 +160,7 @@
* @param ctx context object of the grammar rule
*/
public static void processUsesExit(TreeWalkListener listener,
- GeneratedYangParser.UsesStatementContext ctx) {
+ GeneratedYangParser.UsesStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, USES_DATA, ctx.string().getText(), EXIT);
@@ -184,7 +184,7 @@
}
// Add resolution information to the list
- YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangUses>(uses,
+ YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangUses>(uses,
(YangNode) parentNode, errorLine,
errorPosition);
addToResolutionList(resolutionInfo, ctx);
@@ -208,10 +208,10 @@
* Add to resolution list.
*
* @param resolutionInfo resolution information.
- * @param ctx context object of the grammar rule
+ * @param ctx context object of the grammar rule
*/
- private static void addToResolutionList(YangResolutionInfo<YangUses> resolutionInfo,
- GeneratedYangParser.UsesStatementContext ctx) {
+ private static void addToResolutionList(YangResolutionInfoImpl<YangUses> resolutionInfo,
+ GeneratedYangParser.UsesStatementContext ctx) {
try {
addResolutionInfo(resolutionInfo);
diff --git a/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java b/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
index adc7015..72e3fa2 100644
--- a/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
+++ b/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
@@ -1098,7 +1098,7 @@
/**
* Static attribute for YANG types package.
*/
- public static final String YANG_TYPES_PKG = "org.onosproject.yangutils.utils.builtindatatype";
+ public static final String YANG_TYPES_PKG = "org.onosproject.yangutils.datamodel.utils.builtindatatype";
/**
* Static attribute for MathContext class.
diff --git a/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java b/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java
index c170cd9..7920356 100644
--- a/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java
+++ b/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java
@@ -19,7 +19,6 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.ListIterator;
-
import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;
import org.onosproject.yangutils.datamodel.YangDataTypes;
@@ -71,6 +70,9 @@
YangNode refNode = null;
YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
// Add references to import list.
yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
@@ -137,6 +139,9 @@
YangNode refNode = null;
YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
// Add references to import list.
yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
@@ -211,6 +216,9 @@
YangNode refNode = null;
YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
// Carry out linking of sub module with module.
yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet());
@@ -280,6 +288,9 @@
YangNode refNode = null;
YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
// Carry out linking of sub module with module.
yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet());
@@ -357,6 +368,9 @@
YangNode refNode = null;
YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
// Add references to import list.
yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
@@ -423,6 +437,9 @@
YangNode refNode = null;
YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
// Add references to import list.
yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
@@ -490,6 +507,9 @@
YangNode refNode2 = null;
YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
// Add references to import list.
yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
@@ -554,6 +574,9 @@
YangNode refNode1 = null;
YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
// Add references to import list.
yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
diff --git a/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java b/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
index d4ffaae..202a096 100644
--- a/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
+++ b/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
@@ -26,6 +26,7 @@
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
@@ -33,12 +34,12 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY;
-import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
-import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
+import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
/**
* Test cases for testing "type" intra file linking.
@@ -488,9 +489,9 @@
* Check self resolution when type referred typedef is not available in
* file.
*/
- @Test(expected = ParserException.class)
+ @Test(expected = LinkerException.class)
public void processSelfResolutionWhenTypeReferredTypedefNotDefined()
- throws IOException, ParserException {
+ throws IOException, LinkerException {
YangNode node =
manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang");
@@ -500,9 +501,9 @@
* Checks self resolution when typedef and leaf using type are at different
* level where typedef is is not an ancestor of type.
*/
- @Test(expected = ParserException.class)
+ @Test(expected = LinkerException.class)
public void processSelfFileLinkingTypedefNotFound()
- throws IOException, ParserException {
+ throws IOException, LinkerException {
YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang");
}
@@ -510,9 +511,9 @@
/**
* Checks hierarchical self resolution with self resolution failure scenario.
*/
- @Test(expected = ParserException.class)
+ @Test(expected = LinkerException.class)
public void processSelfFileLinkingWithHierarchicalTypeFailureScenario()
- throws IOException, ParserException {
+ throws IOException, LinkerException {
YangNode node =
manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang");
diff --git a/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java b/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
index 50d8d20..356a659 100644
--- a/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
+++ b/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
@@ -19,7 +19,6 @@
import java.io.IOException;
import java.util.List;
import java.util.ListIterator;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -581,9 +580,9 @@
*/
@Test
public void processSelfResolutionNestedGroupingWithUnresolvedUses()
- throws IOException, ParserException {
+ throws IOException, LinkerException {
- thrown.expect(ParserException.class);
+ thrown.expect(LinkerException.class);
thrown.expectMessage(
"YANG file error: Unable to find base grouping for given uses");
diff --git a/src/test/java/org/onosproject/yangutils/linker/RestrictionResolutionTest.java b/src/test/java/org/onosproject/yangutils/linker/RestrictionResolutionTest.java
index 1be5b25..af309fd 100644
--- a/src/test/java/org/onosproject/yangutils/linker/RestrictionResolutionTest.java
+++ b/src/test/java/org/onosproject/yangutils/linker/RestrictionResolutionTest.java
@@ -30,21 +30,21 @@
import org.onosproject.yangutils.datamodel.YangStringRestriction;
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt32;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
import org.onosproject.yangutils.linker.exceptions.LinkerException;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
-import org.onosproject.yangutils.utils.builtindatatype.YangInt32;
-import org.onosproject.yangutils.utils.builtindatatype.YangUint64;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
-import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
/**
* Test cases for testing restriction resolution.
@@ -412,7 +412,7 @@
/**
* Checks range restriction in typedef and not stricter in referred type.
*/
- @Test(expected = ParserException.class)
+ @Test(expected = LinkerException.class)
public void processRangeRestrictionInRefTypeAndTypedefInValid()
throws IOException, ParserException, DataModelException {
YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang");
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
index 3df9c13..0c862ba 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
@@ -34,7 +34,7 @@
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
-import org.onosproject.yangutils.utils.builtindatatype.YangUint64;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
index 466bb97..0ed801f 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
@@ -31,7 +31,7 @@
import org.onosproject.yangutils.datamodel.YangRangeRestriction;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
-import org.onosproject.yangutils.utils.builtindatatype.YangInt32;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt32;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;