Gaurav Agrawal
Committed by Gerrit Code Review

[ONOS-4670] Removal of Data Model dependencies on Linker

Change-Id: I3f9c5af30198ea31d743e06cea1764dcb306ec32
Showing 50 changed files with 460 additions and 334 deletions
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.onosproject.yangutils.linker;
package org.onosproject.yangutils.datamodel;
/**
* Type of the resolvable info.
......
......@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel;
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 @@ public class YangBelongsTo implements Parsable, LocationInfo {
/**
* 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);
......
......@@ -33,9 +33,9 @@ import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
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.
......
/*
* 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);
}
......@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel;
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 @@ public class YangImport
/**
* 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 @@ public class YangImport
*/
if (importedModuleRevision != null) {
String importedModuleNameWithRevision = importedModuleName + "@" + importedModuleRevision;
moduleNode = findReferredNode(yangFileInfoSet, importedModuleNameWithRevision);
moduleNode = findReferredNode(yangNodeSet, importedModuleNameWithRevision);
}
/*
......@@ -258,7 +257,7 @@ public class YangImport
* without revision if can't find with revision.
*/
if (moduleNode == null) {
moduleNode = findReferredNode(yangFileInfoSet, importedModuleName);
moduleNode = findReferredNode(yangNodeSet, importedModuleName);
}
if (moduleNode != null) {
......
......@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel;
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 @@ public class YangInclude
/**
* 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 @@ public class YangInclude
*/
if (includedSubModuleRevision != null) {
String includedSubModuleNameWithRevision = includedSubModuleName + "@" + includedSubModuleRevision;
subModuleNode = findReferredNode(yangFileInfoSet, includedSubModuleNameWithRevision);
subModuleNode = findReferredNode(yangNodeSet, includedSubModuleNameWithRevision);
}
/*
......@@ -196,7 +195,7 @@ public class YangInclude
* without revision if can't find with revision.
*/
if (subModuleNode == null) {
subModuleNode = findReferredNode(yangFileInfoSet, includedSubModuleName);
subModuleNode = findReferredNode(yangNodeSet, includedSubModuleName);
}
if (subModuleNode != null) {
......
......@@ -26,7 +26,7 @@ package org.onosproject.yangutils.datamodel;
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.
......
......@@ -19,14 +19,8 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.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 @@ public class YangModule
/**
* 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 @@ public class YangModule
/**
* 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 @@ public class YangModule
/**
* 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 class YangModule
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 @@ public class YangModule
@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 @@ public class YangModule
@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 @@ public class YangModule
}
@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();
}
}
}
......
......@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
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.
......
......@@ -21,9 +21,9 @@ import java.util.List;
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;
/*-
......
......@@ -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 @@ public interface YangReferenceResolver {
/**
* 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;
}
......
/*
* 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;
}
......@@ -19,7 +19,7 @@ package org.onosproject.yangutils.datamodel;
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.
......
......@@ -19,14 +19,8 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.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 class YangSubModule
*/
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 @@ public class YangSubModule
@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 @@ public class YangSubModule
@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 @@ public class YangSubModule
/**
* 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);
}
}
}
......
......@@ -19,7 +19,6 @@ package org.onosproject.yangutils.datamodel;
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 @@ public class YangType<T>
@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());
}
}
}
......
......@@ -17,11 +17,9 @@ package org.onosproject.yangutils.datamodel;
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 @@ public class YangUses
@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 @@ public class YangUses
* @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 @@ public class YangUses
* @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 @@ public class YangUses
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 @@ public class YangUses
* @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 @@ public class YangUses
YangConstructType.LEAF_LIST_DATA);
clonedLeafList = leafList.clone();
} catch (CloneNotSupportedException | DataModelException e) {
throw new LinkerException(e.getMessage());
throw new DataModelException(e.getMessage());
}
clonedLeafList.setContainedIn(usesParentNode);
......
......@@ -18,20 +18,18 @@ package org.onosproject.yangutils.datamodel.utils;
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 @@ public final class DataModelUtils {
* @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 @@ public final class DataModelUtils {
* @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 @@ public final class DataModelUtils {
/**
* 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;
......
......@@ -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.UINT16;
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 @@ public final class RestrictionResolver {
* @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 @@ public final class RestrictionResolver {
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 @@ public final class RestrictionResolver {
} 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 @@ public final class RestrictionResolver {
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 @@ public final class RestrictionResolver {
* @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 @@ public final class RestrictionResolver {
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 @@ public final class RestrictionResolver {
} 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 @@ public final class RestrictionResolver {
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 @@ public final class RestrictionResolver {
|| 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();
}
}
......
......@@ -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 @@ public final class BuiltInTypeObjectFactory {
* 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: {
......
......@@ -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 @@ public class DataTypeException extends RuntimeException {
* 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);
......
......@@ -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;
/**
......
......@@ -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;
/**
......
......@@ -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;
......
......@@ -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;
/**
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -17,4 +17,4 @@
/**
* Utilities for YANG built in data types.
*/
package org.onosproject.yangutils.utils.builtindatatype;
package org.onosproject.yangutils.datamodel.utils.builtindatatype;
......
......@@ -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 @@ public interface Resolvable {
/**
* Resolves the linking.
*
* @throws LinkerException linker error
* @throws DataModelException data model exception
*/
void resolve()
throws LinkerException;
throws DataModelException;
}
......
......@@ -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 @@ public class YangEntityToResolveInfo<T> {
// 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;
}
......
......@@ -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 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
*/
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 @@ public class YangLinkerManager
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 @@ public class YangLinkerManager
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 @@ public class YangLinkerManager
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);
}
}
}
}
......
......@@ -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.datamodel.exceptions.DataModelException;
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.RESOLVED;
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 @@ public class YangResolutionInfo<T>
* 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 @@ public class YangResolutionInfo<T>
* @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 @@ public class YangResolutionInfo<T>
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 @@ public class YangResolutionInfo<T>
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 @@ public class YangResolutionInfo<T>
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 @@ public class YangResolutionInfo<T>
*
* @return partial resolved YANG construct stack
*/
private Stack<YangEntityToResolveInfo<T>> getPartialResolvedStack() {
private Stack<YangEntityToResolveInfoImpl<T>> getPartialResolvedStack() {
return partialResolvedStack;
}
......@@ -487,7 +482,7 @@ public class YangResolutionInfo<T>
*
* @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 @@ public class YangResolutionInfo<T>
*
* @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 @@ public class YangResolutionInfo<T>
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 @@ public class YangResolutionInfo<T>
* @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 @@ public class YangResolutionInfo<T>
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 {
......
......@@ -20,6 +20,7 @@ import org.onosproject.yangutils.datamodel.YangDerivedInfo;
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 org.onosproject.yangutils.utils.YangConstructType;
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.ListenerErrorTyp
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 @@ public final class LengthRestrictionListener {
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 @@ public final class LengthRestrictionListener {
* @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);
......
......@@ -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.GeneratedLanguage.JAVA_G
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 @@ public final class ModuleListener {
* (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 @@ public final class ModuleListener {
* 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 @@ public final class ModuleListener {
((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;
}
}
}
......
......@@ -19,12 +19,15 @@ package org.onosproject.yangutils.parser.impl.listeners;
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.ListenerErrorTyp
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 @@ public final class RangeRestrictionListener {
* 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 @@ public final class RangeRestrictionListener {
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 @@ public final class RangeRestrictionListener {
* 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 @@ public final class RangeRestrictionListener {
ctx.range().getText(), EXIT));
}
}
}
\ No newline at end of file
}
......
......@@ -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.GeneratedLanguage.JAVA_G
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 @@ public final class SubModuleListener {
* 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 @@ public final class SubModuleListener {
* 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 @@ public final class SubModuleListener {
((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;
}
}
}
......
......@@ -26,7 +26,7 @@ import org.onosproject.yangutils.datamodel.YangType;
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 @@ public final class TypeListener {
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 @@ public final class TypeListener {
((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 @@ public final class TypeListener {
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 @@ public final class TypeListener {
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 @@ public final class TypeListener {
* @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);
......
......@@ -26,10 +26,10 @@ import org.onosproject.yangutils.datamodel.YangNode;
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 @@ public final class UsesListener {
* 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 @@ public final class UsesListener {
* @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 @@ public final class UsesListener {
}
// 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 @@ public final class UsesListener {
* 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);
......
......@@ -1098,7 +1098,7 @@ public final class UtilConstants {
/**
* 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.
......
......@@ -19,7 +19,6 @@ package org.onosproject.yangutils.linker;
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 @@ public class InterFileLinkingTest {
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 @@ public class InterFileLinkingTest {
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 @@ public class InterFileLinkingTest {
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 @@ public class InterFileLinkingTest {
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 @@ public class InterFileLinkingTest {
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 @@ public class InterFileLinkingTest {
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 @@ public class InterFileLinkingTest {
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 @@ public class InterFileLinkingTest {
YangNode refNode1 = null;
YangNode selfNode = null;
// Create YANG node set
yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
// Add references to import list.
yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
......
......@@ -26,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangList;
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.CoreMatchers.nullValue;
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 @@ public class IntraFileTypeLinkingTest {
* 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 @@ public class IntraFileTypeLinkingTest {
* 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 @@ public class IntraFileTypeLinkingTest {
/**
* 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");
......
......@@ -19,7 +19,6 @@ package org.onosproject.yangutils.linker;
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 @@ public class IntraFileUsesLinkingTest {
*/
@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");
......
......@@ -30,21 +30,21 @@ import org.onosproject.yangutils.datamodel.YangRangeRestriction;
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 @@ public final class RestrictionResolutionTest {
/**
* 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");
......
......@@ -34,7 +34,7 @@ import org.onosproject.yangutils.datamodel.YangStringRestriction;
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;
......
......@@ -31,7 +31,7 @@ import org.onosproject.yangutils.datamodel.YangRangeInterval;
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;
......